Make sure all code lines are within a 100 characters

This commit is contained in:
Veronica K. B. Olsen
2019-11-03 15:36:34 +01:00
parent f6bc1f32e5
commit 33e3b67ba5
17 changed files with 263 additions and 115 deletions
+3 -1
View File
@@ -407,7 +407,9 @@ class GuiConfigEditEditor(QWidget):
self.autoReplaceDQ.setCheckState(Qt.Unchecked)
self.autoReplaceDash = QCheckBox(self)
self.autoReplaceDash.setToolTip("Auto-replace double and triple hyphens with short and long dash.")
self.autoReplaceDash.setToolTip(
"Auto-replace double and triple hyphens with short and long dash."
)
if self.mainConf.doReplaceDash:
self.autoReplaceDash.setCheckState(Qt.Checked)
else:
+3 -1
View File
@@ -510,7 +510,9 @@ class GuiExportMain(QWidget):
self.fixedWidth.setMaximum(999)
self.fixedWidth.setSingleStep(1)
self.fixedWidth.setValue(self.optState.getSetting("fixWidth"))
self.fixedWidth.setToolTip("Applies to .txt and .md files. A value of '0' disables the feature.")
self.fixedWidth.setToolTip(
"Applies to .txt and .md files. A value of '0' disables the feature."
)
self.addSettingsForm.addWidget(QLabel("Fixed width"), 0, 0)
self.addSettingsForm.addWidget(self.fixedWidth, 0, 1)
+8 -6
View File
@@ -13,14 +13,16 @@
import logging
import nw
from os import path
from os import path
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtWidgets import QDialog, QHBoxLayout, QVBoxLayout, QGroupBox, QFormLayout, QLineEdit, QPushButton, QComboBox
from PyQt5.QtSvg import QSvgWidget
from PyQt5.QtWidgets import (
QDialog, QHBoxLayout, QVBoxLayout, QGroupBox, QFormLayout, QLineEdit, QPushButton, QComboBox
)
from nw.enum import nwItemLayout, nwItemClass, nwItemType
from nw.constants import nwLabels
from nw.enum import nwItemLayout, nwItemClass, nwItemType
from nw.constants import nwLabels
logger = logging.getLogger(__name__)
@@ -36,8 +38,8 @@ class GuiItemEditor(QDialog):
self.theParent = theParent
self.theItem = self.theProject.getItem(tHandle)
self.outerBox = QHBoxLayout()
self.innerBox = QVBoxLayout()
self.outerBox = QHBoxLayout()
self.innerBox = QVBoxLayout()
self.setWindowTitle("Item Settings")
+3 -1
View File
@@ -221,7 +221,9 @@ class GuiProjectEditStatus(QWidget):
def _selectColour(self):
logger.verbose("Item colour button clicked")
if self.selColour is not None:
newCol = QColorDialog.getColor(self.selColour, self, "Select Colour", QColorDialog.DontUseNativeDialog)
newCol = QColorDialog.getColor(
self.selColour, self, "Select Colour", QColorDialog.DontUseNativeDialog
)
if newCol:
self.selColour = newCol
colPixmap = QPixmap(16,16)
+6 -2
View File
@@ -70,8 +70,12 @@ class GuiSessionLogView(QDialog):
self.monoFont = QFont("Monospace",10)
sortValid = (Qt.AscendingOrder, Qt.DescendingOrder)
sortCol = self.optState.validIntRange(self.optState.getSetting("sortCol"), 0, 2, 0)
sortOrder = self.optState.validIntTuple(self.optState.getSetting("sortOrder"), sortValid, Qt.DescendingOrder)
sortCol = self.optState.validIntRange(
self.optState.getSetting("sortCol"), 0, 2, 0
)
sortOrder = self.optState.validIntTuple(
self.optState.getSetting("sortOrder"), sortValid, Qt.DescendingOrder
)
self.listBox.sortByColumn(sortCol, sortOrder)
self.listBox.setSortingEnabled(True)
+15 -10
View File
@@ -13,7 +13,8 @@
import logging
import nw
from os import path
from os import path
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon, QColor, QPixmap
from PyQt5.QtWidgets import (
@@ -41,21 +42,25 @@ class GuiTimeLineView(QDialog):
self.optState = TimeLineLastState(self.theProject,nwFiles.TLINE_OPT)
self.optState.loadSettings()
self.theMatrix = {}
self.numRows = 0
self.numCols = 0
self.theMatrix = {}
self.numRows = 0
self.numCols = 0
self.outerBox = QVBoxLayout()
self.filterBox = QVBoxLayout()
self.centreBox = QHBoxLayout()
self.bottomBox = QHBoxLayout()
self.outerBox = QVBoxLayout()
self.filterBox = QVBoxLayout()
self.centreBox = QHBoxLayout()
self.bottomBox = QHBoxLayout()
self.setWindowTitle("Timeline View")
self.setMinimumWidth(700)
self.setMinimumHeight(400)
winWidth = self.optState.validIntRange(self.optState.getSetting("winWidth"), 700, 10000, 700)
winHeight = self.optState.validIntRange(self.optState.getSetting("winHeight"), 400, 10000, 400)
winWidth = self.optState.validIntRange(
self.optState.getSetting("winWidth"), 700, 10000, 700
)
winHeight = self.optState.validIntRange(
self.optState.getSetting("winHeight"), 400, 10000, 400
)
self.resize(winWidth,winHeight)
# TimeLine Table
+21 -4
View File
@@ -82,9 +82,24 @@ class GuiDocEditor(QTextEdit):
self.setAcceptRichText(False)
# Custom Shortcuts
QShortcut(QKeySequence("Ctrl+."), self, context=Qt.WidgetShortcut, activated=self._openSpellContext)
QShortcut(Qt.Key_Return | Qt.ControlModifier, self, context=Qt.WidgetShortcut, activated=self._followTag)
QShortcut(Qt.Key_Enter | Qt.ControlModifier, self, context=Qt.WidgetShortcut, activated=self._followTag)
QShortcut(
QKeySequence("Ctrl+."),
self,
context = Qt.WidgetShortcut,
activated = self._openSpellContext
)
QShortcut(
Qt.Key_Return | Qt.ControlModifier,
self,
context = Qt.WidgetShortcut,
activated = self._followTag
)
QShortcut(
Qt.Key_Enter | Qt.ControlModifier,
self,
context = Qt.WidgetShortcut,
activated = self._followTag
)
# Set Up Word Count Thread and Timer
self.wcInterval = self.mainConf.wordCountTimer
@@ -459,7 +474,9 @@ class GuiDocEditor(QTextEdit):
if len(theSuggest) > 0:
for aWord in theSuggest:
mnuWord = QAction(aWord, mnuSuggest)
mnuWord.triggered.connect(lambda thePos, aWord=aWord : self._correctWord(theCursor, aWord))
mnuWord.triggered.connect(
lambda thePos, aWord=aWord : self._correctWord(theCursor, aWord)
)
mnuSuggest.addAction(mnuWord)
mnuSuggest.addSeparator()
mnuAdd = QAction("Add Word to Dictionary", mnuSuggest)
+9 -5
View File
@@ -18,8 +18,8 @@ from PyQt5.QtGui import QIcon, QFont, QColor
from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QAbstractItemView, QApplication
from nw.project.item import NWItem
from nw.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert
from nw.constants import nwLabels
from nw.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert
logger = logging.getLogger(__name__)
@@ -145,11 +145,15 @@ class GuiDocTree(QTreeWidget):
# If we again has no home, give up
if pHandle is None:
self.makeAlert("Did not find anywhere to add the file or folder!", nwAlert.ERROR)
self.makeAlert(
"Did not find anywhere to add the file or folder!", nwAlert.ERROR
)
return False
if pHandle == self.theProject.trashRoot:
self.makeAlert("Cannot add new files or folders to the trash folder.", nwAlert.ERROR)
self.makeAlert(
"Cannot add new files or folders to the trash folder.", nwAlert.ERROR
)
return False
# If we're still here, add the file or folder
@@ -295,10 +299,10 @@ class GuiDocTree(QTreeWidget):
tStatus += "."+nwLabels.LAYOUT_FLAG[nwItem.itemLayout]
iStatus = nwItem.itemStatus
if tClass == nwItemClass.NOVEL:
iStatus = self.theProject.statusItems.checkEntry(iStatus) # Make sure it's a valid index
iStatus = self.theProject.statusItems.checkEntry(iStatus) # Make sure it's valid
flagIcon = self.theParent.statusIcons[iStatus]
else:
iStatus = self.theProject.importItems.checkEntry(iStatus) # Make sure it's a valid index
iStatus = self.theProject.importItems.checkEntry(iStatus) # Make sure it's valid
flagIcon = self.theParent.importIcons[iStatus]
trItem.setText(self.C_NAME, tName)
+18 -18
View File
@@ -205,24 +205,24 @@ class GuiDocViewer(QTextBrowser):
).format(
textSize = self.mainConf.textSize,
preSize = self.mainConf.textSize*0.9,
tColR = self.theTheme.colText[0],
tColG = self.theTheme.colText[1],
tColB = self.theTheme.colText[2],
hColR = self.theTheme.colHead[0],
hColG = self.theTheme.colHead[1],
hColB = self.theTheme.colHead[2],
cColR = self.theTheme.colComm[0],
cColG = self.theTheme.colComm[1],
cColB = self.theTheme.colComm[2],
eColR = self.theTheme.colEmph[0],
eColG = self.theTheme.colEmph[1],
eColB = self.theTheme.colEmph[2],
aColR = self.theTheme.colVal[0],
aColG = self.theTheme.colVal[1],
aColB = self.theTheme.colVal[2],
kColR = self.theTheme.colKey[0],
kColG = self.theTheme.colKey[1],
kColB = self.theTheme.colKey[2],
tColR = self.theTheme.colText[0],
tColG = self.theTheme.colText[1],
tColB = self.theTheme.colText[2],
hColR = self.theTheme.colHead[0],
hColG = self.theTheme.colHead[1],
hColB = self.theTheme.colHead[2],
cColR = self.theTheme.colComm[0],
cColG = self.theTheme.colComm[1],
cColB = self.theTheme.colComm[2],
eColR = self.theTheme.colEmph[0],
eColG = self.theTheme.colEmph[1],
eColB = self.theTheme.colEmph[2],
aColR = self.theTheme.colVal[0],
aColG = self.theTheme.colVal[1],
aColB = self.theTheme.colVal[2],
kColR = self.theTheme.colKey[0],
kColG = self.theTheme.colKey[1],
kColB = self.theTheme.colKey[2],
)
self.qDocument.setDefaultStyleSheet(styleSheet)
+1 -1
View File
@@ -17,7 +17,7 @@ from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QFrame, QGridLayout, QLabel, QLineEdit, QPushButton, QApplication
from nw.enum import nwDocAction
from nw.enum import nwDocAction
logger = logging.getLogger(__name__)
+3 -1
View File
@@ -353,7 +353,9 @@ class GuiMainMenu(QMenuBar):
# Document > Show File Details
menuItem = QAction("Show File Details", self)
menuItem.setStatusTip("Shows a message box with the document location in the project folder")
menuItem.setStatusTip(
"Shows a message box with the document location in the project folder"
)
menuItem.triggered.connect(self._showDocumentLocation)
self.docuMenu.addAction(menuItem)
+40 -16
View File
@@ -63,10 +63,18 @@ class GuiMain(QMainWindow):
self.theIndex = NWIndex(self.theProject, self)
self.hasProject = False
logger.info("OS: %s" % (self.mainConf.osType))
logger.info("Qt5 Version: %s (%d)" % (self.mainConf.verQtString, self.mainConf.verQtValue))
logger.info("PyQt5 Version: %s (%d)" % (self.mainConf.verPyQtString, self.mainConf.verPyQtValue))
logger.info("Python Version: %s (0x%x)" % (self.mainConf.verPyString, self.mainConf.verPyHexVal))
logger.info("OS: %s" % (
self.mainConf.osType)
)
logger.info("Qt5 Version: %s (%d)" % (
self.mainConf.verQtString, self.mainConf.verQtValue)
)
logger.info("PyQt5 Version: %s (%d)" % (
self.mainConf.verPyQtString, self.mainConf.verPyQtValue)
)
logger.info("Python Version: %s (0x%x)" % (
self.mainConf.verPyString, self.mainConf.verPyHexVal)
)
self.resize(*self.mainConf.winGeometry)
self._setWindowTitle()
@@ -157,8 +165,17 @@ class GuiMain(QMainWindow):
self.asDocTimer.timeout.connect(self._autoSaveDocument)
# Keyboard Shortcuts
QShortcut(Qt.Key_Return, self.treeView, context=Qt.WidgetShortcut, activated=self._treeKeyPressReturn)
QShortcut(Qt.Key_Escape, self, activated=self._keyPressEscape)
QShortcut(
Qt.Key_Return,
self.treeView,
context = Qt.WidgetShortcut,
activated = self._treeKeyPressReturn
)
QShortcut(
Qt.Key_Escape,
self,
activated = self._keyPressEscape
)
# Forward Functions
self.setStatus = self.statusBar.setStatus
@@ -271,8 +288,8 @@ class GuiMain(QMainWindow):
return saveOK
def openProject(self, projFile=None):
"""Open a project.
projFile is passed from the open recent projects menu, so can be set. If not, we pop the dialog.
"""Open a project. The parameter projFile is passed from the open recent projects menu, so
can be set. If not, we pop the dialog.
"""
if projFile is None:
projFile = self.openProjectDialog()
@@ -415,20 +432,26 @@ class GuiMain(QMainWindow):
with open(loadFile,mode="rt",encoding="utf8") as inFile:
theText = inFile.read()
except Exception as e:
self.makeAlert(["Could not read file. The file cannot be a binary file.",str(e)], nwAlert.ERROR)
self.makeAlert(
["Could not read file. The file cannot be a binary file.",str(e)],
nwAlert.ERROR
)
return False
if self.docEditor.theHandle is None:
self.makeAlert(["Please open a document to import the text file into."], nwAlert.ERROR)
self.makeAlert(
["Please open a document to import the text file into."],
nwAlert.ERROR
)
return False
if not self.docEditor.isEmpty():
if self.mainConf.showGUI:
msgBox = QMessageBox()
msgRes = msgBox.question(
self, "Import Document",
"Importing the file will overwrite the current content of the document. Do you want to proceed?"
)
msgRes = msgBox.question(self, "Import Document",(
"Importing the file will overwrite the current content of the document. "
"Do you want to proceed?"
))
if msgRes != QMessageBox.Yes:
return False
else:
@@ -733,7 +756,8 @@ class GuiMain(QMainWindow):
##
def resizeEvent(self, theEvent):
"""Extend QMainWindow.resizeEvent to signal dependent GUI elements that its pane may have changed size.
"""Extend QMainWindow.resizeEvent to signal dependent GUI elements that its pane may have
changed size.
"""
QMainWindow.resizeEvent(self,theEvent)
self.docEditor.changeWidth()
@@ -779,7 +803,7 @@ class GuiMain(QMainWindow):
return
def _keyPressEscape(self):
"""When the escape key is pressed somewhere in the main window, do the following, in order
"""When the escape key is pressed somewhere in the main window, do the following, in order.
"""
if self.searchBar.isVisible():
self.searchBar.setVisible(False)