diff --git a/novelWriter.py b/novelWriter.py index 4f609f24..2cfee6e4 100755 --- a/novelWriter.py +++ b/novelWriter.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- """ novelWriter – Start Script ========================== diff --git a/nw/__init__.py b/nw/__init__.py index 637e1b62..d1562e5c 100644 --- a/nw/__init__.py +++ b/nw/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Init File ======================= @@ -90,15 +89,19 @@ __docurl__ = "https://novelwriter.readthedocs.io" # Add verbose logging level VERBOSE = 5 logging.addLevelName(VERBOSE, "VERBOSE") + + def logVerbose(self, message, *args, **kws): if self.isEnabledFor(VERBOSE): self._log(VERBOSE, message, args, **kws) + logging.Logger.verbose = logVerbose # Initiating logging logger = logging.getLogger(__name__) + ## # Main Program ## @@ -106,6 +109,7 @@ logger = logging.getLogger(__name__) # Load the main config as a global object CONFIG = Config() + def main(sysArgs=None): """Parses command line, sets up logging, and launches main GUI. """ diff --git a/nw/common.py b/nw/common.py index d093be2d..26017ee0 100644 --- a/nw/common.py +++ b/nw/common.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Common Functions ============================== @@ -36,6 +35,7 @@ from nw.constants import nwConst, nwUnicode logger = logging.getLogger(__name__) + def checkString(value, default, allowNone=False): """Check if a variable is a string or a none. """ @@ -48,6 +48,7 @@ def checkString(value, default, allowNone=False): return str(value) return default + def checkInt(value, default, allowNone=False): """Check if a variable is an integer or a none. """ @@ -61,6 +62,7 @@ def checkInt(value, default, allowNone=False): except Exception: return default + def checkBool(value, default, allowNone=False): """Check if a variable is a boolean or a none. """ @@ -85,6 +87,7 @@ def checkBool(value, default, allowNone=False): return default return default + def checkHandle(value, default, allowNone=False): """Check if a value is a handle. """ @@ -97,6 +100,7 @@ def checkHandle(value, default, allowNone=False): return str(value) return default + def isHandle(theString): """Check if a string is a valid novelWriter handle. Note: This is case sensitive. Must be lower case! @@ -110,6 +114,7 @@ def isHandle(theString): return False return True + def isTitleTag(theString): """Check if a string is a valid title string. """ @@ -124,21 +129,25 @@ def isTitleTag(theString): return False return True + def isItemClass(theString): """Check if an item is a calid nwItemClass identifier. """ return theString in nwItemClass.__members__ + def isItemType(theString): """Check if an item is a calid nwItemType identifier. """ return theString in nwItemType.__members__ + def isItemLayout(theString): """Check if an item is a calid nwItemLayout identifier. """ return theString in nwItemLayout.__members__ + def hexToInt(value, default=0): """Convert a hex string to an integer. """ @@ -149,6 +158,7 @@ def hexToInt(value, default=0): return default return default + def formatInt(theInt): """Formats an integer with k, M, G etc. """ @@ -168,6 +178,7 @@ def formatInt(theInt): return str(theInt) + def formatTimeStamp(theTime, fileSafe=False): """Take a number (on the format returned by time.time()) and convert it to a timestamp string. @@ -177,6 +188,7 @@ def formatTimeStamp(theTime, fileSafe=False): else: return datetime.fromtimestamp(theTime).strftime(nwConst.FMT_TSTAMP) + def formatTime(tS): """Format a time in seconds in HH:MM:SS format or d-HH:MM:SS format if a full day or longer. @@ -188,6 +200,7 @@ def formatTime(tS): return f"{tS//3600:02d}:{tS%3600//60:02d}:{tS%60:02d}" return "ERROR" + def splitVersionNumber(vString): """ Splits a version string on the form aa.bb.cc into major, minor and patch, and computes an integer value aabbcc. @@ -211,6 +224,7 @@ def splitVersionNumber(vString): return [vMajor, vMinor, vPatch, vInt] + def transferCase(theSource, theTarget): """Transfers the case of the source word to the target word. This will consider all upper or lower, and first char capitalisation. @@ -232,6 +246,7 @@ def transferCase(theSource, theTarget): return theResult + def fuzzyTime(secDiff): """Converts a time difference in seconds into a fuzzy time string. """ @@ -292,6 +307,7 @@ def fuzzyTime(secDiff): "Common", "{0} years ago" ).format(int(round(secDiff/31557600))) + def makeFileNameSafe(theText): """Returns a filename safe version of the text. """ @@ -301,6 +317,7 @@ def makeFileNameSafe(theText): cleanName += c return cleanName + def getGuiItem(theName): """Returns a QtWidget based on its objectName. """ @@ -309,6 +326,7 @@ def getGuiItem(theName): return qWidget return None + def numberToRoman(numVal, isLower=False): """Convert an integer to a roman number. """ diff --git a/nw/config.py b/nw/config.py index 16647abd..910bc944 100644 --- a/nw/config.py +++ b/nw/config.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Config Class ========================== @@ -45,6 +44,7 @@ from nw.constants import nwConst, nwFiles, nwUnicode logger = logging.getLogger(__name__) + class Config: CNF_STR = 0 diff --git a/nw/constants.py b/nw/constants.py index abf399c5..26169ebe 100644 --- a/nw/constants.py +++ b/nw/constants.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Constants ======================= @@ -28,11 +27,13 @@ from PyQt5.QtCore import QCoreApplication, QT_TRANSLATE_NOOP from nw.enum import nwItemClass, nwItemLayout, nwItemType, nwOutline + def trConst(tString): """Wrapper function for locally translating constants. """ return QCoreApplication.translate("Constant", tString) + class nwConst(): # Date and Time Formats @@ -51,6 +52,7 @@ class nwConst(): # END Class nwConst + class nwLists(): """Lists used for grouping various other constants. """ @@ -65,6 +67,7 @@ class nwLists(): # END Class nwLists + class nwRegEx(): FMT_EI = r"(?. +""" from nw.core.document import NWDoc from nw.core.index import NWIndex, countWords diff --git a/nw/core/document.py b/nw/core/document.py index 7088f61a..60ebd63a 100644 --- a/nw/core/document.py +++ b/nw/core/document.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Project Document ============================== @@ -32,6 +31,7 @@ from nw.common import isHandle logger = logging.getLogger(__name__) + class NWDoc(): def __init__(self, theProject, theHandle): diff --git a/nw/core/index.py b/nw/core/index.py index da11e401..a1759dab 100644 --- a/nw/core/index.py +++ b/nw/core/index.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Project Index =========================== @@ -39,6 +38,7 @@ from nw.core.document import NWDoc logger = logging.getLogger(__name__) + class NWIndex(): H_VALID = ("H0", "H1", "H2", "H3", "H4") @@ -895,6 +895,7 @@ class NWIndex(): # END Class NWIndex + # =============================================================================================== # # Simple Word Counter # =============================================================================================== # diff --git a/nw/core/item.py b/nw/core/item.py index 6ed3f515..3880b5e2 100644 --- a/nw/core/item.py +++ b/nw/core/item.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Project Item Class ================================ @@ -33,6 +32,7 @@ from nw.common import checkInt, isHandle, isItemClass, isItemLayout, isItemType logger = logging.getLogger(__name__) + class NWItem(): def __init__(self, theProject): diff --git a/nw/core/options.py b/nw/core/options.py index e9de1af3..bb1d9fbb 100644 --- a/nw/core/options.py +++ b/nw/core/options.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Project Options Cache =================================== @@ -34,6 +33,7 @@ from nw.constants import nwFiles logger = logging.getLogger(__name__) + class OptionState(): def __init__(self, theProject): diff --git a/nw/core/project.py b/nw/core/project.py index dcf92822..9adab86f 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Project Wrapper ============================= @@ -50,6 +49,7 @@ from nw.constants import trConst, nwFiles, nwLabels logger = logging.getLogger(__name__) + class NWProject(): def __init__(self, theParent): diff --git a/nw/core/spellcheck.py b/nw/core/spellcheck.py index 8b148426..9fcda88f 100644 --- a/nw/core/spellcheck.py +++ b/nw/core/spellcheck.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Spell Check Classes ================================= @@ -31,6 +30,7 @@ import difflib logger = logging.getLogger(__name__) + # =============================================================================================== # # SpellChecking SuperClass # =============================================================================================== # @@ -122,6 +122,7 @@ class NWSpellCheck(): # END Class NWSpellCheck + # =============================================================================================== # # Enchant Based SpellChecking # =============================================================================================== # @@ -208,6 +209,7 @@ class NWSpellEnchant(NWSpellCheck): # END Class NWSpellEnchant + class FakeEnchant: """Fallback for when Enchant is selected, but not installed. """ @@ -225,6 +227,7 @@ class FakeEnchant: # END Class FakeEnchant + # =============================================================================================== # # Fallback SpellChecking Using difflib # =============================================================================================== # diff --git a/nw/core/status.py b/nw/core/status.py index cf0f9fab..b07a8475 100644 --- a/nw/core/status.py +++ b/nw/core/status.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Project Item Status Class ======================================= @@ -32,6 +31,7 @@ from nw.common import checkInt logger = logging.getLogger(__name__) + class NWStatus(): def __init__(self): diff --git a/nw/core/tohtml.py b/nw/core/tohtml.py index a205f6b1..f638d53f 100644 --- a/nw/core/tohtml.py +++ b/nw/core/tohtml.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – HTML Text Converter ================================= @@ -31,6 +30,7 @@ from nw.constants import nwKeyWords, nwLabels, nwHtmlUnicode logger = logging.getLogger(__name__) + class ToHtml(Tokenizer): M_PREVIEW = 0 # Tweak output for the DocViewer diff --git a/nw/core/tokenizer.py b/nw/core/tokenizer.py index 19d09bc3..77f4d4b7 100644 --- a/nw/core/tokenizer.py +++ b/nw/core/tokenizer.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Text Tokenizer ============================ @@ -40,6 +39,7 @@ from nw.core.document import NWDoc logger = logging.getLogger(__name__) + class Tokenizer(): # In-Text Format diff --git a/nw/core/tomd.py b/nw/core/tomd.py index d95a6810..b1b1b093 100644 --- a/nw/core/tomd.py +++ b/nw/core/tomd.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Markdown Text Converter ===================================== @@ -31,6 +30,7 @@ from nw.core.tokenizer import Tokenizer logger = logging.getLogger(__name__) + class ToMarkdown(Tokenizer): M_STD = 0 # Standard Markdown diff --git a/nw/core/toodt.py b/nw/core/toodt.py index b6dd08fc..b30d1954 100644 --- a/nw/core/toodt.py +++ b/nw/core/toodt.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – ODT Text Converter ================================ @@ -57,6 +56,7 @@ TAG_TAB = "{%s}tab" % XML_NS["text"] TAG_SPAN = "{%s}span" % XML_NS["text"] TAG_STNM = "{%s}style-name" % XML_NS["text"] + class ToOdt(Tokenizer): X_BLD = 0x01 # Bold format @@ -985,6 +985,7 @@ class ToOdt(Tokenizer): # END Class ToOdt + # =============================================================================================== # # Auto-Style Classes # =============================================================================================== # @@ -1212,6 +1213,7 @@ class ODTParagraphStyle(): # END Class ODTParagraphStyle + 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 @@ -1282,6 +1284,7 @@ class ODTTextStyle(): # END Class ODTTextStyle + # =============================================================================================== # # Local Functions # =============================================================================================== # diff --git a/nw/core/tree.py b/nw/core/tree.py index 9a6c3050..b2d53ad8 100644 --- a/nw/core/tree.py +++ b/nw/core/tree.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Project Tree Class ================================ @@ -62,6 +61,7 @@ LAYOUT_MAP = { }, } + class NWTree(): def __init__(self, theProject): diff --git a/nw/dialogs/__init__.py b/nw/dialogs/__init__.py index 2cb163a4..9f9e5bf8 100644 --- a/nw/dialogs/__init__.py +++ b/nw/dialogs/__init__.py @@ -1,4 +1,23 @@ -# -*- coding: utf-8 -*- +""" +novelWriter – Dialogs Init +========================== + +This file is a part of novelWriter +Copyright 2018–2021, Veronica Berglyd Olsen + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" from nw.dialogs.about import GuiAbout from nw.dialogs.docmerge import GuiDocMerge diff --git a/nw/dialogs/about.py b/nw/dialogs/about.py index 3ee819bb..28ed76d7 100644 --- a/nw/dialogs/about.py +++ b/nw/dialogs/about.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI About Box =========================== @@ -39,6 +38,7 @@ from PyQt5.QtWidgets import ( logger = logging.getLogger(__name__) + class GuiAbout(QDialog): def __init__(self, theParent): diff --git a/nw/dialogs/docmerge.py b/nw/dialogs/docmerge.py index 89b8233f..2708bc68 100644 --- a/nw/dialogs/docmerge.py +++ b/nw/dialogs/docmerge.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Doc Merge Tool ================================ @@ -39,6 +38,7 @@ from nw.gui.custom import QHelpLabel logger = logging.getLogger(__name__) + class GuiDocMerge(QDialog): def __init__(self, theParent): diff --git a/nw/dialogs/docsplit.py b/nw/dialogs/docsplit.py index 02dcd83a..219f1671 100644 --- a/nw/dialogs/docsplit.py +++ b/nw/dialogs/docsplit.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Doc Split Tool ================================ @@ -40,6 +39,7 @@ from nw.gui.custom import QHelpLabel logger = logging.getLogger(__name__) + class GuiDocSplit(QDialog): def __init__(self, theParent): diff --git a/nw/dialogs/itemeditor.py b/nw/dialogs/itemeditor.py index b8fa07f7..ca27e5ca 100644 --- a/nw/dialogs/itemeditor.py +++ b/nw/dialogs/itemeditor.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Item Editor ============================= @@ -39,6 +38,7 @@ from nw.gui.custom import QSwitch logger = logging.getLogger(__name__) + class GuiItemEditor(QDialog): def __init__(self, theParent, tHandle): diff --git a/nw/dialogs/preferences.py b/nw/dialogs/preferences.py index 88022e81..d372f8f6 100644 --- a/nw/dialogs/preferences.py +++ b/nw/dialogs/preferences.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Preferences ============================= @@ -43,6 +42,7 @@ from nw.dialogs.quotes import GuiQuoteSelect logger = logging.getLogger(__name__) + class GuiPreferences(PagedDialog): def __init__(self, theParent): @@ -134,6 +134,7 @@ class GuiPreferences(PagedDialog): # END Class GuiPreferences + class GuiPreferencesGeneral(QWidget): def __init__(self, theParent): @@ -319,6 +320,7 @@ class GuiPreferencesGeneral(QWidget): # END Class GuiPreferencesGeneral + class GuiPreferencesProjects(QWidget): def __init__(self, theParent): @@ -479,6 +481,7 @@ class GuiPreferencesProjects(QWidget): # END Class GuiPreferencesProjects + class GuiPreferencesDocuments(QWidget): def __init__(self, theParent): @@ -649,6 +652,7 @@ class GuiPreferencesDocuments(QWidget): # END Class GuiPreferencesDocuments + class GuiPreferencesEditor(QWidget): def __init__(self, theParent): @@ -849,6 +853,7 @@ class GuiPreferencesEditor(QWidget): # END Class GuiPreferencesEditor + class GuiPreferencesSyntax(QWidget): def __init__(self, theParent): @@ -973,6 +978,7 @@ class GuiPreferencesSyntax(QWidget): # END Class GuiPreferencesSyntax + class GuiPreferencesAutomation(QWidget): def __init__(self, theParent): @@ -1129,6 +1135,7 @@ class GuiPreferencesAutomation(QWidget): # END Class GuiPreferencesAutomation + class GuiPreferencesQuotes(QWidget): def __init__(self, theParent): diff --git a/nw/dialogs/projload.py b/nw/dialogs/projload.py index 5a5e8de4..f1d3a599 100644 --- a/nw/dialogs/projload.py +++ b/nw/dialogs/projload.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Open Project ============================== @@ -43,6 +42,7 @@ from nw.constants import nwFiles logger = logging.getLogger(__name__) + class GuiProjectLoad(QDialog): NONE_STATE = 0 diff --git a/nw/dialogs/projsettings.py b/nw/dialogs/projsettings.py index 86bbdbe5..edf84806 100644 --- a/nw/dialogs/projsettings.py +++ b/nw/dialogs/projsettings.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Project Settings ================================== @@ -40,6 +39,7 @@ from nw.gui.custom import QSwitch, PagedDialog, QConfigLayout logger = logging.getLogger(__name__) + class GuiProjectSettings(PagedDialog): def __init__(self, theParent): @@ -156,6 +156,7 @@ class GuiProjectSettings(PagedDialog): # END Class GuiProjectSettings + class GuiProjectEditMain(QWidget): def __init__(self, theParent, theProject): @@ -239,6 +240,7 @@ class GuiProjectEditMain(QWidget): # END Class GuiProjectEditMain + class GuiProjectEditStatus(QWidget): COL_LABEL = 0 @@ -487,6 +489,7 @@ class GuiProjectEditStatus(QWidget): # END Class GuiProjectEditStatus + class GuiProjectEditReplace(QWidget): COL_KEY = 0 diff --git a/nw/dialogs/quotes.py b/nw/dialogs/quotes.py index f1c9bd26..4f81ba29 100644 --- a/nw/dialogs/quotes.py +++ b/nw/dialogs/quotes.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Quotes Dialog =============================== @@ -38,6 +37,7 @@ from nw.constants import trConst, nwQuotes logger = logging.getLogger(__name__) + class GuiQuoteSelect(QDialog): selectedQuote = "" diff --git a/nw/dialogs/wordlist.py b/nw/dialogs/wordlist.py index 71442593..e328ecf2 100644 --- a/nw/dialogs/wordlist.py +++ b/nw/dialogs/wordlist.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI User Wordlist =============================== @@ -39,6 +38,7 @@ from nw.constants import nwFiles logger = logging.getLogger(__name__) + class GuiWordList(QDialog): def __init__(self, theParent): diff --git a/nw/enum.py b/nw/enum.py index f619d7dd..c0db68a4 100644 --- a/nw/enum.py +++ b/nw/enum.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Enums =================== @@ -26,6 +25,7 @@ along with this program. If not, see . from enum import Enum + class nwItemType(Enum): NO_TYPE = 0 @@ -36,6 +36,7 @@ class nwItemType(Enum): # END Enum nwItemType + class nwItemClass(Enum): NO_CLASS = 0 @@ -52,6 +53,7 @@ class nwItemClass(Enum): # END Enum nwItemClass + class nwItemLayout(Enum): NO_LAYOUT = 0 @@ -66,6 +68,7 @@ class nwItemLayout(Enum): # END Enum nwItemLayout + class nwDocAction(Enum): NO_ACTION = 0 @@ -98,6 +101,7 @@ class nwDocAction(Enum): # END Enum nwDocAction + class nwDocInsert(Enum): NO_INSERT = 0 @@ -108,6 +112,7 @@ class nwDocInsert(Enum): # END Enum nwDocInsert + class nwAlert(Enum): INFO = 0 @@ -117,6 +122,7 @@ class nwAlert(Enum): # END Enum nwAlert + class nwState(Enum): NONE = 0 @@ -125,6 +131,7 @@ class nwState(Enum): # END Enum nwState + class nwWidget(Enum): TREE = 1 @@ -134,6 +141,7 @@ class nwWidget(Enum): # END Enum nwWidget + class nwOutline(Enum): TITLE = 0 diff --git a/nw/error.py b/nw/error.py index 998b7347..74a7c8ea 100644 --- a/nw/error.py +++ b/nw/error.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Exception Handling ================================ @@ -35,6 +34,7 @@ from PyQt5.QtWidgets import ( logger = logging.getLogger(__name__) + # =============================================================================================== # # Utility Functions # =============================================================================================== # @@ -45,6 +45,7 @@ def logException(): exType, exValue, _ = sys.exc_info() logger.error("%s: %s" % (exType.__name__, str(exValue).strip("'"))) + # =============================================================================================== # # Error Handler # =============================================================================================== # @@ -151,6 +152,7 @@ class NWErrorMessage(QDialog): # END Class NWErrorMessage + def exceptionHandler(exType, exValue, exTrace): """Function to catch unhandled global exceptions. """ diff --git a/nw/gui/__init__.py b/nw/gui/__init__.py index eb87a87f..9c7b3b83 100644 --- a/nw/gui/__init__.py +++ b/nw/gui/__init__.py @@ -1,4 +1,23 @@ -# -*- coding: utf-8 -*- +""" +novelWriter – GUI Init +====================== + +This file is a part of novelWriter +Copyright 2018–2021, Veronica Berglyd Olsen + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" from nw.gui.doceditor import GuiDocEditor from nw.gui.docviewer import GuiDocViewer, GuiDocViewDetails diff --git a/nw/gui/custom.py b/nw/gui/custom.py index 343f3c10..86fd131a 100644 --- a/nw/gui/custom.py +++ b/nw/gui/custom.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Custom Widgets and Layouts ======================================== @@ -43,6 +42,7 @@ from nw.constants import nwUnicode logger = logging.getLogger(__name__) + # =============================================================================================== # # Config Form Layout # =============================================================================================== # @@ -198,6 +198,7 @@ class QConfigLayout(QGridLayout): # END Class QConfigLayout + class QHelpLabel(QLabel): def __init__(self, theText, textCol, fontSize=0.9): @@ -223,6 +224,7 @@ class QHelpLabel(QLabel): # END Class QHelpLabel + # =============================================================================================== # # Switch Widget # =============================================================================================== # @@ -367,6 +369,7 @@ class QSwitch(QAbstractButton): # END Class QSwitch + # =============================================================================================== # # Paged Dialog w/Custom TabWidget # =============================================================================================== # @@ -417,6 +420,7 @@ class PagedDialog(QDialog): # END Class PagedDialog + class VerticalTabBar(QTabBar): def __init__(self, theParent=None): diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 32b50ebc..869ea1ed 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Document Editor ================================= @@ -57,6 +56,7 @@ from nw.gui.dochighlight import GuiDocHighlighter logger = logging.getLogger(__name__) + class GuiDocEditor(QTextEdit): MOVE_KEYS = ( @@ -1931,6 +1931,7 @@ class GuiDocEditor(QTextEdit): # END Class GuiDocEditor + # =============================================================================================== # # The Off-GUI Thread Word Counter # A runnable for the word counter to be run in the thread pool off the main GUI thread. @@ -1962,6 +1963,7 @@ class BackgroundWordCounter(QRunnable): ## END Class BackgroundWordCounter + class BackgroundWordCounterSignals(QObject): """The QRunnable cannot emit a signal, so we need a simple QObject to hold the word counter signal. @@ -1970,6 +1972,7 @@ class BackgroundWordCounterSignals(QObject): # END Class BackgroundWordCounterSignals + # =============================================================================================== # # The Embedded Document Search/Replace Feature # Only used by DocEditor, and is at a fixed position in the QTextEdit's viewport @@ -2345,6 +2348,7 @@ class GuiDocEditSearch(QFrame): # END Class GuiDocEditSearch + # =============================================================================================== # # The Embedded Document Header # Only used by DocEditor, and is at a fixed position in the QTextEdit's viewport @@ -2567,6 +2571,7 @@ class GuiDocEditHeader(QWidget): # END Class GuiDocEditHeader + # =============================================================================================== # # The Embedded Document Footer # Only used by DocEditor, and is at a fixed position in the QTextEdit's viewport diff --git a/nw/gui/dochighlight.py b/nw/gui/dochighlight.py index 95ed4759..193689e9 100644 --- a/nw/gui/dochighlight.py +++ b/nw/gui/dochighlight.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Syntax Highlighter ==================================== @@ -38,6 +37,7 @@ from nw.constants import nwRegEx, nwUnicode logger = logging.getLogger(__name__) + class GuiDocHighlighter(QSyntaxHighlighter): BLOCK_NONE = 0 diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index 00cb9ddb..2a82816f 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Document Viewer ================================= @@ -46,6 +45,7 @@ from nw.constants import nwUnicode logger = logging.getLogger(__name__) + class GuiDocViewer(QTextBrowser): def __init__(self, theParent): @@ -571,6 +571,7 @@ class GuiDocViewer(QTextBrowser): # END Class GuiDocViewer + class GuiDocViewHistory(): def __init__(self, docViewer): @@ -702,6 +703,7 @@ class GuiDocViewHistory(): # END Class GuiDocViewHistory + # =============================================================================================== # # The Embedded Document Header # Only used by DocViewer, and is at a fixed position in the QTextBrowser's viewport @@ -908,6 +910,7 @@ class GuiDocViewHeader(QWidget): # END Class GuiDocViewHeader + # =============================================================================================== # # The Embedded Document Footer # Only used by DocViewer, and is at a fixed position in the QTextBrowser's viewport @@ -1133,6 +1136,7 @@ class GuiDocViewFooter(QWidget): # END Class GuiDocViewFooter + # =============================================================================================== # # The Document Back-Reference Panel # Placed in a separate QSplitter position in the main GUI window diff --git a/nw/gui/itemdetails.py b/nw/gui/itemdetails.py index 7255affe..5ab8b640 100644 --- a/nw/gui/itemdetails.py +++ b/nw/gui/itemdetails.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Item Details Panel ==================================== @@ -36,6 +35,7 @@ from nw.constants import trConst, nwLabels logger = logging.getLogger(__name__) + class GuiItemDetails(QWidget): def __init__(self, theParent): diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index b9cf5e6e..3c94d854 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Main Menu =========================== @@ -36,6 +35,7 @@ from nw.constants import trConst, nwKeyWords, nwLabels, nwUnicode logger = logging.getLogger(__name__) + class GuiMainMenu(QMenuBar): def __init__(self, theParent): diff --git a/nw/gui/noveltree.py b/nw/gui/noveltree.py index fa65de23..dad63610 100644 --- a/nw/gui/noveltree.py +++ b/nw/gui/noveltree.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Novel Tree ============================ @@ -37,6 +36,7 @@ from nw.constants import nwKeyWords logger = logging.getLogger(__name__) + class GuiNovelTree(QTreeWidget): C_TITLE = 0 diff --git a/nw/gui/outline.py b/nw/gui/outline.py index 55359e52..88370a19 100644 --- a/nw/gui/outline.py +++ b/nw/gui/outline.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Project Outline ================================= @@ -39,6 +38,7 @@ from nw.constants import trConst, nwKeyWords, nwLabels logger = logging.getLogger(__name__) + class GuiOutline(QTreeWidget): DEF_WIDTH = { @@ -467,6 +467,7 @@ class GuiOutline(QTreeWidget): # END Class GuiOutline + class GuiOutlineHeaderMenu(QMenu): def __init__(self, theParent): diff --git a/nw/gui/outlinedetails.py b/nw/gui/outlinedetails.py index a4d032b5..ed5b1246 100644 --- a/nw/gui/outlinedetails.py +++ b/nw/gui/outlinedetails.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Project Outline Details ========================================= @@ -37,6 +36,7 @@ from nw.constants import trConst, nwKeyWords, nwLabels logger = logging.getLogger(__name__) + class GuiOutlineDetails(QScrollArea): LVL_MAP = { diff --git a/nw/gui/projdetails.py b/nw/gui/projdetails.py index 9fb13ef5..a780ea9f 100644 --- a/nw/gui/projdetails.py +++ b/nw/gui/projdetails.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Project Details ================================= @@ -41,6 +40,7 @@ from nw.gui.custom import PagedDialog, QSwitch logger = logging.getLogger(__name__) + class GuiProjectDetails(PagedDialog): def __init__(self, theParent): @@ -128,6 +128,7 @@ class GuiProjectDetails(PagedDialog): # END Class GuiProjectDetails + class GuiProjectDetailsMain(QWidget): def __init__(self, theParent, theProject): @@ -241,6 +242,7 @@ class GuiProjectDetailsMain(QWidget): # END Class GuiProjectDetailsMain + class GuiProjectDetailsContents(QWidget): C_TITLE = 0 diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py index 4f13fd55..71fdae90 100644 --- a/nw/gui/projtree.py +++ b/nw/gui/projtree.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Project Tree ============================== @@ -42,6 +41,7 @@ from nw.constants import nwConst, trConst, nwLists, nwLabels logger = logging.getLogger(__name__) + class GuiProjectTree(QTreeWidget): C_NAME = 0 @@ -1102,6 +1102,7 @@ class GuiProjectTree(QTreeWidget): # END Class GuiProjectTree + class GuiProjectTreeMenu(QMenu): def __init__(self, theTree): diff --git a/nw/gui/statusbar.py b/nw/gui/statusbar.py index 85a9f58c..4aac587c 100644 --- a/nw/gui/statusbar.py +++ b/nw/gui/statusbar.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Main Window Status Bar ======================================== @@ -38,6 +37,7 @@ from nw.enum import nwState logger = logging.getLogger(__name__) + class GuiMainStatus(QStatusBar): def __init__(self, theParent): @@ -235,6 +235,7 @@ class GuiMainStatus(QStatusBar): # END Class GuiMainStatus + class StatusLED(QAbstractButton): def __init__(self, colNone, colGood, colBad, sW, sH, parent=None): diff --git a/nw/gui/theme.py b/nw/gui/theme.py index 8f43141d..e808ab7e 100644 --- a/nw/gui/theme.py +++ b/nw/gui/theme.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – Theme and Icons Classes ===================================== @@ -43,6 +42,7 @@ from nw.enum import nwAlert logger = logging.getLogger(__name__) + # =============================================================================================== # # Gui Theme Class # Handles the look and feel of novelWriter @@ -496,6 +496,7 @@ class GuiTheme: # End Class GuiTheme + # =============================================================================================== # # Icons Class # =============================================================================================== # diff --git a/nw/guimain.py b/nw/guimain.py index 039f1100..97fbbd74 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Main Window ============================= @@ -55,6 +54,7 @@ from nw.constants import nwLists logger = logging.getLogger(__name__) + class GuiMain(QMainWindow): def __init__(self): diff --git a/nw/tools/__init__.py b/nw/tools/__init__.py index 18d825d2..0319d6b9 100644 --- a/nw/tools/__init__.py +++ b/nw/tools/__init__.py @@ -1,4 +1,23 @@ -# -*- coding: utf-8 -*- +""" +novelWriter – Tools Init +======================== + +This file is a part of novelWriter +Copyright 2018–2021, Veronica Berglyd Olsen + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +""" from nw.tools.build import GuiBuildNovel from nw.tools.projwizard import GuiProjectWizard diff --git a/nw/tools/build.py b/nw/tools/build.py index b64fe0bd..200766cc 100644 --- a/nw/tools/build.py +++ b/nw/tools/build.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Build Novel Project ===================================== @@ -52,6 +51,7 @@ from nw.gui.custom import QSwitch logger = logging.getLogger(__name__) + class GuiBuildNovel(QDialog): FMT_PDF = 1 # Print to PDF @@ -1182,6 +1182,7 @@ class GuiBuildNovel(QDialog): # END Class GuiBuildNovel + class GuiBuildNovelDocView(QTextBrowser): def __init__(self, theParent, theProject): diff --git a/nw/tools/projwizard.py b/nw/tools/projwizard.py index 81b885e8..846a67e8 100644 --- a/nw/tools/projwizard.py +++ b/nw/tools/projwizard.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI New Project Wizard ==================================== @@ -48,6 +47,7 @@ PAGE_POP = 2 PAGE_CUSTOM = 3 PAGE_FINAL = 4 + class GuiProjectWizard(QWizard): def __init__(self, theParent): @@ -86,6 +86,7 @@ class GuiProjectWizard(QWizard): # END Class GuiProjectWizard + class ProjWizardIntroPage(QWizardPage): def __init__(self, theWizard): @@ -155,6 +156,7 @@ class ProjWizardIntroPage(QWizardPage): # END Class ProjWizardIntroPage + class ProjWizardFolderPage(QWizardPage): def __init__(self, theWizard): @@ -227,6 +229,7 @@ class ProjWizardFolderPage(QWizardPage): # END Class ProjWizardFolderPage + class ProjWizardPopulatePage(QWizardPage): def __init__(self, theWizard): @@ -282,6 +285,7 @@ class ProjWizardPopulatePage(QWizardPage): # END Class ProjWizardPopulatePage + class ProjWizardCustomPage(QWizardPage): def __init__(self, theWizard): @@ -400,6 +404,7 @@ class ProjWizardCustomPage(QWizardPage): # END Class ProjWizardCustomPage + class ProjWizardFinalPage(QWizardPage): def __init__(self, theWizard): diff --git a/nw/tools/writingstats.py b/nw/tools/writingstats.py index 771870d7..5724f268 100644 --- a/nw/tools/writingstats.py +++ b/nw/tools/writingstats.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ novelWriter – GUI Writing Statistics ==================================== @@ -45,6 +44,7 @@ from nw.gui.custom import QSwitch logger = logging.getLogger(__name__) + class GuiWritingStats(QDialog): C_TIME = 0 diff --git a/setup.cfg b/setup.cfg index 8065eb87..e56bd120 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,6 +49,6 @@ gui_scripts = universal = 0 [flake8] -ignore = E203,E221,E226,E228,E241,E251,E261,E266,E302,E305 +ignore = E203,E221,E226,E228,E241,E251,E261,E266 max-line-length = 99 exclude = docs/*