diff --git a/novelwriter/core/document.py b/novelwriter/core/document.py index 5420d44e..672fbee5 100644 --- a/novelwriter/core/document.py +++ b/novelwriter/core/document.py @@ -33,7 +33,7 @@ from novelwriter.common import isHandle, sha256sum logger = logging.getLogger(__name__) -class NWDoc(): +class NWDoc: def __init__(self, theProject, theHandle): diff --git a/novelwriter/core/item.py b/novelwriter/core/item.py index 3f463a1b..a8faea8b 100644 --- a/novelwriter/core/item.py +++ b/novelwriter/core/item.py @@ -36,7 +36,7 @@ from novelwriter.constants import nwLabels, trConst logger = logging.getLogger(__name__) -class NWItem(): +class NWItem: def __init__(self, theProject): diff --git a/novelwriter/core/options.py b/novelwriter/core/options.py index d64970ae..d36e677b 100644 --- a/novelwriter/core/options.py +++ b/novelwriter/core/options.py @@ -63,7 +63,7 @@ VALID_MAP = { } -class OptionState(): +class OptionState: def __init__(self, theProject): self.theProject = theProject diff --git a/novelwriter/core/project.py b/novelwriter/core/project.py index 475300fd..dcfa66d7 100644 --- a/novelwriter/core/project.py +++ b/novelwriter/core/project.py @@ -52,7 +52,7 @@ from novelwriter.constants import trConst, nwFiles, nwLabels logger = logging.getLogger(__name__) -class NWProject(): +class NWProject: FILE_VERSION = "1.4" # The current project file format version diff --git a/novelwriter/core/spellcheck.py b/novelwriter/core/spellcheck.py index d9c506cd..4a63bf39 100644 --- a/novelwriter/core/spellcheck.py +++ b/novelwriter/core/spellcheck.py @@ -33,7 +33,7 @@ from novelwriter.error import logException logger = logging.getLogger(__name__) -class NWSpellEnchant(): +class NWSpellEnchant: def __init__(self): diff --git a/novelwriter/core/status.py b/novelwriter/core/status.py index 4bade5e7..a379f911 100644 --- a/novelwriter/core/status.py +++ b/novelwriter/core/status.py @@ -37,7 +37,7 @@ from novelwriter.common import checkInt, minmax, simplified logger = logging.getLogger(__name__) -class NWStatus(): +class NWStatus: STATUS = 1 IMPORT = 2 diff --git a/novelwriter/core/tohtml.py b/novelwriter/core/tohtml.py index 86a21786..2110300c 100644 --- a/novelwriter/core/tohtml.py +++ b/novelwriter/core/tohtml.py @@ -38,7 +38,7 @@ class ToHtml(Tokenizer): M_EBOOK = 2 # Tweak output for converting to epub def __init__(self, theProject): - Tokenizer.__init__(self, theProject) + super().__init__(theProject) self._genMode = self.M_EXPORT self._cssStyles = True @@ -107,7 +107,7 @@ class ToHtml(Tokenizer): """Extend the auto-replace to also properly encode some unicode characters into their respective HTML entities. """ - Tokenizer.doPreProcessing(self) + super().doPreProcessing() self._theText = self._theText.translate(self._trMap) return diff --git a/novelwriter/core/tomd.py b/novelwriter/core/tomd.py index 48d23a35..89ae9e4f 100644 --- a/novelwriter/core/tomd.py +++ b/novelwriter/core/tomd.py @@ -37,7 +37,7 @@ class ToMarkdown(Tokenizer): M_GH = 1 # GitHub Markdown def __init__(self, theProject): - Tokenizer.__init__(self, theProject) + super().__init__(theProject) self._genMode = self.M_STD self._fullMD = [] diff --git a/novelwriter/core/toodt.py b/novelwriter/core/toodt.py index 59eaf30f..022bda4c 100644 --- a/novelwriter/core/toodt.py +++ b/novelwriter/core/toodt.py @@ -89,7 +89,7 @@ M_DEL = ~X_DEL class ToOdt(Tokenizer): def __init__(self, theProject, isFlat): - Tokenizer.__init__(self, theProject) + super().__init__(theProject) self._isFlat = isFlat # Flat: .fodt, otherwise .odt @@ -994,7 +994,7 @@ class ToOdt(Tokenizer): # Auto-Style Classes # =============================================================================================== # -class ODTParagraphStyle(): +class ODTParagraphStyle: """Wrapper class for the paragraph style setting used by the exporter. Only the used settings are exposed here to keep the class minimal and fast. @@ -1208,7 +1208,7 @@ class ODTParagraphStyle(): # END Class ODTParagraphStyle -class ODTTextStyle(): +class ODTTextStyle: """Wrapper class for the text style setting used by the exporter. Only the used settings are exposed here to keep the class minimal and fast. @@ -1297,7 +1297,7 @@ X_SPAN_TEXT = 2 X_SPAN_SING = 3 -class XMLParagraph(): +class XMLParagraph: """This is a helper class to manage the text content of a single XML element using mixed content tags. diff --git a/novelwriter/core/tree.py b/novelwriter/core/tree.py index 6bb24959..ec8073df 100644 --- a/novelwriter/core/tree.py +++ b/novelwriter/core/tree.py @@ -38,7 +38,7 @@ from novelwriter.core.item import NWItem logger = logging.getLogger(__name__) -class NWTree(): +class NWTree: MAX_DEPTH = 1000 # Cap of tree traversing for loops diff --git a/novelwriter/dialogs/about.py b/novelwriter/dialogs/about.py index 9cf43daf..5b3a509e 100644 --- a/novelwriter/dialogs/about.py +++ b/novelwriter/dialogs/about.py @@ -44,7 +44,7 @@ logger = logging.getLogger(__name__) class GuiAbout(QDialog): def __init__(self, mainGui): - QDialog.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiAbout ...") self.setObjectName("GuiAbout") diff --git a/novelwriter/dialogs/docsplit.py b/novelwriter/dialogs/docsplit.py index e4c9b13a..f99166fb 100644 --- a/novelwriter/dialogs/docsplit.py +++ b/novelwriter/dialogs/docsplit.py @@ -42,7 +42,7 @@ logger = logging.getLogger(__name__) class GuiDocSplit(QDialog): def __init__(self, mainGui): - QDialog.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiDocSplit ...") self.setObjectName("GuiDocSplit") diff --git a/novelwriter/dialogs/editlabel.py b/novelwriter/dialogs/editlabel.py index 03bf9d08..a1982ede 100644 --- a/novelwriter/dialogs/editlabel.py +++ b/novelwriter/dialogs/editlabel.py @@ -36,7 +36,7 @@ logger = logging.getLogger(__name__) class GuiEditLabel(QDialog): def __init__(self, parent, text=""): - QDialog.__init__(self, parent=parent) + super().__init__(parent=parent) self.setObjectName("GuiEditLabel") self.setWindowTitle(self.tr("Item Label")) diff --git a/novelwriter/dialogs/preferences.py b/novelwriter/dialogs/preferences.py index f807fde1..964f92b0 100644 --- a/novelwriter/dialogs/preferences.py +++ b/novelwriter/dialogs/preferences.py @@ -44,7 +44,7 @@ logger = logging.getLogger(__name__) class GuiPreferences(PagedDialog): def __init__(self, mainGui): - PagedDialog.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiPreferences ...") self.setObjectName("GuiPreferences") @@ -55,13 +55,13 @@ class GuiPreferences(PagedDialog): self.setWindowTitle(self.tr("Preferences")) - 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.tabGeneral = GuiPreferencesGeneral(self, self.mainGui) + self.tabProjects = GuiPreferencesProjects(self, self.mainGui) + self.tabDocs = GuiPreferencesDocuments(self, self.mainGui) + self.tabEditor = GuiPreferencesEditor(self, self.mainGui) + self.tabSyntax = GuiPreferencesSyntax(self, self.mainGui) + self.tabAuto = GuiPreferencesAutomation(self, self.mainGui) + self.tabQuote = GuiPreferencesQuotes(self, self.mainGui) self.addTab(self.tabGeneral, self.tr("General")) self.addTab(self.tabProjects, self.tr("Projects")) @@ -138,8 +138,8 @@ class GuiPreferences(PagedDialog): class GuiPreferencesGeneral(QWidget): - def __init__(self, mainGui): - QWidget.__init__(self, mainGui) + def __init__(self, prefsGui, mainGui): + super().__init__(parent=prefsGui) self.mainConf = novelwriter.CONFIG self.mainGui = mainGui @@ -344,8 +344,8 @@ class GuiPreferencesGeneral(QWidget): class GuiPreferencesProjects(QWidget): - def __init__(self, mainGui): - QWidget.__init__(self, mainGui) + def __init__(self, prefsGui, mainGui): + super().__init__(parent=prefsGui) self.mainConf = novelwriter.CONFIG self.mainGui = mainGui @@ -505,8 +505,8 @@ class GuiPreferencesProjects(QWidget): class GuiPreferencesDocuments(QWidget): - def __init__(self, mainGui): - QWidget.__init__(self, mainGui) + def __init__(self, prefsGui, mainGui): + super().__init__(parent=prefsGui) self.mainConf = novelwriter.CONFIG self.mainGui = mainGui @@ -666,8 +666,8 @@ class GuiPreferencesDocuments(QWidget): class GuiPreferencesEditor(QWidget): - def __init__(self, mainGui): - QWidget.__init__(self, mainGui) + def __init__(self, prefsGui, mainGui): + super().__init__(parent=prefsGui) self.mainConf = novelwriter.CONFIG self.mainGui = mainGui @@ -840,8 +840,8 @@ class GuiPreferencesEditor(QWidget): class GuiPreferencesSyntax(QWidget): - def __init__(self, mainGui): - QWidget.__init__(self, mainGui) + def __init__(self, prefsGui, mainGui): + super().__init__(parent=prefsGui) self.mainConf = novelwriter.CONFIG self.mainGui = mainGui @@ -943,8 +943,8 @@ class GuiPreferencesSyntax(QWidget): class GuiPreferencesAutomation(QWidget): - def __init__(self, mainGui): - QWidget.__init__(self, mainGui) + def __init__(self, prefsGui, mainGui): + super().__init__(parent=prefsGui) self.mainConf = novelwriter.CONFIG self.mainGui = mainGui @@ -1100,8 +1100,8 @@ class GuiPreferencesAutomation(QWidget): class GuiPreferencesQuotes(QWidget): - def __init__(self, mainGui): - QWidget.__init__(self, mainGui) + def __init__(self, prefsGui, mainGui): + super().__init__(parent=prefsGui) self.mainConf = novelwriter.CONFIG self.mainGui = mainGui diff --git a/novelwriter/dialogs/projdetails.py b/novelwriter/dialogs/projdetails.py index 7b23498a..67ab6ebe 100644 --- a/novelwriter/dialogs/projdetails.py +++ b/novelwriter/dialogs/projdetails.py @@ -46,7 +46,7 @@ logger = logging.getLogger(__name__) class GuiProjectDetails(PagedDialog): def __init__(self, mainGui): - PagedDialog.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiProjectDetails ...") self.setObjectName("GuiProjectDetails") @@ -142,7 +142,7 @@ class GuiProjectDetails(PagedDialog): class GuiProjectDetailsMain(QWidget): def __init__(self, mainGui, theProject): - QWidget.__init__(self, mainGui) + super().__init__(parent=mainGui) self.mainConf = novelwriter.CONFIG self.theProject = theProject @@ -274,7 +274,7 @@ class GuiProjectDetailsContents(QWidget): C_PROG = 4 def __init__(self, mainGui, theProject): - QWidget.__init__(self, mainGui) + super().__init__(parent=mainGui) self.mainConf = novelwriter.CONFIG self.theProject = theProject diff --git a/novelwriter/dialogs/projload.py b/novelwriter/dialogs/projload.py index c7229f44..fd06fabf 100644 --- a/novelwriter/dialogs/projload.py +++ b/novelwriter/dialogs/projload.py @@ -54,7 +54,7 @@ class GuiProjectLoad(QDialog): C_TIME = 2 def __init__(self, mainGui): - QDialog.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiProjectLoad ...") self.setObjectName("GuiProjectLoad") diff --git a/novelwriter/dialogs/projsettings.py b/novelwriter/dialogs/projsettings.py index 11a640b1..d2484a20 100644 --- a/novelwriter/dialogs/projsettings.py +++ b/novelwriter/dialogs/projsettings.py @@ -44,7 +44,7 @@ logger = logging.getLogger(__name__) class GuiProjectSettings(PagedDialog): def __init__(self, mainGui): - PagedDialog.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiProjectSettings ...") self.setObjectName("GuiProjectSettings") @@ -67,10 +67,10 @@ class GuiProjectSettings(PagedDialog): self.mainConf.pxInt(pOptions.getInt("GuiProjectSettings", "winHeight", wH)) ) - 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.tabMain = GuiProjectEditMain(self, self.mainGui, self.theProject) + self.tabStatus = GuiProjectEditStatus(self, self.mainGui, self.theProject, True) + self.tabImport = GuiProjectEditStatus(self, self.mainGui, self.theProject, False) + self.tabReplace = GuiProjectEditReplace(self, self.mainGui, self.theProject) self.addTab(self.tabMain, self.tr("Settings")) self.addTab(self.tabStatus, self.tr("Status")) @@ -166,8 +166,8 @@ class GuiProjectSettings(PagedDialog): class GuiProjectEditMain(QWidget): - def __init__(self, mainGui, theProject): - QWidget.__init__(self, mainGui) + def __init__(self, projGui, mainGui, theProject): + super().__init__(parent=projGui) self.mainConf = novelwriter.CONFIG self.mainGui = mainGui @@ -256,8 +256,8 @@ class GuiProjectEditStatus(QWidget): COL_ROLE = Qt.UserRole + 1 NUM_ROLE = Qt.UserRole + 2 - def __init__(self, mainGui, theProject, isStatus): - QWidget.__init__(self, mainGui) + def __init__(self, prefsGui, mainGui, theProject, isStatus): + super().__init__(parent=prefsGui) self.mainConf = novelwriter.CONFIG self.mainGui = mainGui @@ -527,8 +527,8 @@ class GuiProjectEditReplace(QWidget): COL_KEY = 0 COL_REPL = 1 - def __init__(self, mainGui, theProject): - QWidget.__init__(self, mainGui) + def __init__(self, prefsGui, mainGui, theProject): + super().__init__(parent=prefsGui) self.mainConf = novelwriter.CONFIG self.mainGui = mainGui diff --git a/novelwriter/dialogs/quotes.py b/novelwriter/dialogs/quotes.py index 299386d8..685459d4 100644 --- a/novelwriter/dialogs/quotes.py +++ b/novelwriter/dialogs/quotes.py @@ -43,7 +43,7 @@ class GuiQuoteSelect(QDialog): selectedQuote = "" def __init__(self, parent=None, currentQuote='"'): - QDialog.__init__(self, parent=parent) + super().__init__(parent=parent) self.mainConf = novelwriter.CONFIG diff --git a/novelwriter/dialogs/updates.py b/novelwriter/dialogs/updates.py index c4782e6d..8b8f1d27 100644 --- a/novelwriter/dialogs/updates.py +++ b/novelwriter/dialogs/updates.py @@ -44,7 +44,7 @@ logger = logging.getLogger(__name__) class GuiUpdates(QDialog): def __init__(self, mainGui): - QDialog.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiUpdates ...") self.setObjectName("GuiUpdates") diff --git a/novelwriter/dialogs/wordlist.py b/novelwriter/dialogs/wordlist.py index 9a17eed8..f155c25e 100644 --- a/novelwriter/dialogs/wordlist.py +++ b/novelwriter/dialogs/wordlist.py @@ -43,7 +43,7 @@ logger = logging.getLogger(__name__) class GuiWordList(QDialog): def __init__(self, mainGui): - QDialog.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiWordList ...") self.setObjectName("GuiWordList") diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index 0942d823..3f9fae10 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -73,7 +73,7 @@ class GuiDocEditor(QTextEdit): loadDocumentTagRequest = pyqtSignal(str, Enum) def __init__(self, mainGui): - QTextEdit.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiDocEditor ...") @@ -1003,7 +1003,7 @@ class GuiDocEditor(QTextEdit): if self.mainConf.autoScroll: cOld = self.cursorRect().center().y() - QTextEdit.keyPressEvent(self, keyEvent) + super().keyPressEvent(keyEvent) kMod = keyEvent.modifiers() okMod = kMod == Qt.NoModifier or kMod == Qt.ShiftModifier @@ -1022,7 +1022,7 @@ class GuiDocEditor(QTextEdit): doAnim.start() else: - QTextEdit.keyPressEvent(self, keyEvent) + super().keyPressEvent(keyEvent) self.docFooter.updateLineCount() @@ -1049,7 +1049,7 @@ class GuiDocEditor(QTextEdit): theCursor = self.cursorForPosition(theEvent.pos()) self._followTag(theCursor) - QTextEdit.mouseReleaseEvent(self, theEvent) + super().mouseReleaseEvent(theEvent) self.docFooter.updateLineCount() return @@ -1059,7 +1059,7 @@ class GuiDocEditor(QTextEdit): has its margins adjusted according to user preferences. """ self.updateDocMargins() - QTextEdit.resizeEvent(self, theEvent) + super().resizeEvent(theEvent) return ## @@ -2161,7 +2161,7 @@ class GuiDocEditor(QTextEdit): class BackgroundWordCounter(QRunnable): def __init__(self, docEditor, forSelection=False): - QRunnable.__init__(self) + super().__init__() self._docEditor = docEditor self._forSelection = forSelection @@ -2211,7 +2211,7 @@ class BackgroundWordCounterSignals(QObject): class GuiDocEditSearch(QFrame): def __init__(self, docEditor): - QFrame.__init__(self, docEditor) + super().__init__(parent=docEditor) logger.debug("Initialising GuiDocEditSearch ...") @@ -2599,7 +2599,7 @@ class GuiDocEditSearch(QFrame): class GuiDocEditHeader(QWidget): def __init__(self, docEditor): - QWidget.__init__(self, docEditor) + super().__init__(parent=docEditor) logger.debug("Initialising GuiDocEditHeader ...") @@ -2823,7 +2823,7 @@ class GuiDocEditHeader(QWidget): class GuiDocEditFooter(QWidget): def __init__(self, docEditor): - QWidget.__init__(self, docEditor) + super().__init__(parent=docEditor) logger.debug("Initialising GuiDocEditFooter ...") diff --git a/novelwriter/gui/dochighlight.py b/novelwriter/gui/dochighlight.py index 8b7ec1a5..91aa0416 100644 --- a/novelwriter/gui/dochighlight.py +++ b/novelwriter/gui/dochighlight.py @@ -47,7 +47,7 @@ class GuiDocHighlighter(QSyntaxHighlighter): BLOCK_TITLE = 4 def __init__(self, theDoc, mainGui, spEnchant): - QSyntaxHighlighter.__init__(self, theDoc) + super().__init__(theDoc) logger.debug("Initialising GuiDocHighlighter ...") self.mainConf = novelwriter.CONFIG diff --git a/novelwriter/gui/docviewer.py b/novelwriter/gui/docviewer.py index 6ce275a3..f4413805 100644 --- a/novelwriter/gui/docviewer.py +++ b/novelwriter/gui/docviewer.py @@ -54,7 +54,7 @@ class GuiDocViewer(QTextBrowser): loadDocumentTagRequest = pyqtSignal(str, Enum) def __init__(self, mainGui): - QTextBrowser.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiDocViewer ...") @@ -461,7 +461,7 @@ class GuiDocViewer(QTextBrowser): has its margins adjusted according to user preferences. """ self.updateDocMargins() - QTextBrowser.resizeEvent(self, theEvent) + super().resizeEvent(theEvent) return def mouseReleaseEvent(self, theEvent): @@ -472,7 +472,7 @@ class GuiDocViewer(QTextBrowser): elif theEvent.button() == Qt.ForwardButton: self.navForward() else: - QTextBrowser.mouseReleaseEvent(self, theEvent) + super().mouseReleaseEvent(theEvent) return ## @@ -568,7 +568,7 @@ class GuiDocViewer(QTextBrowser): # END Class GuiDocViewer -class GuiDocViewHistory(): +class GuiDocViewHistory: def __init__(self, docViewer): @@ -708,7 +708,7 @@ class GuiDocViewHistory(): class GuiDocViewHeader(QWidget): def __init__(self, docViewer): - QWidget.__init__(self, docViewer) + super().__init__(parent=docViewer) logger.debug("Initialising GuiDocViewHeader ...") @@ -915,7 +915,7 @@ class GuiDocViewHeader(QWidget): class GuiDocViewFooter(QWidget): def __init__(self, docViewer): - QWidget.__init__(self, docViewer) + super().__init__(parent=docViewer) logger.debug("Initialising GuiDocViewFooter ...") @@ -1141,7 +1141,7 @@ class GuiDocViewFooter(QWidget): class GuiDocViewDetails(QScrollArea): def __init__(self, mainGui): - QScrollArea.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiDocViewDetails ...") self.mainConf = novelwriter.CONFIG diff --git a/novelwriter/gui/itemdetails.py b/novelwriter/gui/itemdetails.py index a467ed04..dbd2838c 100644 --- a/novelwriter/gui/itemdetails.py +++ b/novelwriter/gui/itemdetails.py @@ -38,7 +38,7 @@ logger = logging.getLogger(__name__) class GuiItemDetails(QWidget): def __init__(self, mainGui): - QWidget.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiItemDetails ...") self.mainConf = novelwriter.CONFIG diff --git a/novelwriter/gui/mainmenu.py b/novelwriter/gui/mainmenu.py index 7877d44a..f4e6e668 100644 --- a/novelwriter/gui/mainmenu.py +++ b/novelwriter/gui/mainmenu.py @@ -42,7 +42,7 @@ logger = logging.getLogger(__name__) class GuiMainMenu(QMenuBar): def __init__(self, mainGui): - QMenuBar.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiMainMenu ...") self.mainConf = novelwriter.CONFIG diff --git a/novelwriter/gui/noveltree.py b/novelwriter/gui/noveltree.py index c8d88b88..b68fb812 100644 --- a/novelwriter/gui/noveltree.py +++ b/novelwriter/gui/noveltree.py @@ -63,7 +63,7 @@ class GuiNovelView(QWidget): openDocumentRequest = pyqtSignal(str, Enum, int, str) def __init__(self, mainGui): - QWidget.__init__(self, mainGui) + super().__init__(parent=mainGui) self.mainGui = mainGui self.theProject = mainGui.theProject @@ -166,7 +166,7 @@ class GuiNovelView(QWidget): class GuiNovelToolBar(QWidget): def __init__(self, novelView): - QTreeWidget.__init__(self, novelView) + super().__init__(parent=novelView) logger.debug("Initialising GuiNovelToolBar ...") @@ -333,7 +333,7 @@ class GuiNovelTree(QTreeWidget): D_KEY = Qt.UserRole + 2 def __init__(self, novelView): - QTreeWidget.__init__(self, novelView) + super().__init__(parent=novelView) logger.debug("Initialising GuiNovelTree ...") @@ -539,7 +539,7 @@ class GuiNovelTree(QTreeWidget): mouse in a blank area of the tree view, and to load a document for viewing if the user middle-clicked. """ - QTreeWidget.mousePressEvent(self, theEvent) + super().mousePressEvent(theEvent) if theEvent.button() == Qt.LeftButton: selItem = self.indexAt(theEvent.pos()) @@ -562,7 +562,7 @@ class GuiNovelTree(QTreeWidget): def focusOutEvent(self, theEvent): """Clear the selection when the tree no longer has focus. """ - QTreeWidget.focusOutEvent(self, theEvent) + super().focusOutEvent(theEvent) self.clearSelection() return diff --git a/novelwriter/gui/outline.py b/novelwriter/gui/outline.py index b5e67b2e..ea76676f 100644 --- a/novelwriter/gui/outline.py +++ b/novelwriter/gui/outline.py @@ -57,7 +57,7 @@ class GuiOutlineView(QWidget): loadDocumentTagRequest = pyqtSignal(str, Enum) def __init__(self, mainGui): - QWidget.__init__(self, mainGui) + super().__init__(parent=mainGui) self.mainConf = novelwriter.CONFIG self.mainGui = mainGui @@ -198,7 +198,7 @@ class GuiOutlineToolBar(QToolBar): viewColumnToggled = pyqtSignal(bool, Enum) def __init__(self, theOutline): - QTreeWidget.__init__(self, theOutline) + super().__init__(parent=theOutline) logger.debug("Initialising GuiOutlineToolBar ...") @@ -357,7 +357,7 @@ class GuiOutlineTree(QTreeWidget): activeItemChanged = pyqtSignal(str, str) def __init__(self, theOutline): - QTreeWidget.__init__(self, theOutline) + super().__init__(parent=theOutline) logger.debug("Initialising GuiOutlineTree ...") @@ -741,7 +741,7 @@ class GuiOutlineHeaderMenu(QMenu): columnToggled = pyqtSignal(bool, Enum) def __init__(self, theOutline): - QMenu.__init__(self, theOutline) + super().__init__(parent=theOutline) self.acceptToggle = True @@ -792,7 +792,7 @@ class GuiOutlineDetails(QScrollArea): itemTagClicked = pyqtSignal(str) def __init__(self, theOutline): - QScrollArea.__init__(self, theOutline) + super().__init__(parent=theOutline) logger.debug("Initialising GuiOutlineDetails ...") diff --git a/novelwriter/gui/projtree.py b/novelwriter/gui/projtree.py index 4195997c..675cf65c 100644 --- a/novelwriter/gui/projtree.py +++ b/novelwriter/gui/projtree.py @@ -63,7 +63,7 @@ class GuiProjectView(QWidget): openDocumentRequest = pyqtSignal(str, Enum, int, str) def __init__(self, mainGui): - QWidget.__init__(self, mainGui) + super().__init__(parent=mainGui) self.mainGui = mainGui @@ -164,7 +164,7 @@ class GuiProjectView(QWidget): class GuiProjectToolBar(QWidget): def __init__(self, projView): - QTreeWidget.__init__(self, projView) + super().__init__(parent=projView) logger.debug("Initialising GuiProjectToolBar ...") @@ -327,7 +327,7 @@ class GuiProjectTree(QTreeWidget): C_STATUS = 3 def __init__(self, projView): - QTreeWidget.__init__(self, projView) + super().__init__(parent=projView) logger.debug("Initialising GuiProjectTree ...") @@ -1191,7 +1191,7 @@ class GuiProjectTree(QTreeWidget): mouse in a blank area of the tree view, and to load a document for viewing if the user middle-clicked. """ - QTreeWidget.mousePressEvent(self, theEvent) + super().mousePressEvent(theEvent) if theEvent.button() == Qt.LeftButton: selItem = self.indexAt(theEvent.pos()) @@ -1237,7 +1237,7 @@ class GuiProjectTree(QTreeWidget): wCount = self._getItemWordCount(sHandle) self.propagateCount(sHandle, 0) - QTreeWidget.dropEvent(self, theEvent) + super().dropEvent(theEvent) self._postItemMove(sHandle, wCount) self._recordLastMove(sItem, pItem, pIndex) self._alertTreeChange(sHandle, flush=True) diff --git a/novelwriter/gui/statusbar.py b/novelwriter/gui/statusbar.py index a0cf9416..c6191b8d 100644 --- a/novelwriter/gui/statusbar.py +++ b/novelwriter/gui/statusbar.py @@ -42,7 +42,7 @@ logger = logging.getLogger(__name__) class GuiMainStatus(QStatusBar): def __init__(self, mainGui): - QStatusBar.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiMainStatus ...") diff --git a/novelwriter/gui/viewsbar.py b/novelwriter/gui/viewsbar.py index 031f4316..4d19f818 100644 --- a/novelwriter/gui/viewsbar.py +++ b/novelwriter/gui/viewsbar.py @@ -41,7 +41,7 @@ class GuiViewsBar(QToolBar): viewChangeRequested = pyqtSignal(nwView) def __init__(self, mainGui): - QToolBar.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiViewsBar ...") diff --git a/novelwriter/guimain.py b/novelwriter/guimain.py index 67442f94..79f56b97 100644 --- a/novelwriter/guimain.py +++ b/novelwriter/guimain.py @@ -62,7 +62,7 @@ logger = logging.getLogger(__name__) class GuiMain(QMainWindow): def __init__(self): - QMainWindow.__init__(self) + super().__init__() logger.debug("Initialising GUI ...") self.setObjectName("GuiMain") diff --git a/novelwriter/tools/build.py b/novelwriter/tools/build.py index 7a0eba6c..2915818c 100644 --- a/novelwriter/tools/build.py +++ b/novelwriter/tools/build.py @@ -66,7 +66,7 @@ class GuiBuildNovel(QDialog): FMT_JSON_M = 9 # nW Markdown wrapped in JSON def __init__(self, mainGui): - QDialog.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiBuildNovel ...") self.setObjectName("GuiBuildNovel") @@ -1194,7 +1194,7 @@ class GuiBuildNovel(QDialog): class GuiBuildNovelDocView(QTextBrowser): def __init__(self, mainGui, theProject): - QTextBrowser.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiBuildNovelDocView ...") @@ -1343,7 +1343,7 @@ class GuiBuildNovelDocView(QTextBrowser): def resizeEvent(self, theEvent): """Make sure the document title is the same width as the window. """ - QTextBrowser.resizeEvent(self, theEvent) + super().resizeEvent(theEvent) self._updateDocMargins() return diff --git a/novelwriter/tools/lipsum.py b/novelwriter/tools/lipsum.py index 2086d615..64069e6f 100644 --- a/novelwriter/tools/lipsum.py +++ b/novelwriter/tools/lipsum.py @@ -43,7 +43,7 @@ logger = logging.getLogger(__name__) class GuiLipsum(QDialog): def __init__(self, mainGui): - QDialog.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiLipsum ...") self.setObjectName("GuiLipsum") diff --git a/novelwriter/tools/projwizard.py b/novelwriter/tools/projwizard.py index 5b21f69a..d2602a4c 100644 --- a/novelwriter/tools/projwizard.py +++ b/novelwriter/tools/projwizard.py @@ -49,7 +49,7 @@ PAGE_FINAL = 4 class GuiProjectWizard(QWizard): def __init__(self, mainGui): - QWizard.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiProjectWizard ...") self.setObjectName("GuiProjectWizard") @@ -88,7 +88,7 @@ class GuiProjectWizard(QWizard): class ProjWizardIntroPage(QWizardPage): def __init__(self, theWizard): - QWizardPage.__init__(self) + super().__init__() self.mainConf = novelwriter.CONFIG self.theWizard = theWizard @@ -158,7 +158,7 @@ class ProjWizardIntroPage(QWizardPage): class ProjWizardFolderPage(QWizardPage): def __init__(self, theWizard): - QWizardPage.__init__(self) + super().__init__() self.mainConf = novelwriter.CONFIG self.theWizard = theWizard @@ -209,7 +209,7 @@ class ProjWizardFolderPage(QWizardPage): """Check that the selected path isn't already being used. """ self.errLabel.setText("") - if not QWizardPage.isComplete(self): + if not super().isComplete(): return False setPath = os.path.abspath(os.path.expanduser(self.projPath.text())) @@ -259,7 +259,7 @@ class ProjWizardFolderPage(QWizardPage): class ProjWizardPopulatePage(QWizardPage): def __init__(self, theWizard): - QWizardPage.__init__(self) + super().__init__() self.mainConf = novelwriter.CONFIG self.theWizard = theWizard @@ -315,7 +315,7 @@ class ProjWizardPopulatePage(QWizardPage): class ProjWizardCustomPage(QWizardPage): def __init__(self, theWizard): - QWizardPage.__init__(self) + super().__init__() self.mainConf = novelwriter.CONFIG self.theWizard = theWizard @@ -397,7 +397,7 @@ class ProjWizardCustomPage(QWizardPage): class ProjWizardFinalPage(QWizardPage): def __init__(self, theWizard): - QWizardPage.__init__(self) + super().__init__() self.mainConf = novelwriter.CONFIG self.theWizard = theWizard @@ -418,7 +418,7 @@ class ProjWizardFinalPage(QWizardPage): def initializePage(self): """Update the summary information on the final page. """ - QWizardPage.initializePage(self) + super().initializePage() sumList = [] sumList.append(self.tr("Project Name: {0}").format(self.field("projName"))) diff --git a/novelwriter/tools/writingstats.py b/novelwriter/tools/writingstats.py index add052ec..7033aadc 100644 --- a/novelwriter/tools/writingstats.py +++ b/novelwriter/tools/writingstats.py @@ -58,7 +58,7 @@ class GuiWritingStats(QDialog): FMT_CSV = 1 def __init__(self, mainGui): - QDialog.__init__(self, mainGui) + super().__init__(parent=mainGui) logger.debug("Initialising GuiWritingStats ...") self.setObjectName("GuiWritingStats") diff --git a/tests/mock.py b/tests/mock.py index 23938d41..6174a3cb 100644 --- a/tests/mock.py +++ b/tests/mock.py @@ -24,7 +24,7 @@ along with this program. If not, see . # Mock GUI # =========================================================================== # -class MockGuiMain(): +class MockGuiMain: def __init__(self): self.mainConf = None @@ -81,7 +81,7 @@ class MockGuiMain(): # END Class MockGuiMain -class MockStatusBar(): +class MockStatusBar: def __init__(self): return