From 0181bebd7085905392184984c8b54f196cfd43c8 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 11 Jun 2022 15:33:32 +0200 Subject: [PATCH] Rename ambiguous theParent variable to mainGui --- novelwriter/core/project.py | 78 ++++++++++----------- novelwriter/core/tokenizer.py | 1 - novelwriter/dialogs/about.py | 22 +++--- novelwriter/dialogs/docmerge.py | 30 ++++---- novelwriter/dialogs/docsplit.py | 30 ++++---- novelwriter/dialogs/itemeditor.py | 8 +-- novelwriter/dialogs/preferences.py | 98 +++++++++++++------------- novelwriter/dialogs/projdetails.py | 28 ++++---- novelwriter/dialogs/projload.py | 14 ++-- novelwriter/dialogs/projsettings.py | 48 ++++++------- novelwriter/dialogs/quotes.py | 4 +- novelwriter/dialogs/updates.py | 10 +-- novelwriter/dialogs/wordlist.py | 14 ++-- novelwriter/gui/custom.py | 8 +-- novelwriter/gui/doceditor.py | 70 +++++++++---------- novelwriter/gui/dochighlight.py | 10 +-- novelwriter/gui/docviewer.py | 40 +++++------ novelwriter/gui/itemdetails.py | 10 +-- novelwriter/gui/mainmenu.py | 102 ++++++++++++++-------------- novelwriter/gui/noveltree.py | 18 ++--- novelwriter/gui/outline.py | 28 ++++---- novelwriter/gui/projtree.py | 48 ++++++------- novelwriter/gui/statusbar.py | 8 +-- novelwriter/gui/viewsbar.py | 20 +++--- novelwriter/tools/build.py | 28 ++++---- novelwriter/tools/lipsum.py | 14 ++-- novelwriter/tools/projwizard.py | 10 +-- novelwriter/tools/writingstats.py | 16 ++--- 28 files changed, 407 insertions(+), 408 deletions(-) diff --git a/novelwriter/core/project.py b/novelwriter/core/project.py index cce4603d..dfb577b1 100644 --- a/novelwriter/core/project.py +++ b/novelwriter/core/project.py @@ -56,11 +56,11 @@ class NWProject(): FILE_VERSION = "1.4" # The current project file format version - def __init__(self, theParent): + def __init__(self, mainGui): # Internal - self.theParent = theParent - self.mainConf = novelwriter.CONFIG + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui # Core Elements self._optState = OptionState(self) # Project-specific GUI options @@ -414,7 +414,7 @@ class NWProject(): if not os.path.isfile(fileName): fileName = os.path.join(fileName, nwFiles.PROJ_FILE) if not os.path.isfile(fileName): - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "File not found: {0}" ).format(fileName), nwAlert.ERROR) return False @@ -465,20 +465,20 @@ class NWProject(): try: nwXML = etree.parse(fileName) except Exception as exc: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Failed to parse project xml." ), nwAlert.ERROR, exception=exc) # Trying to open backup file instead backFile = fileName[:-3]+"bak" if os.path.isfile(backFile): - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Attempting to open backup project file instead." ), nwAlert.INFO) try: nwXML = etree.parse(backFile) except Exception as exc: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Failed to parse project xml." ), nwAlert.ERROR, exception=exc) self.clearProject() @@ -501,7 +501,7 @@ class NWProject(): # =============== if not nwxRoot == "novelWriterXML": - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Project file does not appear to be a novelWriterXML file." ), nwAlert.ERROR) self.clearProject() @@ -527,7 +527,7 @@ class NWProject(): # stored and handled. Introduced in version 1.7. 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. " "The project cannot be opened by this version of novelWriter. " "The file was saved with novelWriter version {0}." @@ -536,7 +536,7 @@ class NWProject(): return False if fileVersion != self.FILE_VERSION: - msgYes = self.theParent.askQuestion( + msgYes = self.mainGui.askQuestion( self.tr("File Version"), self.tr( "The file format of your project is about to be updated. " @@ -552,7 +552,7 @@ class NWProject(): # ========================= if hexToInt(hexVersion) > hexToInt(novelwriter.__hexversion__): - msgYes = self.theParent.askQuestion( + msgYes = self.mainGui.askQuestion( self.tr("Version Conflict"), self.tr( "This project was saved by a newer version of " @@ -646,7 +646,7 @@ class NWProject(): for projItem in legacyList: errList = self._legacyDataFolder(projItem, errList) if errList: - self.theParent.makeAlert(errList, nwAlert.ERROR) + self.mainGui.makeAlert(errList, nwAlert.ERROR) # Clean up no longer used files self._deprecatedFiles() @@ -672,7 +672,7 @@ class NWProject(): self._writeLockFile() 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 @@ -683,7 +683,7 @@ class NWProject(): file. """ if self.projPath is None: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Project path not set, cannot save project." ), nwAlert.ERROR) return False @@ -763,7 +763,7 @@ class NWProject(): xml_declaration=True )) except Exception as exc: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Failed to save project." ), nwAlert.ERROR, exception=exc) return False @@ -775,7 +775,7 @@ class NWProject(): os.replace(saveFile, backFile) os.replace(tempFile, saveFile) except OSError as exc: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Failed to save project." ), nwAlert.ERROR, exception=exc) return False @@ -788,7 +788,7 @@ class NWProject(): self.mainConf.saveRecentCache() 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) return True @@ -836,22 +836,22 @@ class NWProject(): def zipIt(self, doNotify): """Create a zip file of the entire project. """ - if not self.theParent.hasProject: + if not self.mainGui.hasProject: logger.error("No project open") return False 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)): - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Cannot backup project because no valid backup path is set. " "Please set a valid backup location in Preferences." ), nwAlert.ERROR) return False if not self.projName: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Cannot backup project because no project name is set. " "Please set a Working Title in Project Settings." ), nwAlert.ERROR) @@ -864,13 +864,13 @@ class NWProject(): os.mkdir(baseDir) logger.debug("Created folder: %s", baseDir) except Exception as exc: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Could not create backup folder." ), nwAlert.ERROR, exception=exc) return False 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 " "project folder to be backed up. Please choose a different " "backup path in Preferences." @@ -886,17 +886,17 @@ class NWProject(): self._writeLockFile() logger.info("Backup written to: %s", archName) if doNotify: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Backup archive file written to: {0}" ).format(f"{os.path.join(cleanName, archName)}.zip"), nwAlert.INFO) except Exception as exc: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Could not write backup archive." ), nwAlert.ERROR, exception=exc) return False - self.theParent.setStatus(self.tr( + self.mainGui.setStatus(self.tr( "Project backed up to '{0}'" ).format(f"{baseName}.zip")) @@ -924,7 +924,7 @@ class NWProject(): shutil.unpack_archive(pkgSample, projPath) isSuccess = True except Exception as exc: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Failed to create a new example project." ), nwAlert.ERROR, exception=exc) @@ -946,12 +946,12 @@ class NWProject(): isSuccess = True except Exception as exc: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Failed to create a new example project." ), nwAlert.ERROR, exception=exc) else: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Failed to create a new example project. " "Could not find the necessary files. " "They seem to be missing from this installation." @@ -959,8 +959,8 @@ class NWProject(): if isSuccess: self.clearProject() - self.theParent.openProject(projPath) - self.theParent.rebuildIndex() + self.mainGui.openProject(projPath) + self.mainGui.rebuildIndex() return isSuccess @@ -985,14 +985,14 @@ class NWProject(): os.mkdir(projPath) logger.debug("Created folder: %s", projPath) except Exception as exc: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Could not create new project folder." ), nwAlert.ERROR, exception=exc) return False if os.path.isdir(projPath): if os.listdir(self.projPath): - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "New project folder is not empty. " "Each project requires a dedicated project folder." ), nwAlert.ERROR) @@ -1042,14 +1042,14 @@ class NWProject(): self.doBackup = doBackup if doBackup: 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 " "the automatic project backup feature." ), nwAlert.WARN) return False if self.projName == "": - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "You must set a valid project name in Project Settings to " "use the automatic project backup feature." ), nwAlert.WARN) @@ -1154,7 +1154,7 @@ class NWProject(): information to the GUI statusbar. """ self.projChanged = bValue - self.theParent.statusBar.doUpdateProjectStatus(bValue) + self.mainGui.statusBar.doUpdateProjectStatus(bValue) if bValue: # If we've changed the project at all, this should be True self.projAltered = True @@ -1384,7 +1384,7 @@ class NWProject(): os.mkdir(thePath) logger.debug("Created folder: %s", thePath) except Exception as exc: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Could not create folder." ), nwAlert.ERROR, exception=exc) return False @@ -1447,7 +1447,7 @@ class NWProject(): # Report status if len(orphanFiles) > 0: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Found {0} orphaned file(s) in project folder." ).format(len(orphanFiles)), nwAlert.WARN) else: @@ -1504,7 +1504,7 @@ class NWProject(): self._projTree.updateItemData(orphItem.itemHandle) 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. " "Make sure at least a Novel root folder exists." ), nwAlert.WARN) diff --git a/novelwriter/core/tokenizer.py b/novelwriter/core/tokenizer.py index bb5f3d8e..3a3b52f1 100644 --- a/novelwriter/core/tokenizer.py +++ b/novelwriter/core/tokenizer.py @@ -82,7 +82,6 @@ class Tokenizer(ABC): def __init__(self, theProject): self.theProject = theProject - self.theParent = theProject.theParent self.mainConf = novelwriter.CONFIG # Data Variables diff --git a/novelwriter/dialogs/about.py b/novelwriter/dialogs/about.py index f832343a..83e3c347 100644 --- a/novelwriter/dialogs/about.py +++ b/novelwriter/dialogs/about.py @@ -43,15 +43,15 @@ logger = logging.getLogger(__name__) class GuiAbout(QDialog): - def __init__(self, theParent): - QDialog.__init__(self, theParent) + def __init__(self, mainGui): + QDialog.__init__(self, mainGui) logger.debug("Initialising GuiAbout ...") self.setObjectName("GuiAbout") - self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui + self.theTheme = mainGui.theTheme self.outerBox = QVBoxLayout() self.innerBox = QHBoxLayout() @@ -63,7 +63,7 @@ class GuiAbout(QDialog): nPx = self.mainConf.pxInt(96) 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("novelWriter") self.lblVers = QLabel(f"v{novelwriter.__version__}") self.lblDate = QLabel(datetime.strptime(novelwriter.__date__, "%Y-%m-%d").strftime("%x")) @@ -191,8 +191,8 @@ class GuiAbout(QDialog): ]) ) - theTheme = self.theParent.theTheme - theIcons = self.theParent.theTheme.theIcons + theTheme = self.mainGui.theTheme + theIcons = self.mainGui.theTheme.theIcons if theTheme.themeName and theTheme.themeAuthor != "N/A": licURL = f"{theTheme.themeLicense}" aboutMsg += "

{0}

{1}

".format( @@ -279,9 +279,9 @@ class GuiAbout(QDialog): " padding-right: 0.8em;" "}}\n" ).format( - hColR=self.theParent.theTheme.colHead[0], - hColG=self.theParent.theTheme.colHead[1], - hColB=self.theParent.theTheme.colHead[2], + hColR=self.mainGui.theTheme.colHead[0], + hColG=self.mainGui.theTheme.colHead[1], + hColB=self.mainGui.theTheme.colHead[2], kColR=self.theTheme.colKey[0], kColG=self.theTheme.colKey[1], kColB=self.theTheme.colKey[2], diff --git a/novelwriter/dialogs/docmerge.py b/novelwriter/dialogs/docmerge.py index 033f3698..23657fb5 100644 --- a/novelwriter/dialogs/docmerge.py +++ b/novelwriter/dialogs/docmerge.py @@ -41,15 +41,15 @@ logger = logging.getLogger(__name__) class GuiDocMerge(QDialog): - def __init__(self, theParent): - QDialog.__init__(self, theParent) + def __init__(self, mainGui): + QDialog.__init__(self, mainGui) logger.debug("Initialising GuiDocMerge ...") self.setObjectName("GuiDocMerge") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theProject = mainGui.theProject self.sourceItem = None self.outerBox = QVBoxLayout() @@ -57,7 +57,7 @@ class GuiDocMerge(QDialog): self.headLabel = QLabel("{0}".format(self.tr("Documents to Merge"))) 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() @@ -102,7 +102,7 @@ class GuiDocMerge(QDialog): finalOrder.append(self.listBox.item(i).data(Qt.UserRole)) if len(finalOrder) == 0: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "No source documents found. Nothing to do." ), nwAlert.ERROR) return False @@ -113,21 +113,21 @@ class GuiDocMerge(QDialog): docText = inDoc.readDocument() docErr = inDoc.getError() if docText is None and docErr: - self.theParent.makeAlert([ + self.mainGui.makeAlert([ self.tr("Failed to open document file."), docErr ], nwAlert.ERROR) if docText: theText += docText.rstrip("\n")+"\n\n" if self.sourceItem is None: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "No source folder selected. Nothing to do." ), nwAlert.ERROR) return False srcItem = self.theProject.tree[self.sourceItem] if srcItem is None: - self.theParent.makeAlert(self.tr("Internal error."), nwAlert.ERROR) + self.mainGui.makeAlert(self.tr("Internal error."), nwAlert.ERROR) return False nHandle = self.theProject.newFile(srcItem.itemName, srcItem.itemParent) @@ -137,13 +137,13 @@ class GuiDocMerge(QDialog): outDoc = NWDoc(self.theProject, nHandle) if not outDoc.writeDocument(theText): - self.theParent.makeAlert([ + self.mainGui.makeAlert([ self.tr("Could not save document."), outDoc.getError() ], nwAlert.ERROR) return False - self.theParent.treeView.revealNewTreeItem(nHandle) - self.theParent.openDocument(nHandle, doScroll=True) + self.mainGui.treeView.revealNewTreeItem(nHandle) + self.mainGui.openDocument(nHandle, doScroll=True) self._doClose() @@ -165,7 +165,7 @@ class GuiDocMerge(QDialog): are then added to the list view in order. The list itself can be reordered by the user. """ - tHandle = self.theParent.treeView.getSelectedHandle() + tHandle = self.mainGui.treeView.getSelectedHandle() self.sourceItem = tHandle if tHandle is None: return False @@ -175,12 +175,12 @@ class GuiDocMerge(QDialog): return False 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." ), nwAlert.ERROR) return False - for sHandle in self.theParent.treeView.getTreeFromHandle(tHandle): + for sHandle in self.mainGui.treeView.getTreeFromHandle(tHandle): newItem = QListWidgetItem() nwItem = self.theProject.tree[sHandle] if nwItem.itemType is not nwItemType.FILE: diff --git a/novelwriter/dialogs/docsplit.py b/novelwriter/dialogs/docsplit.py index 76e64d5f..4d2ecc4a 100644 --- a/novelwriter/dialogs/docsplit.py +++ b/novelwriter/dialogs/docsplit.py @@ -41,15 +41,15 @@ logger = logging.getLogger(__name__) class GuiDocSplit(QDialog): - def __init__(self, theParent): - QDialog.__init__(self, theParent) + def __init__(self, mainGui): + QDialog.__init__(self, mainGui) logger.debug("Initialising GuiDocSplit ...") self.setObjectName("GuiDocSplit") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theProject = mainGui.theProject self.sourceItem = None self.sourceText = [] @@ -60,7 +60,7 @@ class GuiDocSplit(QDialog): self.headLabel = QLabel("{0}".format(self.tr("Document Headers"))) self.helpLabel = QHelpLabel( self.tr("Select the maximum level to split into files."), - self.theParent.theTheme.helpText + self.mainGui.theTheme.helpText ) self.listBox = QListWidget() @@ -115,14 +115,14 @@ class GuiDocSplit(QDialog): logger.verbose("GuiDocSplit split button clicked") if self.sourceItem is None: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "No source document selected. Nothing to do." ), nwAlert.ERROR) return False srcItem = self.theProject.tree[self.sourceItem] if srcItem is None: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Could not parse source document." ), nwAlert.ERROR) return False @@ -132,7 +132,7 @@ class GuiDocSplit(QDialog): docErr = inDoc.getError() if theText is None and docErr: - self.theParent.makeAlert([ + self.mainGui.makeAlert([ self.tr("Failed to open document file."), docErr ], nwAlert.ERROR) @@ -153,12 +153,12 @@ class GuiDocSplit(QDialog): nFiles = len(finalOrder) if nFiles == 0: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "No headers found. Nothing to do." ), nwAlert.ERROR) return False - msgYes = self.theParent.askQuestion( + msgYes = self.mainGui.askQuestion( self.tr("Split Document"), "{0}

{1}".format( self.tr( @@ -175,7 +175,7 @@ class GuiDocSplit(QDialog): # Create the folder fHandle = self.theProject.newFolder(srcItem.itemName, srcItem.itemParent) - self.theParent.treeView.revealNewTreeItem(fHandle) + self.mainGui.treeView.revealNewTreeItem(fHandle) logger.verbose("Creating folder '%s'", fHandle) # Loop through, and create the files @@ -196,12 +196,12 @@ class GuiDocSplit(QDialog): outDoc = NWDoc(self.theProject, nHandle) if not outDoc.writeDocument(theText): - self.theParent.makeAlert([ + self.mainGui.makeAlert([ self.tr("Could not save document."), outDoc.getError() ], nwAlert.ERROR) return False - self.theParent.treeView.revealNewTreeItem(nHandle) + self.mainGui.treeView.revealNewTreeItem(nHandle) self._doClose() @@ -226,7 +226,7 @@ class GuiDocSplit(QDialog): """ self.listBox.clear() if self.sourceItem is None: - self.sourceItem = self.theParent.treeView.getSelectedHandle() + self.sourceItem = self.mainGui.treeView.getSelectedHandle() if self.sourceItem is None: return False @@ -236,7 +236,7 @@ class GuiDocSplit(QDialog): return False 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." ), nwAlert.ERROR) return False diff --git a/novelwriter/dialogs/itemeditor.py b/novelwriter/dialogs/itemeditor.py index acf07134..7ad4eed0 100644 --- a/novelwriter/dialogs/itemeditor.py +++ b/novelwriter/dialogs/itemeditor.py @@ -41,15 +41,15 @@ logger = logging.getLogger(__name__) class GuiItemEditor(QDialog): - def __init__(self, theParent, tHandle): - QDialog.__init__(self, theParent) + def __init__(self, mainGui, tHandle): + QDialog.__init__(self, mainGui) logger.debug("Initialising GuiItemEditor ...") self.setObjectName("GuiItemEditor") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theProject = mainGui.theProject ## # Build GUI diff --git a/novelwriter/dialogs/preferences.py b/novelwriter/dialogs/preferences.py index 755b9198..4b74655f 100644 --- a/novelwriter/dialogs/preferences.py +++ b/novelwriter/dialogs/preferences.py @@ -43,25 +43,25 @@ logger = logging.getLogger(__name__) class GuiPreferences(PagedDialog): - def __init__(self, theParent): - PagedDialog.__init__(self, theParent) + def __init__(self, mainGui): + PagedDialog.__init__(self, mainGui) logger.debug("Initialising GuiPreferences ...") self.setObjectName("GuiPreferences") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theProject = mainGui.theProject self.setWindowTitle(self.tr("Preferences")) - self.tabGeneral = GuiPreferencesGeneral(self.theParent) - self.tabProjects = GuiPreferencesProjects(self.theParent) - self.tabDocs = GuiPreferencesDocuments(self.theParent) - self.tabEditor = GuiPreferencesEditor(self.theParent) - self.tabSyntax = GuiPreferencesSyntax(self.theParent) - self.tabAuto = GuiPreferencesAutomation(self.theParent) - self.tabQuote = GuiPreferencesQuotes(self.theParent) + self.tabGeneral = GuiPreferencesGeneral(self.mainGui) + self.tabProjects = GuiPreferencesProjects(self.mainGui) + self.tabDocs = GuiPreferencesDocuments(self.mainGui) + self.tabEditor = GuiPreferencesEditor(self.mainGui) + self.tabSyntax = GuiPreferencesSyntax(self.mainGui) + self.tabAuto = GuiPreferencesAutomation(self.mainGui) + self.tabQuote = GuiPreferencesQuotes(self.mainGui) self.addTab(self.tabGeneral, self.tr("General")) self.addTab(self.tabProjects, self.tr("Projects")) @@ -102,12 +102,12 @@ class GuiPreferences(PagedDialog): self.tabQuote.saveValues() if needsRestart: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Some changes will not be applied until novelWriter has been restarted." ), nwAlert.INFO) if refreshTree: - self.theParent.treeView.populateTree() + self.mainGui.treeView.populateTree() self._saveWindowSize() self.accept() @@ -138,12 +138,12 @@ class GuiPreferences(PagedDialog): class GuiPreferencesGeneral(QWidget): - def __init__(self, theParent): - QWidget.__init__(self, theParent) + def __init__(self, mainGui): + QWidget.__init__(self, mainGui) - self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui + self.theTheme = mainGui.theTheme # The Form self.mainForm = QConfigLayout() @@ -344,12 +344,12 @@ class GuiPreferencesGeneral(QWidget): class GuiPreferencesProjects(QWidget): - def __init__(self, theParent): - QWidget.__init__(self, theParent) + def __init__(self, mainGui): + QWidget.__init__(self, mainGui) - self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui + self.theTheme = mainGui.theTheme # The Form self.mainForm = QConfigLayout() @@ -505,12 +505,12 @@ class GuiPreferencesProjects(QWidget): class GuiPreferencesDocuments(QWidget): - def __init__(self, theParent): - QWidget.__init__(self, theParent) + def __init__(self, mainGui): + QWidget.__init__(self, mainGui) - self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui + self.theTheme = mainGui.theTheme # The Form self.mainForm = QConfigLayout() @@ -666,12 +666,12 @@ class GuiPreferencesDocuments(QWidget): class GuiPreferencesEditor(QWidget): - def __init__(self, theParent): - QWidget.__init__(self, theParent) + def __init__(self, mainGui): + QWidget.__init__(self, mainGui) - self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui + self.theTheme = mainGui.theTheme # The Form self.mainForm = QConfigLayout() @@ -688,7 +688,7 @@ class GuiPreferencesEditor(QWidget): self.spellLanguage = QComboBox(self) self.spellLanguage.setMaximumWidth(mW) - langAvail = self.theParent.docEditor.spEnchant.listDictionaries() + langAvail = self.mainGui.docEditor.spEnchant.listDictionaries() if self.mainConf.hasEnchant: if langAvail: for spTag, spProv in langAvail: @@ -840,12 +840,12 @@ class GuiPreferencesEditor(QWidget): class GuiPreferencesSyntax(QWidget): - def __init__(self, theParent): - QWidget.__init__(self, theParent) + def __init__(self, mainGui): + QWidget.__init__(self, mainGui) - self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui + self.theTheme = mainGui.theTheme # The Form self.mainForm = QConfigLayout() @@ -943,12 +943,12 @@ class GuiPreferencesSyntax(QWidget): class GuiPreferencesAutomation(QWidget): - def __init__(self, theParent): - QWidget.__init__(self, theParent) + def __init__(self, mainGui): + QWidget.__init__(self, mainGui) - self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui + self.theTheme = mainGui.theTheme # The Form self.mainForm = QConfigLayout() @@ -1100,12 +1100,12 @@ class GuiPreferencesAutomation(QWidget): class GuiPreferencesQuotes(QWidget): - def __init__(self, theParent): - QWidget.__init__(self, theParent) + def __init__(self, mainGui): + QWidget.__init__(self, mainGui) - self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui + self.theTheme = mainGui.theTheme # The Form self.mainForm = QConfigLayout() diff --git a/novelwriter/dialogs/projdetails.py b/novelwriter/dialogs/projdetails.py index 258b82e4..8ab1943f 100644 --- a/novelwriter/dialogs/projdetails.py +++ b/novelwriter/dialogs/projdetails.py @@ -43,15 +43,15 @@ logger = logging.getLogger(__name__) class GuiProjectDetails(PagedDialog): - def __init__(self, theParent): - PagedDialog.__init__(self, theParent) + def __init__(self, mainGui): + PagedDialog.__init__(self, mainGui) logger.debug("Initialising GuiProjectDetails ...") self.setObjectName("GuiProjectDetails") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theProject = mainGui.theProject self.setWindowTitle(self.tr("Project Details")) @@ -66,8 +66,8 @@ class GuiProjectDetails(PagedDialog): self.mainConf.pxInt(pOptions.getInt("GuiProjectDetails", "winHeight", wH)) ) - self.tabMain = GuiProjectDetailsMain(self.theParent, self.theProject) - self.tabContents = GuiProjectDetailsContents(self.theParent, self.theProject) + self.tabMain = GuiProjectDetailsMain(self.mainGui, self.theProject) + self.tabContents = GuiProjectDetailsContents(self.mainGui, self.theProject) self.addTab(self.tabMain, self.tr("Overview")) self.addTab(self.tabContents, self.tr("Contents")) @@ -139,13 +139,13 @@ class GuiProjectDetails(PagedDialog): class GuiProjectDetailsMain(QWidget): - def __init__(self, theParent, theProject): - QWidget.__init__(self, theParent) + def __init__(self, mainGui, theProject): + QWidget.__init__(self, mainGui) self.mainConf = novelwriter.CONFIG - self.theParent = theParent self.theProject = theProject - self.theTheme = theParent.theTheme + self.mainGui = mainGui + self.theTheme = mainGui.theTheme fPx = self.theTheme.fontPixelSize fPt = self.theTheme.fontPointSize @@ -271,13 +271,13 @@ class GuiProjectDetailsContents(QWidget): C_PAGE = 3 C_PROG = 4 - def __init__(self, theParent, theProject): - QWidget.__init__(self, theParent) + def __init__(self, mainGui, theProject): + QWidget.__init__(self, mainGui) self.mainConf = novelwriter.CONFIG - self.theParent = theParent self.theProject = theProject - self.theTheme = theParent.theTheme + self.mainGui = mainGui + self.theTheme = mainGui.theTheme # Internal self._theToC = [] diff --git a/novelwriter/dialogs/projload.py b/novelwriter/dialogs/projload.py index bbae4920..6d296980 100644 --- a/novelwriter/dialogs/projload.py +++ b/novelwriter/dialogs/projload.py @@ -53,15 +53,15 @@ class GuiProjectLoad(QDialog): C_COUNT = 1 C_TIME = 2 - def __init__(self, theParent): - QDialog.__init__(self, theParent) + def __init__(self, mainGui): + QDialog.__init__(self, mainGui) logger.debug("Initialising GuiProjectLoad ...") self.setObjectName("GuiProjectLoad") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainGui = mainGui + self.theTheme = mainGui.theTheme self.openState = self.NONE_STATE self.openPath = None @@ -80,7 +80,7 @@ class GuiProjectLoad(QDialog): self.setModal(True) 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.projectForm = QGridLayout() @@ -225,7 +225,7 @@ class GuiProjectLoad(QDialog): selList = self.listBox.selectedItems() if selList: projName = selList[0].text(self.C_NAME) - msgYes = self.theParent.askQuestion( + msgYes = self.mainGui.askQuestion( self.tr("Remove Entry"), self.tr( "Remove '{0}' from the recent projects list? " @@ -280,7 +280,7 @@ class GuiProjectLoad(QDialog): sortList = sorted(dataList, key=lambda x: x[1], reverse=True) for theTitle, theTime, theWords, projPath in sortList: 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.setData(self.C_NAME, Qt.UserRole, projPath) newItem.setText(self.C_COUNT, formatInt(theWords)) diff --git a/novelwriter/dialogs/projsettings.py b/novelwriter/dialogs/projsettings.py index 8bbdcee3..c7531866 100644 --- a/novelwriter/dialogs/projsettings.py +++ b/novelwriter/dialogs/projsettings.py @@ -43,15 +43,15 @@ logger = logging.getLogger(__name__) class GuiProjectSettings(PagedDialog): - def __init__(self, theParent): - PagedDialog.__init__(self, theParent) + def __init__(self, mainGui): + PagedDialog.__init__(self, mainGui) logger.debug("Initialising GuiProjectSettings ...") self.setObjectName("GuiProjectSettings") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theProject = mainGui.theProject self.theProject.countStatus() self.setWindowTitle(self.tr("Project Settings")) @@ -67,10 +67,10 @@ class GuiProjectSettings(PagedDialog): self.mainConf.pxInt(pOptions.getInt("GuiProjectSettings", "winHeight", wH)) ) - self.tabMain = GuiProjectEditMain(self.theParent, self.theProject) - self.tabStatus = GuiProjectEditStatus(self.theParent, self.theProject, True) - self.tabImport = GuiProjectEditStatus(self.theParent, self.theProject, False) - self.tabReplace = GuiProjectEditReplace(self.theParent, self.theProject) + self.tabMain = GuiProjectEditMain(self.mainGui, self.theProject) + self.tabStatus = GuiProjectEditStatus(self.mainGui, self.theProject, True) + self.tabImport = GuiProjectEditStatus(self.mainGui, self.theProject, False) + self.tabReplace = GuiProjectEditReplace(self.mainGui, self.theProject) self.addTab(self.tabMain, self.tr("Settings")) self.addTab(self.tabStatus, self.tr("Status")) @@ -121,7 +121,7 @@ class GuiProjectSettings(PagedDialog): self.theProject.setImportColours(newList, delList) if self.tabStatus.colChanged or self.tabImport.colChanged: - self.theParent.rebuildTrees() + self.mainGui.rebuildTrees() if self.tabReplace.arChanged: newList = self.tabReplace.getNewList() @@ -166,22 +166,22 @@ class GuiProjectSettings(PagedDialog): class GuiProjectEditMain(QWidget): - def __init__(self, theParent, theProject): - QWidget.__init__(self, theParent) + def __init__(self, mainGui, theProject): + QWidget.__init__(self, mainGui) self.mainConf = novelwriter.CONFIG - self.theParent = theParent + self.mainGui = mainGui self.theProject = theProject # The Form self.mainForm = QConfigLayout() - self.mainForm.setHelpTextStyle(self.theParent.theTheme.helpText) + self.mainForm.setHelpTextStyle(self.mainGui.theTheme.helpText) self.setLayout(self.mainForm) self.mainForm.addGroupLabel(self.tr("Project Settings")) 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.setMaxLength(200) @@ -216,7 +216,7 @@ class GuiProjectEditMain(QWidget): self.spellLang = QComboBox(self) self.spellLang.setMaximumWidth(xW) self.spellLang.addItem(self.tr("Default"), "None") - langAvail = self.theParent.docEditor.spEnchant.listDictionaries() + langAvail = self.mainGui.docEditor.spEnchant.listDictionaries() for spTag, spProv in langAvail: qLocal = QLocale(spTag) spLang = qLocal.nativeLanguageName().title() @@ -256,13 +256,13 @@ class GuiProjectEditStatus(QWidget): COL_ROLE = Qt.UserRole + 1 NUM_ROLE = Qt.UserRole + 2 - def __init__(self, theParent, theProject, isStatus): - QWidget.__init__(self, theParent) + def __init__(self, mainGui, theProject, isStatus): + QWidget.__init__(self, mainGui) self.mainConf = novelwriter.CONFIG - self.theParent = theParent + self.mainGui = mainGui self.theProject = theProject - self.theTheme = theParent.theTheme + self.theTheme = mainGui.theTheme if isStatus: self.theStatus = self.theProject.statusItems @@ -411,7 +411,7 @@ class GuiProjectEditStatus(QWidget): if selItem is not None: iRow = self.listBox.indexOfTopLevelItem(selItem) 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." ), nwAlert.ERROR) else: @@ -527,12 +527,12 @@ class GuiProjectEditReplace(QWidget): COL_KEY = 0 COL_REPL = 1 - def __init__(self, theParent, theProject): - QWidget.__init__(self, theParent) + def __init__(self, mainGui, theProject): + QWidget.__init__(self, mainGui) self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainGui = mainGui + self.theTheme = mainGui.theTheme self.theProject = theProject self.arChanged = False diff --git a/novelwriter/dialogs/quotes.py b/novelwriter/dialogs/quotes.py index e8426adf..299386d8 100644 --- a/novelwriter/dialogs/quotes.py +++ b/novelwriter/dialogs/quotes.py @@ -42,8 +42,8 @@ class GuiQuoteSelect(QDialog): selectedQuote = "" - def __init__(self, theParent=None, currentQuote='"'): - QDialog.__init__(self, parent=theParent) + def __init__(self, parent=None, currentQuote='"'): + QDialog.__init__(self, parent=parent) self.mainConf = novelwriter.CONFIG diff --git a/novelwriter/dialogs/updates.py b/novelwriter/dialogs/updates.py index fccc49c2..a8f3c8a9 100644 --- a/novelwriter/dialogs/updates.py +++ b/novelwriter/dialogs/updates.py @@ -43,14 +43,14 @@ logger = logging.getLogger(__name__) class GuiUpdates(QDialog): - def __init__(self, theParent): - QDialog.__init__(self, theParent) + def __init__(self, mainGui): + QDialog.__init__(self, mainGui) logger.debug("Initialising GuiUpdates ...") self.setObjectName("GuiUpdates") - self.mainConf = novelwriter.CONFIG - self.theParent = theParent + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui self.setWindowTitle(self.tr("Check for Updates")) @@ -61,7 +61,7 @@ class GuiUpdates(QDialog): # Left Box 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.addWidget(self.nwIcon) diff --git a/novelwriter/dialogs/wordlist.py b/novelwriter/dialogs/wordlist.py index 77a4fb5a..172ae846 100644 --- a/novelwriter/dialogs/wordlist.py +++ b/novelwriter/dialogs/wordlist.py @@ -42,16 +42,16 @@ logger = logging.getLogger(__name__) class GuiWordList(QDialog): - def __init__(self, theParent): - QDialog.__init__(self, theParent) + def __init__(self, mainGui): + QDialog.__init__(self, mainGui) logger.debug("Initialising GuiWordList ...") self.setObjectName("GuiWordList") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theTheme = mainGui.theTheme + self.theProject = mainGui.theProject self.setWindowTitle(self.tr("Project Word List")) @@ -121,13 +121,13 @@ class GuiWordList(QDialog): """ newWord = self.newEntry.text().strip() if newWord == "": - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Cannot add a blank word." ), nwAlert.ERROR) return False 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." ).format(newWord), nwAlert.ERROR) return False diff --git a/novelwriter/gui/custom.py b/novelwriter/gui/custom.py index 62dd3c91..e571a5a1 100644 --- a/novelwriter/gui/custom.py +++ b/novelwriter/gui/custom.py @@ -376,8 +376,8 @@ class QSwitch(QAbstractButton): class PagedDialog(QDialog): - def __init__(self, theParent=None): - QDialog.__init__(self, parent=theParent) + def __init__(self, parent=None): + QDialog.__init__(self, parent=parent) self._tabBar = VerticalTabBar(self) self._tabBar.setExpanding(False) @@ -426,8 +426,8 @@ class PagedDialog(QDialog): class VerticalTabBar(QTabBar): - def __init__(self, theParent=None): - QTabBar.__init__(self, parent=theParent) + def __init__(self, parent=None): + QTabBar.__init__(self, parent=parent) self._mW = novelwriter.CONFIG.pxInt(150) return diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index 5ede17f1..e1b1d948 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -72,16 +72,16 @@ class GuiDocEditor(QTextEdit): docCountsChanged = pyqtSignal(str, int, int, int) loadDocumentTagRequest = pyqtSignal(str, Enum) - def __init__(self, theParent): - QTextEdit.__init__(self, theParent) + def __init__(self, mainGui): + QTextEdit.__init__(self, mainGui) logger.debug("Initialising GuiDocEditor ...") # Class Variables self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theTheme = mainGui.theTheme + self.theProject = mainGui.theProject self._nwDocument = None self._nwItem = None @@ -124,7 +124,7 @@ class GuiDocEditor(QTextEdit): # Syntax self.spEnchant = NWSpellEnchant() - self.highLight = GuiDocHighlighter(qDoc, self.theParent, self.spEnchant) + self.highLight = GuiDocHighlighter(qDoc, self.mainGui, self.spEnchant) # Context Menu self.setContextMenuPolicy(Qt.CustomContextMenu) @@ -341,7 +341,7 @@ class GuiDocEditor(QTextEdit): docSize = len(theDoc) 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 size is {0} MB. " "The maximum size allowed is {1} MB." @@ -417,7 +417,7 @@ class GuiDocEditor(QTextEdit): # Update the status bar if self._nwItem is not None: - self.theParent.setStatus( + self.mainGui.setStatus( self.tr("Opened Document: {0}").format(self._nwItem.itemName) ) @@ -442,7 +442,7 @@ class GuiDocEditor(QTextEdit): """ docSize = len(theText) 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 size is {0} MB. " "The maximum size allowed is {1} MB." @@ -488,7 +488,7 @@ class GuiDocEditor(QTextEdit): if not self._nwDocument.writeDocument(docText): saveOk = False if self._nwDocument._currHash != self._nwDocument._prevHash: - msgYes = self.theParent.askQuestion( + msgYes = self.mainGui.askQuestion( self.tr("File Changed on Disk"), self.tr( "This document has been changed outside of novelWriter " @@ -499,7 +499,7 @@ class GuiDocEditor(QTextEdit): saveOk = self._nwDocument.writeDocument(docText, forceWrite=True) if not saveOk: - self.theParent.makeAlert([ + self.mainGui.makeAlert([ self.tr("Could not save document."), self._nwDocument.getError() ], nwAlert.ERROR) @@ -512,17 +512,17 @@ class GuiDocEditor(QTextEdit): newHeader = self.theProject.index.getHandleHeaderLevel(tHandle) if self._updateHeaders(checkLevel=True): - self.theParent.requestNovelTreeRefresh() + self.mainGui.requestNovelTreeRefresh() else: - self.theParent.novelView.updateWordCounts(tHandle) + self.mainGui.novelView.updateWordCounts(tHandle) if oldHeader != newHeader: - self.theParent.treeView.setTreeItemValues(tHandle) - self.theParent.treeMeta.updateViewBox(tHandle) + self.mainGui.treeView.setTreeItemValues(tHandle) + self.mainGui.treeMeta.updateViewBox(tHandle) self.docFooter.updateInfo() # Update the status bar - self.theParent.setStatus( + self.mainGui.setStatus( self.tr("Saved Document: {0}").format(self._nwItem.itemName) ) @@ -544,8 +544,8 @@ class GuiDocEditor(QTextEdit): sH = hBar.height() if hBar.isVisible() else 0 tM = cM - if self.mainConf.textWidth > 0 or self.theParent.isFocusMode: - tW = self.mainConf.getTextWidth(self.theParent.isFocusMode) + if self.mainConf.textWidth > 0 or self.mainGui.isFocusMode: + tW = self.mainConf.getTextWidth(self.mainGui.isFocusMode) tM = max((wW - sW - tW)//2, cM) tB = self.frameWidth() @@ -704,7 +704,7 @@ class GuiDocEditor(QTextEdit): if not self.mainConf.hasEnchant: if theMode: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Spell checking requires the package PyEnchant. " "It does not appear to be installed." ), nwAlert.INFO) @@ -714,7 +714,7 @@ class GuiDocEditor(QTextEdit): theMode = False self._spellCheck = theMode - self.theParent.mainMenu.setSpellCheck(theMode) + self.mainGui.mainMenu.setSpellCheck(theMode) self.theProject.setSpellCheck(theMode) self.highLight.setSpellCheck(theMode) if not self._bigDoc: @@ -742,7 +742,7 @@ class GuiDocEditor(QTextEdit): qApp.restoreOverrideCursor() afTime = time() 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 @@ -1085,7 +1085,7 @@ class GuiDocEditor(QTextEdit): self._lastFind = None 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 maximum size of a single novelWriter document is {0} MB." ).format( @@ -1245,7 +1245,7 @@ class GuiDocEditor(QTextEdit): if time() - self._lastEdit < 5 * self.wcInterval: logger.verbose("Running word counter") - self.theParent.threadPool.start(self.wCounterDoc) + self.mainGui.threadPool.start(self.wCounterDoc) return @@ -1302,7 +1302,7 @@ class GuiDocEditor(QTextEdit): logger.verbose("Selection word counter is busy") return - self.theParent.threadPool.start(self.wCounterSel) + self.mainGui.threadPool.start(self.wCounterSel) return @@ -1381,7 +1381,7 @@ class GuiDocEditor(QTextEdit): self.docSearch.setResultCount(0, 0) self._lastFind = None if self.docSearch.doNextFile and not goBack: - self.theParent.openNextDocument( + self.mainGui.openNextDocument( self._docHandle, wrapAround=self.docSearch.doLoop ) self.beginSearch() @@ -1401,7 +1401,7 @@ class GuiDocEditor(QTextEdit): if resIdx > maxIdx: if self.docSearch.doNextFile and not goBack: - self.theParent.openNextDocument( + self.mainGui.openNextDocument( self._docHandle, wrapAround=self.docSearch.doLoop ) self.beginSearch() @@ -1645,7 +1645,7 @@ class GuiDocEditor(QTextEdit): """ theCursor = self.textCursor() if not theCursor.hasSelection(): - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Please select some text before calling replace quotes." ), nwAlert.ERROR) return False @@ -2187,7 +2187,7 @@ class GuiDocEditSearch(QFrame): self.mainConf = novelwriter.CONFIG self.docEditor = docEditor - self.theParent = docEditor.theParent + self.mainGui = docEditor.mainGui self.theProject = docEditor.theProject self.theTheme = docEditor.theTheme @@ -2575,7 +2575,7 @@ class GuiDocEditHeader(QWidget): self.mainConf = novelwriter.CONFIG self.docEditor = docEditor - self.theParent = docEditor.theParent + self.mainGui = docEditor.mainGui self.theProject = docEditor.theProject self.theTheme = docEditor.theTheme @@ -2733,7 +2733,7 @@ class GuiDocEditHeader(QWidget): This function is called by the GuiMain class via the toggleFocusMode function and should not be activated directly. """ - if self.theParent.isFocusMode: + if self.mainGui.isFocusMode: self.minmaxButton.setIcon(self.theTheme.getIcon("minimise")) else: self.minmaxButton.setIcon(self.theTheme.getIcon("maximise")) @@ -2746,7 +2746,7 @@ class GuiDocEditHeader(QWidget): def _editDocument(self): """Open the edit item dialog from the main GUI. """ - self.theParent.editItem(self._docHandle) + self.mainGui.editItem(self._docHandle) return def _searchDocument(self): @@ -2758,7 +2758,7 @@ class GuiDocEditHeader(QWidget): def _closeDocument(self): """Trigger the close editor on the main window. """ - self.theParent.closeDocEditor() + self.mainGui.closeDocEditor() self.editButton.setVisible(False) self.searchButton.setVisible(False) self.closeButton.setVisible(False) @@ -2768,7 +2768,7 @@ class GuiDocEditHeader(QWidget): def _minmaxDocument(self): """Switch on or off Focus Mode. """ - self.theParent.toggleFocusMode() + self.mainGui.toggleFocusMode() return ## @@ -2779,7 +2779,7 @@ class GuiDocEditHeader(QWidget): """Capture a click on the title and ensure that the item is selected in the project tree. """ - self.theParent.treeView.setSelectedHandle(self._docHandle, doScroll=True) + self.mainGui.treeView.setSelectedHandle(self._docHandle, doScroll=True) return # END Class GuiDocEditHeader @@ -2799,7 +2799,7 @@ class GuiDocEditFooter(QWidget): self.mainConf = novelwriter.CONFIG self.docEditor = docEditor - self.theParent = docEditor.theParent + self.mainGui = docEditor.mainGui self.theProject = docEditor.theProject self.theTheme = docEditor.theTheme diff --git a/novelwriter/gui/dochighlight.py b/novelwriter/gui/dochighlight.py index bd2d78eb..d811332c 100644 --- a/novelwriter/gui/dochighlight.py +++ b/novelwriter/gui/dochighlight.py @@ -46,16 +46,16 @@ class GuiDocHighlighter(QSyntaxHighlighter): BLOCK_META = 2 BLOCK_TITLE = 4 - def __init__(self, theDoc, theParent, spEnchant): + def __init__(self, theDoc, mainGui, spEnchant): QSyntaxHighlighter.__init__(self, theDoc) logger.debug("Initialising GuiDocHighlighter ...") self.mainConf = novelwriter.CONFIG self.theDoc = theDoc self.spEnchant = spEnchant - self.theParent = theParent - self.theTheme = theParent.theTheme - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theTheme = mainGui.theTheme + self.theProject = mainGui.theProject self.theHandle = None self.spellCheck = False self.spellRx = None @@ -288,7 +288,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): if theText.startswith("@"): # Keywords and commands self.setCurrentBlockState(self.BLOCK_META) pIndex = self.theProject.index - tItem = self.theParent.theProject.tree[self.theHandle] + tItem = self.mainGui.theProject.tree[self.theHandle] isValid, theBits, thePos = pIndex.scanThis(theText) isGood = pIndex.checkThese(theBits, tItem) if isValid: diff --git a/novelwriter/gui/docviewer.py b/novelwriter/gui/docviewer.py index 89ae8ea2..5a9c61cd 100644 --- a/novelwriter/gui/docviewer.py +++ b/novelwriter/gui/docviewer.py @@ -53,16 +53,16 @@ class GuiDocViewer(QTextBrowser): loadDocumentTagRequest = pyqtSignal(str, Enum) - def __init__(self, theParent): - QTextBrowser.__init__(self, theParent) + def __init__(self, mainGui): + QTextBrowser.__init__(self, mainGui) logger.debug("Initialising GuiDocViewer ...") # Class Variables self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theTheme = mainGui.theTheme + self.theProject = mainGui.theProject # Internal Variables self._docHandle = None @@ -221,7 +221,7 @@ class GuiDocViewer(QTextBrowser): self.updateDocMargins() # 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 # the document dirty again to make sure it's re-rendered properly. @@ -714,7 +714,7 @@ class GuiDocViewHeader(QWidget): self.mainConf = novelwriter.CONFIG self.docViewer = docViewer - self.theParent = docViewer.theParent + self.mainGui = docViewer.mainGui self.theProject = docViewer.theProject self.theTheme = docViewer.theTheme @@ -882,14 +882,14 @@ class GuiDocViewHeader(QWidget): def _closeDocument(self): """Trigger the close editor/viewer on the main window. """ - self.theParent.closeDocViewer() + self.mainGui.closeDocViewer() return def _refreshDocument(self): """Reload the content of the document. """ - if self.docViewer.docHandle() == self.theParent.docEditor.docHandle(): - self.theParent.saveDocument() + if self.docViewer.docHandle() == self.mainGui.docEditor.docHandle(): + self.mainGui.saveDocument() self.docViewer.reloadText() return @@ -901,7 +901,7 @@ class GuiDocViewHeader(QWidget): """Capture a click on the title and ensure that the item is selected in the project tree. """ - self.theParent.treeView.setSelectedHandle(self._docHandle, doScroll=True) + self.mainGui.treeView.setSelectedHandle(self._docHandle, doScroll=True) return # END Class GuiDocViewHeader @@ -921,9 +921,9 @@ class GuiDocViewFooter(QWidget): self.mainConf = novelwriter.CONFIG self.docViewer = docViewer - self.theParent = docViewer.theParent + self.mainGui = docViewer.mainGui self.theTheme = docViewer.theTheme - self.viewMeta = docViewer.theParent.viewMeta + self.viewMeta = docViewer.mainGui.viewMeta # Internal Variables self._docHandle = None @@ -1140,14 +1140,14 @@ class GuiDocViewFooter(QWidget): class GuiDocViewDetails(QScrollArea): - def __init__(self, theParent): - QScrollArea.__init__(self, theParent) + def __init__(self, mainGui): + QScrollArea.__init__(self, mainGui) logger.debug("Initialising GuiDocViewDetails ...") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theProject = theParent.theProject - self.theTheme = theParent.theTheme + self.mainGui = mainGui + self.theProject = mainGui.theProject + self.theTheme = mainGui.theTheme self.refList = QLabel("") self.refList.setWordWrap(True) @@ -1181,7 +1181,7 @@ class GuiDocViewDetails(QScrollArea): """Update the current list of document references from the project index. """ - if self.theParent.docViewer.stickyRef: + if self.mainGui.docViewer.stickyRef: return theRefs = self.theProject.index.getBackReferenceList(tHandle) @@ -1209,7 +1209,7 @@ class GuiDocViewDetails(QScrollArea): if len(theLink) == 21: tHandle = theLink[:13] tAnchor = theLink[13:] - self.theParent.viewDocument(tHandle, tAnchor) + self.mainGui.viewDocument(tHandle, tAnchor) return # END Class GuiDocViewDetails diff --git a/novelwriter/gui/itemdetails.py b/novelwriter/gui/itemdetails.py index cf9e8017..97d4ba0e 100644 --- a/novelwriter/gui/itemdetails.py +++ b/novelwriter/gui/itemdetails.py @@ -38,14 +38,14 @@ logger = logging.getLogger(__name__) class GuiItemDetails(QWidget): - def __init__(self, theParent): - QWidget.__init__(self, theParent) + def __init__(self, mainGui): + QWidget.__init__(self, mainGui) logger.debug("Initialising GuiItemDetails ...") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theProject = theParent.theProject - self.theTheme = theParent.theTheme + self.mainGui = mainGui + self.theProject = mainGui.theProject + self.theTheme = mainGui.theTheme # Internal Variables self._itemHandle = None diff --git a/novelwriter/gui/mainmenu.py b/novelwriter/gui/mainmenu.py index 33b43cfb..f482544f 100644 --- a/novelwriter/gui/mainmenu.py +++ b/novelwriter/gui/mainmenu.py @@ -41,13 +41,13 @@ logger = logging.getLogger(__name__) class GuiMainMenu(QMenuBar): - def __init__(self, theParent): - QMenuBar.__init__(self, theParent) + def __init__(self, mainGui): + QMenuBar.__init__(self, mainGui) logger.debug("Initialising GuiMainMenu ...") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theProject = mainGui.theProject # Build Menu self._buildProjectMenu() @@ -61,9 +61,9 @@ class GuiMainMenu(QMenuBar): self._buildHelpMenu() # Function Pointers - self._docAction = self.theParent.passDocumentAction - self._docInsert = self.theParent.docEditor.insertText - self._insertKeyWord = self.theParent.docEditor.insertKeyWord + self._docAction = self.mainGui.passDocumentAction + self._docInsert = self.mainGui.docEditor.insertText + self._insertKeyWord = self.mainGui.docEditor.insertKeyWord logger.debug("GuiMainMenu initialisation complete") @@ -94,7 +94,7 @@ class GuiMainMenu(QMenuBar): flag is handled by the document editor class, so we make no decision, just pass a None to the function and let it decide. """ - self.theParent.docEditor.toggleSpellCheck(None) + self.mainGui.docEditor.toggleSpellCheck(None) return True def _openWebsite(self, theUrl): @@ -123,25 +123,25 @@ class GuiMainMenu(QMenuBar): # Project > New Project 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) # Project > Open Project self.aOpenProject = QAction(self.tr("Open Project"), self) 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) # Project > Save Project self.aSaveProject = QAction(self.tr("Save Project"), self) 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) # Project > Close Project self.aCloseProject = QAction(self.tr("Close Project"), self) 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) # Project > Separator @@ -150,13 +150,13 @@ class GuiMainMenu(QMenuBar): # Project > Project Settings self.aProjectSettings = QAction(self.tr("Project Settings"), self) 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) # Project > Project Details self.aProjectDetails = QAction(self.tr("Project Details"), self) 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) # Project > Separator @@ -165,18 +165,18 @@ class GuiMainMenu(QMenuBar): # Project > Edit self.aEditItem = QAction(self.tr("Edit Item"), self) 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) # Project > Delete self.aDeleteItem = QAction(self.tr("Delete Item"), self) 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) # Project > Empty Trash 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) # Project > Separator @@ -186,7 +186,7 @@ class GuiMainMenu(QMenuBar): self.aExitNW = QAction(self.tr("Exit"), self) self.aExitNW.setShortcut("Ctrl+Q") 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) return @@ -200,19 +200,19 @@ class GuiMainMenu(QMenuBar): # Document > Open self.aOpenDoc = QAction(self.tr("Open Document"), self) 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) # Document > Save self.aSaveDoc = QAction(self.tr("Save Document"), self) 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) # Document > Close self.aCloseDoc = QAction(self.tr("Close Document"), self) 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) # Document > Separator @@ -221,13 +221,13 @@ class GuiMainMenu(QMenuBar): # Document > Preview self.aViewDoc = QAction(self.tr("View Document"), self) 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) # Document > Close Preview self.aCloseView = QAction(self.tr("Close Document View"), self) 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) # Document > Separator @@ -235,23 +235,23 @@ class GuiMainMenu(QMenuBar): # Document > Show File Details 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) # Document > Import From File self.aImportFile = QAction(self.tr("Import Text from File"), self) 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) # Document > Merge Documents 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) # Document > Split Document 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) return @@ -324,7 +324,7 @@ class GuiMainMenu(QMenuBar): self.aFocusTree.setShortcut("Ctrl+Alt+1") else: 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) # View > Document Pane 1 @@ -333,7 +333,7 @@ class GuiMainMenu(QMenuBar): self.aFocusEditor.setShortcut("Ctrl+Alt+2") else: 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) # View > Document Pane 2 @@ -342,7 +342,7 @@ class GuiMainMenu(QMenuBar): self.aFocusView.setShortcut("Ctrl+Alt+3") else: 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) # View > Outline @@ -351,7 +351,7 @@ class GuiMainMenu(QMenuBar): self.aFocusOutline.setShortcut("Ctrl+Alt+4") else: 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) # View > Separator @@ -360,13 +360,13 @@ class GuiMainMenu(QMenuBar): # View > Go Backward self.aViewPrev = QAction(self.tr("Navigate Backward"), self) 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) # View > Go Forward self.aViewNext = QAction(self.tr("Navigate Forward"), self) 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) # View > Separator @@ -376,14 +376,14 @@ class GuiMainMenu(QMenuBar): self.aFocusMode = QAction(self.tr("Focus Mode"), self) self.aFocusMode.setShortcut("F8") self.aFocusMode.setCheckable(True) - self.aFocusMode.setChecked(self.theParent.isFocusMode) - self.aFocusMode.triggered.connect(lambda: self.theParent.toggleFocusMode()) + self.aFocusMode.setChecked(self.mainGui.isFocusMode) + self.aFocusMode.triggered.connect(lambda: self.mainGui.toggleFocusMode()) self.viewMenu.addAction(self.aFocusMode) # View > Toggle Full Screen self.aFullScreen = QAction(self.tr("Full Screen Mode"), self) 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) return @@ -588,7 +588,7 @@ class GuiMainMenu(QMenuBar): # Insert > Placeholder Text 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) return @@ -752,7 +752,7 @@ class GuiMainMenu(QMenuBar): # Search > Find self.aFind = QAction(self.tr("Find"), self) 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) # Search > Replace @@ -761,7 +761,7 @@ class GuiMainMenu(QMenuBar): self.aReplace.setShortcut("Ctrl+=") else: 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) # Search > Find Next @@ -770,7 +770,7 @@ class GuiMainMenu(QMenuBar): self.aFindNext.setShortcuts(["Ctrl+G", "F3"]) else: 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) # Search > Find Prev @@ -779,13 +779,13 @@ class GuiMainMenu(QMenuBar): self.aFindPrev.setShortcuts(["Ctrl+Shift+G", "Shift+F3"]) else: 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) # Search > Replace Next self.aReplaceNext = QAction(self.tr("Replace Next"), self) 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) return @@ -807,12 +807,12 @@ class GuiMainMenu(QMenuBar): # Tools > Re-Run Spell Check self.aReRunSpell = QAction(self.tr("Re-Run Spell Check"), self) 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) # Tools > Project Word List 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) # Tools > Separator @@ -821,7 +821,7 @@ class GuiMainMenu(QMenuBar): # Tools > Rebuild Indices self.aRebuildIndex = QAction(self.tr("Rebuild Index"), self) 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) # Tools > Separator @@ -835,20 +835,20 @@ class GuiMainMenu(QMenuBar): # Tools > Export Project self.aBuildProject = QAction(self.tr("Build Novel Project"), self) 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) # Tools > Writing Stats self.aWritingStats = QAction(self.tr("Writing Statistics"), self) 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) # Tools > Settings self.aPreferences = QAction(self.tr("Preferences"), self) self.aPreferences.setShortcut("Ctrl+,") 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) return @@ -862,13 +862,13 @@ class GuiMainMenu(QMenuBar): # Help > About self.aAboutNW = QAction(self.tr("About novelWriter"), self) 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) # Help > About Qt5 self.aAboutQt = QAction(self.tr("About Qt5"), self) 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) # Help > Separator @@ -915,7 +915,7 @@ class GuiMainMenu(QMenuBar): # Document > Check for Updates 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) return diff --git a/novelwriter/gui/noveltree.py b/novelwriter/gui/noveltree.py index 9ac2ea2b..af79fad5 100644 --- a/novelwriter/gui/noveltree.py +++ b/novelwriter/gui/noveltree.py @@ -45,15 +45,15 @@ class GuiNovelTree(QTreeWidget): C_WORDS = 1 C_POV = 2 - def __init__(self, theParent): - QTreeWidget.__init__(self, theParent) + def __init__(self, mainGui): + QTreeWidget.__init__(self, mainGui) logger.debug("Initialising GuiNovelTree ...") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theTheme = mainGui.theTheme + self.theProject = mainGui.theProject # Internal Variables self._treeMap = {} @@ -135,7 +135,7 @@ class GuiNovelTree(QTreeWidget): """Called whenever the Novel tab is activated. """ 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) if not (treeChanged or indexChanged or overRide): logger.verbose("No changes have been made to the novel index") @@ -209,7 +209,7 @@ class GuiNovelTree(QTreeWidget): if tHandle is None: return - self.theParent.viewDocument(tHandle) + self.mainGui.viewDocument(tHandle) return @@ -223,7 +223,7 @@ class GuiNovelTree(QTreeWidget): document editor. """ tHandle, tLine = self.getSelectedHandle() - self.theParent.openDocument(tHandle, tLine=tLine-1, doScroll=True) + self.mainGui.openDocument(tHandle, tLine=tLine-1, doScroll=True) return def _itemSelected(self): @@ -233,7 +233,7 @@ class GuiNovelTree(QTreeWidget): selItems = self.selectedItems() if selItems: tHandle = selItems[0].data(self.C_TITLE, Qt.UserRole)[0] - self.theParent.treeMeta.updateViewBox(tHandle) + self.mainGui.treeMeta.updateViewBox(tHandle) return diff --git a/novelwriter/gui/outline.py b/novelwriter/gui/outline.py index 65bffdbd..d2b2eb04 100644 --- a/novelwriter/gui/outline.py +++ b/novelwriter/gui/outline.py @@ -56,11 +56,11 @@ class GuiOutline(QWidget): loadDocumentTagRequest = pyqtSignal(str, Enum) - def __init__(self, theParent): - QWidget.__init__(self, theParent) + def __init__(self, mainGui): + QWidget.__init__(self, mainGui) - self.mainConf = novelwriter.CONFIG - self.theParent = theParent + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui # Build GUI self.outlineBar = GuiOutlineToolBar(self) @@ -177,9 +177,9 @@ class GuiOutlineToolBar(QToolBar): logger.debug("Initialising GuiOutlineToolBar ...") self.mainConf = novelwriter.CONFIG - self.theParent = theOutline.theParent - self.theProject = theOutline.theParent.theProject - self.theTheme = theOutline.theParent.theTheme + self.mainGui = theOutline.mainGui + self.theProject = theOutline.mainGui.theProject + self.theTheme = theOutline.mainGui.theTheme iPx = self.mainConf.pxInt(22) mPx = self.mainConf.pxInt(12) @@ -322,9 +322,9 @@ class GuiOutlineView(QTreeWidget): logger.debug("Initialising GuiOutlineView ...") self.mainConf = novelwriter.CONFIG - self.theParent = theOutline.theParent - self.theProject = theOutline.theParent.theProject - self.theTheme = theOutline.theParent.theTheme + self.mainGui = theOutline.mainGui + self.theProject = theOutline.mainGui.theProject + self.theTheme = theOutline.mainGui.theTheme self.setFrameStyle(QFrame.NoFrame) self.setSelectionBehavior(QAbstractItemView.SelectRows) @@ -464,7 +464,7 @@ class GuiOutlineView(QTreeWidget): document editor. """ tHandle, tLine = self.getSelectedHandle() - self.theParent.openDocument(tHandle, tLine=tLine - 1, doScroll=True) + self.mainGui.openDocument(tHandle, tLine=tLine - 1, doScroll=True) return @pyqtSlot() @@ -782,9 +782,9 @@ class GuiOutlineDetails(QScrollArea): self.mainConf = novelwriter.CONFIG self.theOutline = theOutline - self.theParent = theOutline.theParent - self.theProject = theOutline.theParent.theProject - self.theTheme = theOutline.theParent.theTheme + self.mainGui = theOutline.mainGui + self.theProject = theOutline.mainGui.theProject + self.theTheme = theOutline.mainGui.theTheme # Sizes minTitle = 30*self.theTheme.textNWidth diff --git a/novelwriter/gui/projtree.py b/novelwriter/gui/projtree.py index 372a2d84..f2a7b2b3 100644 --- a/novelwriter/gui/projtree.py +++ b/novelwriter/gui/projtree.py @@ -63,10 +63,10 @@ class GuiProjectView(QWidget): selectedItemChanged = pyqtSignal(str) openDocumentRequest = pyqtSignal(str, Enum) - def __init__(self, theParent): - QWidget.__init__(self, theParent) + def __init__(self, mainGui): + QWidget.__init__(self, mainGui) - self.theParent = theParent + self.mainGui = mainGui # Build GUI self.projTree = GuiProjectTree(self) @@ -167,9 +167,9 @@ class GuiProjectToolBar(QWidget): self.mainConf = novelwriter.CONFIG self.projView = projView self.projTree = projView.projTree - self.theParent = projView.theParent - self.theProject = projView.theParent.theProject - self.theTheme = projView.theParent.theTheme + self.mainGui = projView.mainGui + self.theProject = projView.mainGui.theProject + self.theTheme = projView.mainGui.theTheme iPx = self.theTheme.baseIconSize mPx = self.mainConf.pxInt(4) @@ -323,9 +323,9 @@ class GuiProjectTree(QTreeWidget): self.mainConf = novelwriter.CONFIG self.projView = projView - self.theParent = projView.theParent - self.theTheme = projView.theParent.theTheme - self.theProject = projView.theParent.theProject + self.mainGui = projView.mainGui + self.theTheme = projView.mainGui.theTheme + self.theProject = projView.mainGui.theProject # Internal Variables self._treeMap = {} @@ -420,7 +420,7 @@ class GuiProjectTree(QTreeWidget): 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. """ - if not self.theParent.hasProject: + if not self.mainGui.hasProject: logger.error("No project open") return False @@ -435,7 +435,7 @@ class GuiProjectTree(QTreeWidget): sHandle = self.getSelectedHandle() 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!" ), nwAlert.ERROR) return False @@ -452,7 +452,7 @@ class GuiProjectTree(QTreeWidget): return False 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." ), nwAlert.ERROR) return False @@ -611,7 +611,7 @@ class GuiProjectTree(QTreeWidget): function only asks for confirmation once, and calls the regular deleteItem function for each document in the Trash folder. """ - if not self.theParent.hasProject: + if not self.mainGui.hasProject: logger.error("No project open") return False @@ -619,7 +619,7 @@ class GuiProjectTree(QTreeWidget): logger.debug("Emptying Trash folder") if trashHandle is None: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "There is currently no Trash folder in this project." ), nwAlert.INFO) return False @@ -630,12 +630,12 @@ class GuiProjectTree(QTreeWidget): nTrash = len(theTrash) if nTrash == 0: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "The Trash folder is already empty." ), nwAlert.INFO) return False - msgYes = self.theParent.askQuestion( + msgYes = self.mainGui.askQuestion( self.tr("Empty Trash"), 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 only, and the deletion is always permanent. """ - if not self.theParent.hasProject: + if not self.mainGui.hasProject: logger.error("No project open") return False @@ -693,7 +693,7 @@ class GuiProjectTree(QTreeWidget): self._deleteTreeItem(tHandle) self._alertTreeChange(tHandle=tHandle, flush=True) else: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Cannot delete root folder. It is not empty. " "Recursive deletion is not supported. " "Please delete the content first." @@ -723,7 +723,7 @@ class GuiProjectTree(QTreeWidget): # user if they want to permanently delete the file. doPermanent = False if not alreadyAsked: - msgYes = self.theParent.askQuestion( + msgYes = self.mainGui.askQuestion( self.tr("Delete"), self.tr("Permanently delete '{0}'?").format(nwItemS.itemName) ) @@ -739,8 +739,8 @@ class GuiProjectTree(QTreeWidget): tIndex = trItemP.indexOfChild(trItemS) trItemC = trItemP.takeChild(tIndex) for dHandle in reversed(self.getTreeFromHandle(tHandle)): - if self.theParent.docEditor.docHandle() == dHandle: - self.theParent.closeDocument() + if self.mainGui.docEditor.docHandle() == dHandle: + self.mainGui.closeDocument() self._deleteTreeItem(dHandle) self._alertTreeChange(tHandle=tHandle, flush=autoFlush) @@ -749,7 +749,7 @@ class GuiProjectTree(QTreeWidget): else: # The item is not already in the trash folder, so we # move it there. - msgYes = self.theParent.askQuestion( + msgYes = self.mainGui.askQuestion( self.tr("Delete"), self.tr("Move '{0}' to Trash?").format(nwItemS.itemName), ) @@ -1199,7 +1199,7 @@ class GuiProjectTree(QTreeWidget): if self.theProject.tree.checkType(tHandle, nwItemType.FILE): delDoc = NWDoc(self.theProject, tHandle) if not delDoc.deleteDocument(): - self.theParent.makeAlert([ + self.mainGui.makeAlert([ self.tr("Could not delete document file."), delDoc.getError() ], nwAlert.ERROR) return False @@ -1295,7 +1295,7 @@ class GuiProjectTree(QTreeWidget): newItem.setFlags(newItem.flags() ^ Qt.ItemIsDragEnabled) self.addTopLevelItem(newItem) else: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "There is nowhere to add item with name '{0}'." ).format(nwItem.itemName), nwAlert.ERROR) del self._treeMap[tHandle] diff --git a/novelwriter/gui/statusbar.py b/novelwriter/gui/statusbar.py index e3891e7e..4863f9bc 100644 --- a/novelwriter/gui/statusbar.py +++ b/novelwriter/gui/statusbar.py @@ -41,14 +41,14 @@ logger = logging.getLogger(__name__) class GuiMainStatus(QStatusBar): - def __init__(self, theParent): - QStatusBar.__init__(self, theParent) + def __init__(self, mainGui): + QStatusBar.__init__(self, mainGui) logger.debug("Initialising GuiMainStatus ...") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainGui = mainGui + self.theTheme = mainGui.theTheme self.refTime = None self.userIdle = False diff --git a/novelwriter/gui/viewsbar.py b/novelwriter/gui/viewsbar.py index e5b627b2..d62b5543 100644 --- a/novelwriter/gui/viewsbar.py +++ b/novelwriter/gui/viewsbar.py @@ -40,14 +40,14 @@ class GuiViewsBar(QToolBar): viewChangeRequested = pyqtSignal(nwView) - def __init__(self, theParent): - QToolBar.__init__(self, theParent) + def __init__(self, mainGui): + QToolBar.__init__(self, mainGui) logger.debug("Initialising GuiViewsBar ...") - self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui + self.theTheme = mainGui.theTheme # Style iPx = self.mainConf.pxInt(22) @@ -89,29 +89,29 @@ class GuiViewsBar(QToolBar): self.aBuild.setFont(lblFont) self.aBuild.setToolTip(self.tr("Build novel project")) 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.setFont(lblFont) self.aDetails.setToolTip(self.tr("Show project 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.setFont(lblFont) self.aStats.setToolTip(self.tr("Show project statistics")) 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 self.mSettings = QMenu() 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.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.tbSettings = QToolButton(self) diff --git a/novelwriter/tools/build.py b/novelwriter/tools/build.py index b27a98a4..4ce9dea1 100644 --- a/novelwriter/tools/build.py +++ b/novelwriter/tools/build.py @@ -65,16 +65,16 @@ class GuiBuildNovel(QDialog): FMT_JSON_H = 8 # HTML5 wrapped in JSON FMT_JSON_M = 9 # nW Markdown wrapped in JSON - def __init__(self, theParent): - QDialog.__init__(self, theParent) + def __init__(self, mainGui): + QDialog.__init__(self, mainGui) logger.debug("Initialising GuiBuildNovel ...") self.setObjectName("GuiBuildNovel") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theTheme = mainGui.theTheme + self.theProject = mainGui.theProject self.htmlText = [] # List of html documents self.htmlStyle = [] # List of html styles @@ -711,7 +711,7 @@ class GuiBuildNovel(QDialog): bldObj.initDocument() # 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.setValue(0) @@ -760,7 +760,7 @@ class GuiBuildNovel(QDialog): logger.debug("Built project in %.3f ms", 1000*(tEnd - tStart)) if bldObj.errData: - self.theParent.makeAlert([ + self.mainGui.makeAlert([ self.tr("There were problems when building the project:") ] + bldObj.errData, nwAlert.ERROR) @@ -1003,11 +1003,11 @@ class GuiBuildNovel(QDialog): # ============== if wSuccess: - self.theParent.makeAlert([ + self.mainGui.makeAlert([ self.tr("{0} file successfully written to:").format(textFmt), savePath ], nwAlert.INFO) else: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Failed to write {0} file. {1}" ).format(textFmt, errMsg), nwAlert.ERROR) @@ -1193,18 +1193,18 @@ class GuiBuildNovel(QDialog): class GuiBuildNovelDocView(QTextBrowser): - def __init__(self, theParent, theProject): - QTextBrowser.__init__(self, theParent) + def __init__(self, mainGui, theProject): + QTextBrowser.__init__(self, mainGui) logger.debug("Initialising GuiBuildNovelDocView ...") self.mainConf = novelwriter.CONFIG self.theProject = theProject - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainGui = mainGui + self.theTheme = mainGui.theTheme self.buildTime = 0 - self.setMinimumWidth(40*self.theParent.theTheme.textNWidth) + self.setMinimumWidth(40*self.mainGui.theTheme.textNWidth) self.setOpenExternalLinks(False) self.document().setDocumentMargin(self.mainConf.getTextMargin()) diff --git a/novelwriter/tools/lipsum.py b/novelwriter/tools/lipsum.py index 4ce21643..d741058c 100644 --- a/novelwriter/tools/lipsum.py +++ b/novelwriter/tools/lipsum.py @@ -42,15 +42,15 @@ logger = logging.getLogger(__name__) class GuiLipsum(QDialog): - def __init__(self, theParent): - QDialog.__init__(self, theParent) + def __init__(self, mainGui): + QDialog.__init__(self, mainGui) logger.debug("Initialising GuiLipsum ...") self.setObjectName("GuiLipsum") - self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui + self.theTheme = mainGui.theTheme self.setWindowTitle(self.tr("Insert Placeholder Text")) @@ -61,7 +61,7 @@ class GuiLipsum(QDialog): nPx = self.mainConf.pxInt(64) vSp = self.mainConf.pxInt(4) 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.setSpacing(vSp) @@ -129,7 +129,7 @@ class GuiLipsum(QDialog): pCount = self.paraCount.value() inText = "\n\n".join(lipsumText[0:pCount]) + "\n\n" - self.theParent.docEditor.insertText(inText) + self.mainGui.docEditor.insertText(inText) return diff --git a/novelwriter/tools/projwizard.py b/novelwriter/tools/projwizard.py index 765445b9..3dac9ed8 100644 --- a/novelwriter/tools/projwizard.py +++ b/novelwriter/tools/projwizard.py @@ -48,15 +48,15 @@ PAGE_FINAL = 4 class GuiProjectWizard(QWizard): - def __init__(self, theParent): - QWizard.__init__(self, theParent) + def __init__(self, mainGui): + QWizard.__init__(self, mainGui) logger.debug("Initialising GuiProjectWizard ...") self.setObjectName("GuiProjectWizard") - self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme + self.mainConf = novelwriter.CONFIG + self.mainGui = mainGui + self.theTheme = mainGui.theTheme self.sideImage = self.theTheme.loadDecoration( "wiz-back", None, self.mainConf.pxInt(370) diff --git a/novelwriter/tools/writingstats.py b/novelwriter/tools/writingstats.py index aff7bc3d..d4527612 100644 --- a/novelwriter/tools/writingstats.py +++ b/novelwriter/tools/writingstats.py @@ -57,16 +57,16 @@ class GuiWritingStats(QDialog): FMT_JSON = 0 FMT_CSV = 1 - def __init__(self, theParent): - QDialog.__init__(self, theParent) + def __init__(self, mainGui): + QDialog.__init__(self, mainGui) logger.debug("Initialising GuiWritingStats ...") self.setObjectName("GuiWritingStats") self.mainConf = novelwriter.CONFIG - self.theParent = theParent - self.theTheme = theParent.theTheme - self.theProject = theParent.theProject + self.mainGui = mainGui + self.theTheme = mainGui.theTheme + self.theProject = mainGui.theProject self.logData = [] self.filterData = [] @@ -411,11 +411,11 @@ class GuiWritingStats(QDialog): # Report to user if wSuccess: - self.theParent.makeAlert([ + self.mainGui.makeAlert([ self.tr("{0} file successfully written to:").format(textFmt), savePath ], nwAlert.INFO) else: - self.theParent.makeAlert([ + self.mainGui.makeAlert([ self.tr("Failed to write {0} file.").format(textFmt), errMsg ], nwAlert.ERROR) @@ -478,7 +478,7 @@ class GuiWritingStats(QDialog): self.logData.append((dStart, sDiff, wcNovel, wcNotes, sIdle)) except Exception as exc: - self.theParent.makeAlert(self.tr( + self.mainGui.makeAlert(self.tr( "Failed to read session log file." ), nwAlert.ERROR, exception=exc) return False