Merge pull request #577 from vkbo/issue546_multipar_quotes
Issue #546: Multi-Paragraph Quotes
This commit is contained in:
@@ -142,6 +142,8 @@ class Config:
|
|||||||
self.bigDocLimit = 800 # Size threshold for heavy editor features in kilobytes
|
self.bigDocLimit = 800 # Size threshold for heavy editor features in kilobytes
|
||||||
|
|
||||||
self.highlightQuotes = True # Highlight text in quotes
|
self.highlightQuotes = True # Highlight text in quotes
|
||||||
|
self.allowOpenSQuote = False # Allow open-ended single quotes
|
||||||
|
self.allowOpenDQuote = True # Allow open-ended double quotes
|
||||||
self.highlightEmph = True # Add colour to text emphasis
|
self.highlightEmph = True # Add colour to text emphasis
|
||||||
|
|
||||||
## User-Selected Symbols
|
## User-Selected Symbols
|
||||||
@@ -520,6 +522,12 @@ class Config:
|
|||||||
self.highlightQuotes = self._parseLine(
|
self.highlightQuotes = self._parseLine(
|
||||||
cnfParse, cnfSec, "highlightquotes", self.CNF_BOOL, self.highlightQuotes
|
cnfParse, cnfSec, "highlightquotes", self.CNF_BOOL, self.highlightQuotes
|
||||||
)
|
)
|
||||||
|
self.allowOpenSQuote = self._parseLine(
|
||||||
|
cnfParse, cnfSec, "allowopensquote", self.CNF_BOOL, self.allowOpenSQuote
|
||||||
|
)
|
||||||
|
self.allowOpenDQuote = self._parseLine(
|
||||||
|
cnfParse, cnfSec, "allowopendquote", self.CNF_BOOL, self.allowOpenDQuote
|
||||||
|
)
|
||||||
self.highlightEmph = self._parseLine(
|
self.highlightEmph = self._parseLine(
|
||||||
cnfParse, cnfSec, "highlightemph", self.CNF_BOOL, self.highlightEmph
|
cnfParse, cnfSec, "highlightemph", self.CNF_BOOL, self.highlightEmph
|
||||||
)
|
)
|
||||||
@@ -575,6 +583,15 @@ class Config:
|
|||||||
# Check Certain Values for None
|
# Check Certain Values for None
|
||||||
self.spellLanguage = self._checkNone(self.spellLanguage)
|
self.spellLanguage = self._checkNone(self.spellLanguage)
|
||||||
|
|
||||||
|
# If we're using straight quotes, disable auto-replace
|
||||||
|
if self.fmtSingleQuotes == ["'", "'"] and self.doReplaceSQuote:
|
||||||
|
logger.info("Using straight single quotes, so disabling auto-replace")
|
||||||
|
self.doReplaceSQuote = False
|
||||||
|
|
||||||
|
if self.fmtDoubleQuotes == ["\"", "\""] and self.doReplaceDQuote:
|
||||||
|
logger.info("Using straight double quotes, so disabling auto-replace")
|
||||||
|
self.doReplaceDQuote = False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def saveConfig(self):
|
def saveConfig(self):
|
||||||
@@ -651,6 +668,8 @@ class Config:
|
|||||||
cnfParse.set(cnfSec, "bigdoclimit", str(self.bigDocLimit))
|
cnfParse.set(cnfSec, "bigdoclimit", str(self.bigDocLimit))
|
||||||
cnfParse.set(cnfSec, "showfullpath", str(self.showFullPath))
|
cnfParse.set(cnfSec, "showfullpath", str(self.showFullPath))
|
||||||
cnfParse.set(cnfSec, "highlightquotes", str(self.highlightQuotes))
|
cnfParse.set(cnfSec, "highlightquotes", str(self.highlightQuotes))
|
||||||
|
cnfParse.set(cnfSec, "allowopensquote", str(self.allowOpenSQuote))
|
||||||
|
cnfParse.set(cnfSec, "allowopendquote", str(self.allowOpenDQuote))
|
||||||
cnfParse.set(cnfSec, "highlightemph", str(self.highlightEmph))
|
cnfParse.set(cnfSec, "highlightemph", str(self.highlightEmph))
|
||||||
|
|
||||||
## Backup
|
## Backup
|
||||||
|
|||||||
+9
-3
@@ -143,15 +143,15 @@ class GuiDocEditor(QTextEdit):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Set Up Word Counter
|
# Set Up Word Counter
|
||||||
self.wcInterval = self.mainConf.wordCountTimer
|
|
||||||
self.wcTimer = QTimer()
|
self.wcTimer = QTimer()
|
||||||
self.wcTimer.setInterval(int(self.wcInterval*1000))
|
|
||||||
self.wcTimer.timeout.connect(self._runCounter)
|
self.wcTimer.timeout.connect(self._runCounter)
|
||||||
|
|
||||||
self.wCounter = BackgroundWordCounter(self)
|
self.wCounter = BackgroundWordCounter(self)
|
||||||
self.wCounter.setAutoDelete(False)
|
self.wCounter.setAutoDelete(False)
|
||||||
self.wCounter.signals.countsReady.connect(self._updateCounts)
|
self.wCounter.signals.countsReady.connect(self._updateCounts)
|
||||||
|
|
||||||
|
self.wcInterval = self.mainConf.wordCountTimer
|
||||||
|
|
||||||
self.initEditor()
|
self.initEditor()
|
||||||
|
|
||||||
logger.debug("GuiDocEditor initialisation complete")
|
logger.debug("GuiDocEditor initialisation complete")
|
||||||
@@ -258,6 +258,10 @@ class GuiDocEditor(QTextEdit):
|
|||||||
# Initialise the syntax highlighter
|
# Initialise the syntax highlighter
|
||||||
self.hLight.initHighlighter()
|
self.hLight.initHighlighter()
|
||||||
|
|
||||||
|
# Configure word count timer
|
||||||
|
self.wcInterval = self.mainConf.wordCountTimer
|
||||||
|
self.wcTimer.setInterval(int(self.wcInterval*1000))
|
||||||
|
|
||||||
# If we have a document open, we should reload it in case the
|
# If we have a document open, we should reload it in case the
|
||||||
# font changed, otherwise we just clear the editor entirely,
|
# font changed, otherwise we just clear the editor entirely,
|
||||||
# which makes it read only.
|
# which makes it read only.
|
||||||
@@ -1721,7 +1725,9 @@ class BackgroundWordCounter(QRunnable):
|
|||||||
## END Class BackgroundWordCounter
|
## END Class BackgroundWordCounter
|
||||||
|
|
||||||
class BackgroundWordCounterSignals(QObject):
|
class BackgroundWordCounterSignals(QObject):
|
||||||
|
"""The QRunnable cannot emit a signal, so we need a simple QObject
|
||||||
|
to hold the word counter signal.
|
||||||
|
"""
|
||||||
countsReady = pyqtSignal(int, int, int)
|
countsReady = pyqtSignal(int, int, int)
|
||||||
|
|
||||||
# END Class BackgroundWordCounterSignals
|
# END Class BackgroundWordCounterSignals
|
||||||
|
|||||||
+18
-11
@@ -147,22 +147,29 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
|||||||
|
|
||||||
# Quoted Strings
|
# Quoted Strings
|
||||||
if self.mainConf.highlightQuotes:
|
if self.mainConf.highlightQuotes:
|
||||||
fmtDO = self.mainConf.fmtDoubleQuotes[0]
|
fmtDbl = self.mainConf.fmtDoubleQuotes
|
||||||
fmtDC = self.mainConf.fmtDoubleQuotes[1]
|
fmtSng = self.mainConf.fmtSingleQuotes
|
||||||
fmtSO = self.mainConf.fmtSingleQuotes[0]
|
|
||||||
fmtSC = self.mainConf.fmtSingleQuotes[1]
|
# Straight Quotes
|
||||||
|
if fmtDbl != ["\"", "\""]:
|
||||||
|
self.hRules.append((
|
||||||
|
"(\\B\")(.*?)(\"\\B)", {
|
||||||
|
0 : self.hStyles["dialogue1"],
|
||||||
|
}
|
||||||
|
))
|
||||||
|
|
||||||
|
# Double Quotes
|
||||||
|
dblEnd = "|$" if self.mainConf.allowOpenDQuote else ""
|
||||||
self.hRules.append((
|
self.hRules.append((
|
||||||
"\\B\"(.*?)\"\\B", {
|
f"(\\B{fmtDbl[0]})(.*?)({fmtDbl[1]}\\B{dblEnd})", {
|
||||||
0 : self.hStyles["dialogue1"],
|
|
||||||
}
|
|
||||||
))
|
|
||||||
self.hRules.append((
|
|
||||||
f"\\B{fmtDO:s}(.*?){fmtDC:s}\\B", {
|
|
||||||
0 : self.hStyles["dialogue2"],
|
0 : self.hStyles["dialogue2"],
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|
||||||
|
# Single Quotes
|
||||||
|
sngEnd = "|$" if self.mainConf.allowOpenSQuote else ""
|
||||||
self.hRules.append((
|
self.hRules.append((
|
||||||
f"\\B{fmtSO:s}(.*?){fmtSC:s}\\B", {
|
f"(\\B{fmtSng[0]})(.*?)({fmtSng[1]}\\B{sngEnd})", {
|
||||||
0 : self.hStyles["dialogue3"],
|
0 : self.hStyles["dialogue3"],
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|||||||
+263
-228
@@ -31,13 +31,13 @@ import os
|
|||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
from PyQt5.QtGui import QFont
|
from PyQt5.QtGui import QFont
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QWidget, QComboBox, QSpinBox, QPushButton, QLineEdit, QMessageBox,
|
QDialog, QWidget, QComboBox, QSpinBox, QPushButton, QDialogButtonBox,
|
||||||
QDialogButtonBox, QFileDialog, QFontDialog
|
QLineEdit, QFileDialog, QFontDialog, QDoubleSpinBox
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.gui.custom import QSwitch, QConfigLayout, PagedDialog, QuotesDialog
|
from nw.gui.custom import QSwitch, QConfigLayout, PagedDialog, QuotesDialog
|
||||||
from nw.core import NWSpellSimple, NWSpellEnchant
|
from nw.core import NWSpellSimple, NWSpellEnchant
|
||||||
from nw.constants import nwConst
|
from nw.constants import nwConst, nwAlert
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -55,17 +55,19 @@ class GuiPreferences(PagedDialog):
|
|||||||
|
|
||||||
self.setWindowTitle("Preferences")
|
self.setWindowTitle("Preferences")
|
||||||
|
|
||||||
self.tabGeneral = GuiConfigEditGeneralTab(self.theParent)
|
self.tabGeneral = GuiPreferencesGeneral(self.theParent)
|
||||||
self.tabProjects = GuiConfigEditProjectsTab(self.theParent)
|
self.tabProjects = GuiPreferencesProjects(self.theParent)
|
||||||
self.tabLayout = GuiConfigEditLayoutTab(self.theParent)
|
self.tabDocs = GuiPreferencesDocuments(self.theParent)
|
||||||
self.tabEditing = GuiConfigEditEditingTab(self.theParent)
|
self.tabEditor = GuiPreferencesEditor(self.theParent)
|
||||||
self.tabAutoRep = GuiConfigEditAutoReplaceTab(self.theParent)
|
self.tabSyntax = GuiPreferencesSyntax(self.theParent)
|
||||||
|
self.tabAuto = GuiPreferencesAutomation(self.theParent)
|
||||||
|
|
||||||
self.addTab(self.tabGeneral, "General")
|
self.addTab(self.tabGeneral, "General")
|
||||||
self.addTab(self.tabProjects, "Projects")
|
self.addTab(self.tabProjects, "Projects")
|
||||||
self.addTab(self.tabLayout, "Text Layout")
|
self.addTab(self.tabDocs, "Documents")
|
||||||
self.addTab(self.tabEditing, "Editor")
|
self.addTab(self.tabEditor, "Editor")
|
||||||
self.addTab(self.tabAutoRep, "Auto-Replace")
|
self.addTab(self.tabSyntax, "Syntax")
|
||||||
|
self.addTab(self.tabAuto, "Automation")
|
||||||
|
|
||||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
||||||
self.buttonBox.accepted.connect(self._doSave)
|
self.buttonBox.accepted.connect(self._doSave)
|
||||||
@@ -84,53 +86,35 @@ class GuiPreferences(PagedDialog):
|
|||||||
"""Trigger all the save functions in the tabs, and collect the
|
"""Trigger all the save functions in the tabs, and collect the
|
||||||
status of the saves.
|
status of the saves.
|
||||||
"""
|
"""
|
||||||
logger.verbose("ConfigEditor save button clicked")
|
logger.debug("Saving new preferences")
|
||||||
|
|
||||||
validEntries = True
|
needsRestart = self.tabGeneral.saveValues()
|
||||||
needsRestart = False
|
|
||||||
|
|
||||||
retA, retB = self.tabGeneral.saveValues()
|
self.tabProjects.saveValues()
|
||||||
validEntries &= retA
|
self.tabDocs.saveValues()
|
||||||
needsRestart |= retB
|
self.tabEditor.saveValues()
|
||||||
|
self.tabSyntax.saveValues()
|
||||||
retA, retB = self.tabProjects.saveValues()
|
self.tabAuto.saveValues()
|
||||||
validEntries &= retA
|
|
||||||
needsRestart |= retB
|
|
||||||
|
|
||||||
retA, retB = self.tabLayout.saveValues()
|
|
||||||
validEntries &= retA
|
|
||||||
needsRestart |= retB
|
|
||||||
|
|
||||||
retA, retB = self.tabEditing.saveValues()
|
|
||||||
validEntries &= retA
|
|
||||||
needsRestart |= retB
|
|
||||||
|
|
||||||
retA, retB = self.tabAutoRep.saveValues()
|
|
||||||
validEntries &= retA
|
|
||||||
needsRestart |= retB
|
|
||||||
|
|
||||||
if needsRestart:
|
if needsRestart:
|
||||||
msgBox = QMessageBox()
|
self.theParent.makeAlert(
|
||||||
msgBox.information(
|
"Some changes will not be applied until novelWriter has been restarted.",
|
||||||
self, "Preferences",
|
nwAlert.INFO
|
||||||
"Some changes will not be applied until novelWriter has been restarted."
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if validEntries:
|
self.accept()
|
||||||
self.accept()
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _doClose(self):
|
def _doClose(self):
|
||||||
"""Close the preferences without saving the changes.
|
"""Close the preferences without saving the changes.
|
||||||
"""
|
"""
|
||||||
logger.verbose("ConfigEditor close button clicked")
|
|
||||||
self.reject()
|
self.reject()
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class GuiPreferences
|
# END Class GuiPreferences
|
||||||
|
|
||||||
class GuiConfigEditGeneralTab(QWidget):
|
class GuiPreferencesGeneral(QWidget):
|
||||||
|
|
||||||
def __init__(self, theParent):
|
def __init__(self, theParent):
|
||||||
QWidget.__init__(self, theParent)
|
QWidget.__init__(self, theParent)
|
||||||
@@ -250,21 +234,17 @@ class GuiConfigEditGeneralTab(QWidget):
|
|||||||
def saveValues(self):
|
def saveValues(self):
|
||||||
"""Save the values set for this tab.
|
"""Save the values set for this tab.
|
||||||
"""
|
"""
|
||||||
validEntries = True
|
|
||||||
needsRestart = False
|
|
||||||
|
|
||||||
guiTheme = self.selectTheme.currentData()
|
guiTheme = self.selectTheme.currentData()
|
||||||
guiIcons = self.selectIcons.currentData()
|
guiIcons = self.selectIcons.currentData()
|
||||||
guiDark = self.preferDarkIcons.isChecked()
|
guiDark = self.preferDarkIcons.isChecked()
|
||||||
guiFont = self.guiFont.text()
|
guiFont = self.guiFont.text()
|
||||||
guiFontSize = self.guiFontSize.value()
|
guiFontSize = self.guiFontSize.value()
|
||||||
showFullPath = self.showFullPath.isChecked()
|
|
||||||
hideVScroll = self.hideVScroll.isChecked()
|
|
||||||
hideHScroll = self.hideHScroll.isChecked()
|
|
||||||
|
|
||||||
# Check if restart is needed
|
# Check if restart is needed
|
||||||
|
needsRestart = False
|
||||||
needsRestart |= self.mainConf.guiTheme != guiTheme
|
needsRestart |= self.mainConf.guiTheme != guiTheme
|
||||||
needsRestart |= self.mainConf.guiIcons != guiIcons
|
needsRestart |= self.mainConf.guiIcons != guiIcons
|
||||||
|
needsRestart |= self.mainConf.guiDark != guiDark
|
||||||
needsRestart |= self.mainConf.guiFont != guiFont
|
needsRestart |= self.mainConf.guiFont != guiFont
|
||||||
needsRestart |= self.mainConf.guiFontSize != guiFontSize
|
needsRestart |= self.mainConf.guiFontSize != guiFontSize
|
||||||
|
|
||||||
@@ -273,13 +253,13 @@ class GuiConfigEditGeneralTab(QWidget):
|
|||||||
self.mainConf.guiDark = guiDark
|
self.mainConf.guiDark = guiDark
|
||||||
self.mainConf.guiFont = guiFont
|
self.mainConf.guiFont = guiFont
|
||||||
self.mainConf.guiFontSize = guiFontSize
|
self.mainConf.guiFontSize = guiFontSize
|
||||||
self.mainConf.showFullPath = showFullPath
|
self.mainConf.showFullPath = self.showFullPath.isChecked()
|
||||||
self.mainConf.hideVScroll = hideVScroll
|
self.mainConf.hideVScroll = self.hideVScroll.isChecked()
|
||||||
self.mainConf.hideHScroll = hideHScroll
|
self.mainConf.hideHScroll = self.hideHScroll.isChecked()
|
||||||
|
|
||||||
self.mainConf.confChanged = True
|
self.mainConf.confChanged = True
|
||||||
|
|
||||||
return validEntries, needsRestart
|
return needsRestart
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Slots
|
||||||
@@ -297,9 +277,9 @@ class GuiConfigEditGeneralTab(QWidget):
|
|||||||
self.guiFontSize.setValue(theFont.pointSize())
|
self.guiFontSize.setValue(theFont.pointSize())
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class GuiConfigEditGeneralTab
|
# END Class GuiPreferencesGeneral
|
||||||
|
|
||||||
class GuiConfigEditProjectsTab(QWidget):
|
class GuiPreferencesProjects(QWidget):
|
||||||
|
|
||||||
def __init__(self, theParent):
|
def __init__(self, theParent):
|
||||||
QWidget.__init__(self, theParent)
|
QWidget.__init__(self, theParent)
|
||||||
@@ -313,8 +293,8 @@ class GuiConfigEditProjectsTab(QWidget):
|
|||||||
self.mainForm.setHelpTextStyle(self.theTheme.helpText)
|
self.mainForm.setHelpTextStyle(self.theTheme.helpText)
|
||||||
self.setLayout(self.mainForm)
|
self.setLayout(self.mainForm)
|
||||||
|
|
||||||
# AutoSave Settings
|
# Automatic Save
|
||||||
# =================
|
# ==============
|
||||||
self.mainForm.addGroupLabel("Automatic Save")
|
self.mainForm.addGroupLabel("Automatic Save")
|
||||||
|
|
||||||
## Document Save Timer
|
## Document Save Timer
|
||||||
@@ -323,7 +303,7 @@ class GuiConfigEditProjectsTab(QWidget):
|
|||||||
self.autoSaveDoc.setMaximum(600)
|
self.autoSaveDoc.setMaximum(600)
|
||||||
self.autoSaveDoc.setSingleStep(1)
|
self.autoSaveDoc.setSingleStep(1)
|
||||||
self.autoSaveDoc.setValue(self.mainConf.autoSaveDoc)
|
self.autoSaveDoc.setValue(self.mainConf.autoSaveDoc)
|
||||||
self.backupPathRow = self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
"Save document interval",
|
"Save document interval",
|
||||||
self.autoSaveDoc,
|
self.autoSaveDoc,
|
||||||
"How often the open document is automatically saved.",
|
"How often the open document is automatically saved.",
|
||||||
@@ -336,15 +316,15 @@ class GuiConfigEditProjectsTab(QWidget):
|
|||||||
self.autoSaveProj.setMaximum(600)
|
self.autoSaveProj.setMaximum(600)
|
||||||
self.autoSaveProj.setSingleStep(1)
|
self.autoSaveProj.setSingleStep(1)
|
||||||
self.autoSaveProj.setValue(self.mainConf.autoSaveProj)
|
self.autoSaveProj.setValue(self.mainConf.autoSaveProj)
|
||||||
self.backupPathRow = self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
"Save project interval",
|
"Save project interval",
|
||||||
self.autoSaveProj,
|
self.autoSaveProj,
|
||||||
"How often the open project is automatically saved.",
|
"How often the open project is automatically saved.",
|
||||||
theUnit="seconds"
|
theUnit="seconds"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Backup Settings
|
# Project Backup
|
||||||
# ===============
|
# ==============
|
||||||
self.mainForm.addGroupLabel("Project Backup")
|
self.mainForm.addGroupLabel("Project Backup")
|
||||||
|
|
||||||
## Backup Path
|
## Backup Path
|
||||||
@@ -383,24 +363,18 @@ class GuiConfigEditProjectsTab(QWidget):
|
|||||||
def saveValues(self):
|
def saveValues(self):
|
||||||
"""Save the values set for this tab.
|
"""Save the values set for this tab.
|
||||||
"""
|
"""
|
||||||
validEntries = True
|
# Automatic Save
|
||||||
needsRestart = False
|
self.mainConf.autoSaveDoc = self.autoSaveDoc.value()
|
||||||
|
self.mainConf.autoSaveProj = self.autoSaveProj.value()
|
||||||
|
|
||||||
autoSaveDoc = self.autoSaveDoc.value()
|
# Project Backup
|
||||||
autoSaveProj = self.autoSaveProj.value()
|
self.mainConf.backupPath = self.backupPath
|
||||||
backupPath = self.backupPath
|
self.mainConf.backupOnClose = self.backupOnClose.isChecked()
|
||||||
backupOnClose = self.backupOnClose.isChecked()
|
self.mainConf.askBeforeBackup = self.askBeforeBackup.isChecked()
|
||||||
askBeforeBackup = self.askBeforeBackup.isChecked()
|
|
||||||
|
|
||||||
self.mainConf.autoSaveDoc = autoSaveDoc
|
|
||||||
self.mainConf.autoSaveProj = autoSaveProj
|
|
||||||
self.mainConf.backupPath = backupPath
|
|
||||||
self.mainConf.backupOnClose = backupOnClose
|
|
||||||
self.mainConf.askBeforeBackup = askBeforeBackup
|
|
||||||
|
|
||||||
self.mainConf.confChanged = True
|
self.mainConf.confChanged = True
|
||||||
|
|
||||||
return validEntries, needsRestart
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Slots
|
||||||
@@ -433,9 +407,9 @@ class GuiConfigEditProjectsTab(QWidget):
|
|||||||
self.askBeforeBackup.setEnabled(theState)
|
self.askBeforeBackup.setEnabled(theState)
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class GuiConfigEditProjectsTab
|
# END Class GuiPreferencesProjects
|
||||||
|
|
||||||
class GuiConfigEditLayoutTab(QWidget):
|
class GuiPreferencesDocuments(QWidget):
|
||||||
|
|
||||||
def __init__(self, theParent):
|
def __init__(self, theParent):
|
||||||
QWidget.__init__(self, theParent)
|
QWidget.__init__(self, theParent)
|
||||||
@@ -451,7 +425,7 @@ class GuiConfigEditLayoutTab(QWidget):
|
|||||||
|
|
||||||
# Text Style
|
# Text Style
|
||||||
# ==========
|
# ==========
|
||||||
self.mainForm.addGroupLabel("Document Text Style")
|
self.mainForm.addGroupLabel("Text Style")
|
||||||
|
|
||||||
## Font Family
|
## Font Family
|
||||||
self.textStyleFont = QLineEdit()
|
self.textStyleFont = QLineEdit()
|
||||||
@@ -483,7 +457,7 @@ class GuiConfigEditLayoutTab(QWidget):
|
|||||||
|
|
||||||
# Text Flow
|
# Text Flow
|
||||||
# =========
|
# =========
|
||||||
self.mainForm.addGroupLabel("Document Text Flow")
|
self.mainForm.addGroupLabel("Text Flow")
|
||||||
|
|
||||||
## Max Text Width in Normal Mode
|
## Max Text Width in Normal Mode
|
||||||
self.textFlowMax = QSpinBox(self)
|
self.textFlowMax = QSpinBox(self)
|
||||||
@@ -564,78 +538,27 @@ class GuiConfigEditLayoutTab(QWidget):
|
|||||||
theUnit="px"
|
theUnit="px"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Scroll Behaviour
|
|
||||||
# ================
|
|
||||||
self.mainForm.addGroupLabel("Scroll Behaviour")
|
|
||||||
|
|
||||||
## Scroll Past End
|
|
||||||
self.scrollPastEnd = QSwitch()
|
|
||||||
self.scrollPastEnd.setChecked(self.mainConf.scrollPastEnd)
|
|
||||||
self.mainForm.addRow(
|
|
||||||
"Scroll past end of the document",
|
|
||||||
self.scrollPastEnd,
|
|
||||||
"Allow scrolling until the last line is centred in the editor."
|
|
||||||
)
|
|
||||||
|
|
||||||
## Typewriter Scrolling
|
|
||||||
self.autoScroll = QSwitch()
|
|
||||||
self.autoScroll.setChecked(self.mainConf.autoScroll)
|
|
||||||
self.mainForm.addRow(
|
|
||||||
"Typewriter style scrolling when you type",
|
|
||||||
self.autoScroll,
|
|
||||||
"Try to keep the cursor at a fixed vertical position."
|
|
||||||
)
|
|
||||||
|
|
||||||
## Font Size
|
|
||||||
self.autoScrollPos = QSpinBox(self)
|
|
||||||
self.autoScrollPos.setMinimum(10)
|
|
||||||
self.autoScrollPos.setMaximum(90)
|
|
||||||
self.autoScrollPos.setSingleStep(1)
|
|
||||||
self.autoScrollPos.setValue(int(self.mainConf.autoScrollPos))
|
|
||||||
self.mainForm.addRow(
|
|
||||||
"Minimum position for Typewriter scrolling",
|
|
||||||
self.autoScrollPos,
|
|
||||||
"In units of percentage of the editor height.",
|
|
||||||
theUnit = "%"
|
|
||||||
)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def saveValues(self):
|
def saveValues(self):
|
||||||
"""Save the values set for this tab.
|
"""Save the values set for this tab.
|
||||||
"""
|
"""
|
||||||
validEntries = True
|
# Text Style
|
||||||
needsRestart = False
|
self.mainConf.textFont = self.textStyleFont.text()
|
||||||
|
self.mainConf.textSize = self.textStyleSize.value()
|
||||||
|
|
||||||
textFont = self.textStyleFont.text()
|
# Text Flow
|
||||||
textSize = self.textStyleSize.value()
|
self.mainConf.textWidth = self.textFlowMax.value()
|
||||||
textWidth = self.textFlowMax.value()
|
self.mainConf.focusWidth = self.focusDocWidth.value()
|
||||||
focusWidth = self.focusDocWidth.value()
|
self.mainConf.textFixedW = not self.textFlowFixed.isChecked()
|
||||||
textFixedW = not self.textFlowFixed.isChecked()
|
self.mainConf.hideFocusFooter = self.hideFocusFooter.isChecked()
|
||||||
hideFocusFooter = self.hideFocusFooter.isChecked()
|
self.mainConf.doJustify = self.textJustify.isChecked()
|
||||||
doJustify = self.textJustify.isChecked()
|
self.mainConf.textMargin = self.textMargin.value()
|
||||||
textMargin = self.textMargin.value()
|
self.mainConf.tabWidth = self.tabWidth.value()
|
||||||
tabWidth = self.tabWidth.value()
|
|
||||||
scrollPastEnd = self.scrollPastEnd.isChecked()
|
|
||||||
autoScroll = self.autoScroll.isChecked()
|
|
||||||
autoScrollPos = self.autoScrollPos.value()
|
|
||||||
|
|
||||||
self.mainConf.textFont = textFont
|
|
||||||
self.mainConf.textSize = textSize
|
|
||||||
self.mainConf.textWidth = textWidth
|
|
||||||
self.mainConf.focusWidth = focusWidth
|
|
||||||
self.mainConf.textFixedW = textFixedW
|
|
||||||
self.mainConf.hideFocusFooter = hideFocusFooter
|
|
||||||
self.mainConf.doJustify = doJustify
|
|
||||||
self.mainConf.textMargin = textMargin
|
|
||||||
self.mainConf.tabWidth = tabWidth
|
|
||||||
self.mainConf.scrollPastEnd = scrollPastEnd
|
|
||||||
self.mainConf.autoScroll = autoScroll
|
|
||||||
self.mainConf.autoScrollPos = autoScrollPos
|
|
||||||
|
|
||||||
self.mainConf.confChanged = True
|
self.mainConf.confChanged = True
|
||||||
|
|
||||||
return validEntries, needsRestart
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Slots
|
||||||
@@ -651,11 +574,12 @@ class GuiConfigEditLayoutTab(QWidget):
|
|||||||
if theStatus:
|
if theStatus:
|
||||||
self.textStyleFont.setText(theFont.family())
|
self.textStyleFont.setText(theFont.family())
|
||||||
self.textStyleSize.setValue(theFont.pointSize())
|
self.textStyleSize.setValue(theFont.pointSize())
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class GuiConfigEditLayoutTab
|
# END Class GuiPreferencesDocuments
|
||||||
|
|
||||||
class GuiConfigEditEditingTab(QWidget):
|
class GuiPreferencesEditor(QWidget):
|
||||||
|
|
||||||
def __init__(self, theParent):
|
def __init__(self, theParent):
|
||||||
QWidget.__init__(self, theParent)
|
QWidget.__init__(self, theParent)
|
||||||
@@ -669,42 +593,6 @@ class GuiConfigEditEditingTab(QWidget):
|
|||||||
self.mainForm.setHelpTextStyle(self.theTheme.helpText)
|
self.mainForm.setHelpTextStyle(self.theTheme.helpText)
|
||||||
self.setLayout(self.mainForm)
|
self.setLayout(self.mainForm)
|
||||||
|
|
||||||
# Spell Checking
|
|
||||||
# ==============
|
|
||||||
self.mainForm.addGroupLabel("Syntax Highlighting")
|
|
||||||
|
|
||||||
## Syntax Highlighting
|
|
||||||
self.selectSyntax = QComboBox()
|
|
||||||
self.selectSyntax.setMinimumWidth(self.mainConf.pxInt(200))
|
|
||||||
self.theSyntaxes = self.theTheme.listSyntax()
|
|
||||||
for syntaxFile, syntaxName in self.theSyntaxes:
|
|
||||||
self.selectSyntax.addItem(syntaxName, syntaxFile)
|
|
||||||
syntaxIdx = self.selectSyntax.findData(self.mainConf.guiSyntax)
|
|
||||||
if syntaxIdx != -1:
|
|
||||||
self.selectSyntax.setCurrentIndex(syntaxIdx)
|
|
||||||
|
|
||||||
self.mainForm.addRow(
|
|
||||||
"Highlight theme",
|
|
||||||
self.selectSyntax,
|
|
||||||
"Colour theme to apply to the editor and viewer."
|
|
||||||
)
|
|
||||||
|
|
||||||
self.highlightQuotes = QSwitch()
|
|
||||||
self.highlightQuotes.setChecked(self.mainConf.highlightQuotes)
|
|
||||||
self.mainForm.addRow(
|
|
||||||
"Highlight text wrapped in quotes",
|
|
||||||
self.highlightQuotes,
|
|
||||||
"Applies to single, double and straight quotes."
|
|
||||||
)
|
|
||||||
|
|
||||||
self.highlightEmph = QSwitch()
|
|
||||||
self.highlightEmph.setChecked(self.mainConf.highlightEmph)
|
|
||||||
self.mainForm.addRow(
|
|
||||||
"Add highlight colour to emphasised text",
|
|
||||||
self.highlightEmph,
|
|
||||||
"Applies to emphasis, strong and strikethrough."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Spell Checking
|
# Spell Checking
|
||||||
# ==============
|
# ==============
|
||||||
self.mainForm.addGroupLabel("Spell Checking")
|
self.mainForm.addGroupLabel("Spell Checking")
|
||||||
@@ -749,6 +637,24 @@ class GuiConfigEditEditingTab(QWidget):
|
|||||||
theUnit="kB"
|
theUnit="kB"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Word Count
|
||||||
|
# ==========
|
||||||
|
self.mainForm.addGroupLabel("Word Count")
|
||||||
|
|
||||||
|
## Word Count Timer
|
||||||
|
self.wordCountTimer = QDoubleSpinBox(self)
|
||||||
|
self.wordCountTimer.setDecimals(1)
|
||||||
|
self.wordCountTimer.setMinimum(2.0)
|
||||||
|
self.wordCountTimer.setMaximum(600.0)
|
||||||
|
self.wordCountTimer.setSingleStep(0.1)
|
||||||
|
self.wordCountTimer.setValue(self.mainConf.wordCountTimer)
|
||||||
|
self.mainForm.addRow(
|
||||||
|
"Word count interval",
|
||||||
|
self.wordCountTimer,
|
||||||
|
"How often the word count is updated.",
|
||||||
|
theUnit="seconds"
|
||||||
|
)
|
||||||
|
|
||||||
# Writing Guides
|
# Writing Guides
|
||||||
# ==============
|
# ==============
|
||||||
self.mainForm.addGroupLabel("Writing Guides")
|
self.mainForm.addGroupLabel("Writing Guides")
|
||||||
@@ -771,35 +677,66 @@ class GuiConfigEditEditingTab(QWidget):
|
|||||||
"Add a symbol to indicate line endings in the editor."
|
"Add a symbol to indicate line endings in the editor."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Scroll Behaviour
|
||||||
|
# ================
|
||||||
|
self.mainForm.addGroupLabel("Scroll Behaviour")
|
||||||
|
|
||||||
|
## Scroll Past End
|
||||||
|
self.scrollPastEnd = QSwitch()
|
||||||
|
self.scrollPastEnd.setChecked(self.mainConf.scrollPastEnd)
|
||||||
|
self.mainForm.addRow(
|
||||||
|
"Scroll past end of the document",
|
||||||
|
self.scrollPastEnd,
|
||||||
|
"Allow scrolling until the last line is centred in the editor."
|
||||||
|
)
|
||||||
|
|
||||||
|
## Typewriter Scrolling
|
||||||
|
self.autoScroll = QSwitch()
|
||||||
|
self.autoScroll.setChecked(self.mainConf.autoScroll)
|
||||||
|
self.mainForm.addRow(
|
||||||
|
"Typewriter style scrolling when you type",
|
||||||
|
self.autoScroll,
|
||||||
|
"Try to keep the cursor at a fixed vertical position."
|
||||||
|
)
|
||||||
|
|
||||||
|
## Typewriter Position
|
||||||
|
self.autoScrollPos = QSpinBox(self)
|
||||||
|
self.autoScrollPos.setMinimum(10)
|
||||||
|
self.autoScrollPos.setMaximum(90)
|
||||||
|
self.autoScrollPos.setSingleStep(1)
|
||||||
|
self.autoScrollPos.setValue(int(self.mainConf.autoScrollPos))
|
||||||
|
self.mainForm.addRow(
|
||||||
|
"Minimum position for Typewriter scrolling",
|
||||||
|
self.autoScrollPos,
|
||||||
|
"In units of percentage of the editor height.",
|
||||||
|
theUnit = "%"
|
||||||
|
)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def saveValues(self):
|
def saveValues(self):
|
||||||
"""Save the values set for this tab.
|
"""Save the values set for this tab.
|
||||||
"""
|
"""
|
||||||
validEntries = True
|
# Spell Checking
|
||||||
needsRestart = False
|
self.mainConf.spellTool = self.spellToolList.currentData()
|
||||||
|
self.mainConf.spellLanguage = self.spellLangList.currentData()
|
||||||
|
self.mainConf.bigDocLimit = self.bigDocLimit.value()
|
||||||
|
|
||||||
guiSyntax = self.selectSyntax.currentData()
|
# Word Count
|
||||||
highlightQuotes = self.highlightQuotes.isChecked()
|
self.mainConf.wordCountTimer = self.wordCountTimer.value()
|
||||||
highlightEmph = self.highlightEmph.isChecked()
|
|
||||||
spellTool = self.spellToolList.currentData()
|
|
||||||
spellLanguage = self.spellLangList.currentData()
|
|
||||||
bigDocLimit = self.bigDocLimit.value()
|
|
||||||
showTabsNSpaces = self.showTabsNSpaces.isChecked()
|
|
||||||
showLineEndings = self.showLineEndings.isChecked()
|
|
||||||
|
|
||||||
self.mainConf.guiSyntax = guiSyntax
|
# Writing Guides
|
||||||
self.mainConf.highlightQuotes = highlightQuotes
|
self.mainConf.showTabsNSpaces = self.showTabsNSpaces.isChecked()
|
||||||
self.mainConf.highlightEmph = highlightEmph
|
self.mainConf.showLineEndings = self.showLineEndings.isChecked()
|
||||||
self.mainConf.spellTool = spellTool
|
|
||||||
self.mainConf.spellLanguage = spellLanguage
|
# Scroll Behaviour
|
||||||
self.mainConf.bigDocLimit = bigDocLimit
|
self.mainConf.scrollPastEnd = self.scrollPastEnd.isChecked()
|
||||||
self.mainConf.showTabsNSpaces = showTabsNSpaces
|
self.mainConf.autoScroll = self.autoScroll.isChecked()
|
||||||
self.mainConf.showLineEndings = showLineEndings
|
self.mainConf.autoScrollPos = self.autoScrollPos.value()
|
||||||
|
|
||||||
self.mainConf.confChanged = True
|
self.mainConf.confChanged = True
|
||||||
|
|
||||||
return validEntries, needsRestart
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Internal Functions
|
# Internal Functions
|
||||||
@@ -833,9 +770,117 @@ class GuiConfigEditEditingTab(QWidget):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class GuiConfigEditEditingTab
|
# END Class GuiPreferencesEditor
|
||||||
|
|
||||||
class GuiConfigEditAutoReplaceTab(QWidget):
|
class GuiPreferencesSyntax(QWidget):
|
||||||
|
|
||||||
|
def __init__(self, theParent):
|
||||||
|
QWidget.__init__(self, theParent)
|
||||||
|
|
||||||
|
self.mainConf = nw.CONFIG
|
||||||
|
self.theParent = theParent
|
||||||
|
self.theTheme = theParent.theTheme
|
||||||
|
|
||||||
|
# The Form
|
||||||
|
self.mainForm = QConfigLayout()
|
||||||
|
self.mainForm.setHelpTextStyle(self.theTheme.helpText)
|
||||||
|
self.setLayout(self.mainForm)
|
||||||
|
|
||||||
|
# Highlighting Theme
|
||||||
|
# ==================
|
||||||
|
self.mainForm.addGroupLabel("Highlighting Theme")
|
||||||
|
|
||||||
|
self.selectSyntax = QComboBox()
|
||||||
|
self.selectSyntax.setMinimumWidth(self.mainConf.pxInt(200))
|
||||||
|
self.theSyntaxes = self.theTheme.listSyntax()
|
||||||
|
for syntaxFile, syntaxName in self.theSyntaxes:
|
||||||
|
self.selectSyntax.addItem(syntaxName, syntaxFile)
|
||||||
|
syntaxIdx = self.selectSyntax.findData(self.mainConf.guiSyntax)
|
||||||
|
if syntaxIdx != -1:
|
||||||
|
self.selectSyntax.setCurrentIndex(syntaxIdx)
|
||||||
|
|
||||||
|
self.mainForm.addRow(
|
||||||
|
"Highlighting theme",
|
||||||
|
self.selectSyntax,
|
||||||
|
"Colour theme to apply to the editor and viewer."
|
||||||
|
)
|
||||||
|
|
||||||
|
# Quotes & Dialogue
|
||||||
|
# =================
|
||||||
|
self.mainForm.addGroupLabel("Quotes & Dialogue")
|
||||||
|
|
||||||
|
self.highlightQuotes = QSwitch()
|
||||||
|
self.highlightQuotes.setChecked(self.mainConf.highlightQuotes)
|
||||||
|
self.highlightQuotes.toggled.connect(self._toggleHighlightQuotes)
|
||||||
|
self.mainForm.addRow(
|
||||||
|
"Highlight text wrapped in quotes",
|
||||||
|
self.highlightQuotes,
|
||||||
|
"Applies to single, double and straight quotes."
|
||||||
|
)
|
||||||
|
|
||||||
|
self.allowOpenSQuote = QSwitch()
|
||||||
|
self.allowOpenSQuote.setChecked(self.mainConf.allowOpenSQuote)
|
||||||
|
self.mainForm.addRow(
|
||||||
|
"Allow open-ended single quotes",
|
||||||
|
self.allowOpenSQuote,
|
||||||
|
"Highlight single-quoted line with no closing quote."
|
||||||
|
)
|
||||||
|
|
||||||
|
self.allowOpenDQuote = QSwitch()
|
||||||
|
self.allowOpenDQuote.setChecked(self.mainConf.allowOpenDQuote)
|
||||||
|
self.mainForm.addRow(
|
||||||
|
"Allow open-ended double quotes",
|
||||||
|
self.allowOpenDQuote,
|
||||||
|
"Highlight double-quoted line with no closing quote."
|
||||||
|
)
|
||||||
|
|
||||||
|
# Text Emphasis
|
||||||
|
# =============
|
||||||
|
self.mainForm.addGroupLabel("Text Emphasis")
|
||||||
|
|
||||||
|
self.highlightEmph = QSwitch()
|
||||||
|
self.highlightEmph.setChecked(self.mainConf.highlightEmph)
|
||||||
|
self.mainForm.addRow(
|
||||||
|
"Add highlight colour to emphasised text",
|
||||||
|
self.highlightEmph,
|
||||||
|
"Applies to emphasis (italic) and strong (bold)."
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def saveValues(self):
|
||||||
|
"""Save the values set for this tab.
|
||||||
|
"""
|
||||||
|
# Highlighting Theme
|
||||||
|
self.mainConf.guiSyntax = self.selectSyntax.currentData()
|
||||||
|
|
||||||
|
# Quotes & Dialogue
|
||||||
|
self.mainConf.highlightQuotes = self.highlightQuotes.isChecked()
|
||||||
|
self.mainConf.allowOpenSQuote = self.allowOpenSQuote.isChecked()
|
||||||
|
self.mainConf.allowOpenDQuote = self.allowOpenDQuote.isChecked()
|
||||||
|
|
||||||
|
# Text Emphasis
|
||||||
|
self.mainConf.highlightEmph = self.highlightEmph.isChecked()
|
||||||
|
|
||||||
|
self.mainConf.confChanged = True
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Slots
|
||||||
|
##
|
||||||
|
|
||||||
|
def _toggleHighlightQuotes(self, theState):
|
||||||
|
"""Enables or disables switches controlled by the highlight
|
||||||
|
quotes switch.
|
||||||
|
"""
|
||||||
|
self.allowOpenSQuote.setEnabled(theState)
|
||||||
|
self.allowOpenDQuote.setEnabled(theState)
|
||||||
|
return
|
||||||
|
|
||||||
|
# END Class GuiPreferencesSyntax
|
||||||
|
|
||||||
|
class GuiPreferencesAutomation(QWidget):
|
||||||
|
|
||||||
def __init__(self, theParent):
|
def __init__(self, theParent):
|
||||||
QWidget.__init__(self, theParent)
|
QWidget.__init__(self, theParent)
|
||||||
@@ -872,8 +917,8 @@ class GuiConfigEditAutoReplaceTab(QWidget):
|
|||||||
"Allow the editor to replace symbols as you type."
|
"Allow the editor to replace symbols as you type."
|
||||||
)
|
)
|
||||||
|
|
||||||
# Auto-Replace
|
# Replace as You Type
|
||||||
# ============
|
# ===================
|
||||||
self.mainForm.addGroupLabel("Replace as You Type")
|
self.mainForm.addGroupLabel("Replace as You Type")
|
||||||
|
|
||||||
## Auto-Replace Single Quotes
|
## Auto-Replace Single Quotes
|
||||||
@@ -913,7 +958,7 @@ class GuiConfigEditAutoReplaceTab(QWidget):
|
|||||||
self.mainForm.addRow(
|
self.mainForm.addRow(
|
||||||
"Auto-replace dots",
|
"Auto-replace dots",
|
||||||
self.autoReplaceDots,
|
self.autoReplaceDots,
|
||||||
"Three consecutive dots becomes ellipsis."
|
"Three consecutive dots become ellipsis."
|
||||||
)
|
)
|
||||||
|
|
||||||
# Quotation Style
|
# Quotation Style
|
||||||
@@ -995,36 +1040,25 @@ class GuiConfigEditAutoReplaceTab(QWidget):
|
|||||||
def saveValues(self):
|
def saveValues(self):
|
||||||
"""Save the values set for this tab.
|
"""Save the values set for this tab.
|
||||||
"""
|
"""
|
||||||
validEntries = True
|
# Automatic Features
|
||||||
needsRestart = False
|
self.mainConf.autoSelect = self.autoSelect.isChecked()
|
||||||
|
self.mainConf.doReplace = self.autoReplaceMain.isChecked()
|
||||||
|
|
||||||
autoSelect = self.autoSelect.isChecked()
|
# Replace as You Type
|
||||||
doReplace = self.autoReplaceMain.isChecked()
|
self.mainConf.doReplaceSQuote = self.autoReplaceSQ.isChecked()
|
||||||
doReplaceSQuote = self.autoReplaceSQ.isChecked()
|
self.mainConf.doReplaceDQuote = self.autoReplaceDQ.isChecked()
|
||||||
doReplaceDQuote = self.autoReplaceDQ.isChecked()
|
self.mainConf.doReplaceDash = self.autoReplaceDash.isChecked()
|
||||||
doReplaceDash = self.autoReplaceDash.isChecked()
|
self.mainConf.doReplaceDots = self.autoReplaceDots.isChecked()
|
||||||
doReplaceDots = self.autoReplaceDots.isChecked()
|
|
||||||
|
|
||||||
self.mainConf.autoSelect = autoSelect
|
# Quotation Style
|
||||||
self.mainConf.doReplace = doReplace
|
self.mainConf.fmtSingleQuotes[0] = self.quoteSym["SO"].text()
|
||||||
self.mainConf.doReplaceSQuote = doReplaceSQuote
|
self.mainConf.fmtSingleQuotes[1] = self.quoteSym["SC"].text()
|
||||||
self.mainConf.doReplaceDQuote = doReplaceDQuote
|
self.mainConf.fmtDoubleQuotes[0] = self.quoteSym["DO"].text()
|
||||||
self.mainConf.doReplaceDash = doReplaceDash
|
self.mainConf.fmtDoubleQuotes[1] = self.quoteSym["DC"].text()
|
||||||
self.mainConf.doReplaceDots = doReplaceDots
|
|
||||||
|
|
||||||
fmtSingleQuotesO = self.quoteSym["SO"].text()
|
|
||||||
fmtSingleQuotesC = self.quoteSym["SC"].text()
|
|
||||||
fmtDoubleQuotesO = self.quoteSym["DO"].text()
|
|
||||||
fmtDoubleQuotesC = self.quoteSym["DC"].text()
|
|
||||||
|
|
||||||
self.mainConf.fmtSingleQuotes[0] = fmtSingleQuotesO
|
|
||||||
self.mainConf.fmtSingleQuotes[1] = fmtSingleQuotesC
|
|
||||||
self.mainConf.fmtDoubleQuotes[0] = fmtDoubleQuotesO
|
|
||||||
self.mainConf.fmtDoubleQuotes[1] = fmtDoubleQuotesC
|
|
||||||
|
|
||||||
self.mainConf.confChanged = True
|
self.mainConf.confChanged = True
|
||||||
|
|
||||||
return validEntries, needsRestart
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Slots
|
||||||
@@ -1046,6 +1080,7 @@ class GuiConfigEditAutoReplaceTab(QWidget):
|
|||||||
qtBox = QuotesDialog(self, currentQuote=self.quoteSym[qType].text())
|
qtBox = QuotesDialog(self, currentQuote=self.quoteSym[qType].text())
|
||||||
if qtBox.exec_() == QDialog.Accepted:
|
if qtBox.exec_() == QDialog.Accepted:
|
||||||
self.quoteSym[qType].setText(qtBox.selectedQuote)
|
self.quoteSym[qType].setText(qtBox.selectedQuote)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class GuiConfigEditAutoReplaceTab
|
# END Class GuiPreferencesAutomation
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ showlineendings = False
|
|||||||
bigdoclimit = 800
|
bigdoclimit = 800
|
||||||
showfullpath = True
|
showfullpath = True
|
||||||
highlightquotes = True
|
highlightquotes = True
|
||||||
|
allowopensquote = False
|
||||||
|
allowopendquote = True
|
||||||
highlightemph = True
|
highlightemph = True
|
||||||
|
|
||||||
[Backup]
|
[Backup]
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ showlineendings = True
|
|||||||
bigdoclimit = 500
|
bigdoclimit = 500
|
||||||
showfullpath = False
|
showfullpath = False
|
||||||
highlightquotes = False
|
highlightquotes = False
|
||||||
|
allowopensquote = False
|
||||||
|
allowopendquote = True
|
||||||
highlightemph = False
|
highlightemph = False
|
||||||
|
|
||||||
[Backup]
|
[Backup]
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ def testBaseConfig_Constructor(monkeypatch):
|
|||||||
monkeypatch.undo()
|
monkeypatch.undo()
|
||||||
|
|
||||||
# Other
|
# Other
|
||||||
monkeypatch.setattr("sys.platform", "some_ther_os")
|
monkeypatch.setattr("sys.platform", "some_other_os")
|
||||||
tstConf = Config()
|
tstConf = Config()
|
||||||
assert tstConf.osLinux is False
|
assert tstConf.osLinux is False
|
||||||
assert tstConf.osDarwin is False
|
assert tstConf.osDarwin is False
|
||||||
@@ -170,6 +170,28 @@ def testBaseConfig_Init(monkeypatch, tmpDir, fncDir, outDir, refDir):
|
|||||||
assert tstConf.loadConfig()
|
assert tstConf.loadConfig()
|
||||||
assert tstConf.saveConfig()
|
assert tstConf.saveConfig()
|
||||||
|
|
||||||
|
# Test Correcting Quote Settings
|
||||||
|
origDbl = tstConf.fmtDoubleQuotes
|
||||||
|
origSng = tstConf.fmtSingleQuotes
|
||||||
|
orDoDbl = tstConf.doReplaceDQuote
|
||||||
|
orDoSng = tstConf.doReplaceSQuote
|
||||||
|
|
||||||
|
tstConf.fmtDoubleQuotes = ["\"", "\""]
|
||||||
|
tstConf.fmtSingleQuotes = ["'", "'"]
|
||||||
|
tstConf.doReplaceDQuote = True
|
||||||
|
tstConf.doReplaceSQuote = True
|
||||||
|
assert tstConf.saveConfig()
|
||||||
|
|
||||||
|
assert tstConf.loadConfig()
|
||||||
|
assert not tstConf.doReplaceDQuote
|
||||||
|
assert not tstConf.doReplaceSQuote
|
||||||
|
|
||||||
|
tstConf.fmtDoubleQuotes = origDbl
|
||||||
|
tstConf.fmtSingleQuotes = origSng
|
||||||
|
tstConf.doReplaceDQuote = orDoDbl
|
||||||
|
tstConf.doReplaceSQuote = orDoSng
|
||||||
|
assert tstConf.saveConfig()
|
||||||
|
|
||||||
copyfile(confFile, testFile)
|
copyfile(confFile, testFile)
|
||||||
assert cmpFiles(testFile, compFile, [2, 9])
|
assert cmpFiles(testFile, compFile, [2, 9])
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ from PyQt5.QtWidgets import (
|
|||||||
from nw.gui import GuiPreferences
|
from nw.gui import GuiPreferences
|
||||||
from nw.config import Config
|
from nw.config import Config
|
||||||
from nw.gui.custom import QuotesDialog
|
from nw.gui.custom import QuotesDialog
|
||||||
|
from nw.constants import nwConst
|
||||||
|
|
||||||
keyDelay = 2
|
keyDelay = 2
|
||||||
typeDelay = 1
|
typeDelay = 1
|
||||||
@@ -67,6 +68,7 @@ def testGuiPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
|
|||||||
|
|
||||||
theConf = nwGUI.mainConf
|
theConf = nwGUI.mainConf
|
||||||
assert theConf.confPath == fncDir
|
assert theConf.confPath == fncDir
|
||||||
|
theConf.spellTool = nwConst.SP_INTERNAL
|
||||||
|
|
||||||
monkeypatch.setattr(GuiPreferences, "exec_", lambda *args: None)
|
monkeypatch.setattr(GuiPreferences, "exec_", lambda *args: None)
|
||||||
monkeypatch.setattr(GuiPreferences, "result", lambda *args: QDialog.Accepted)
|
monkeypatch.setattr(GuiPreferences, "result", lambda *args: QDialog.Accepted)
|
||||||
@@ -78,7 +80,6 @@ def testGuiPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
|
|||||||
nwPrefs.show()
|
nwPrefs.show()
|
||||||
assert nwPrefs.mainConf.confPath == fncDir
|
assert nwPrefs.mainConf.confPath == fncDir
|
||||||
|
|
||||||
# qtbot.stopForInteraction()
|
|
||||||
# General Settings
|
# General Settings
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
tabGeneral = nwPrefs.tabGeneral
|
tabGeneral = nwPrefs.tabGeneral
|
||||||
@@ -122,6 +123,8 @@ def testGuiPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
|
|||||||
qtbot.mouseClick(tabProjects.backupOnClose, Qt.LeftButton)
|
qtbot.mouseClick(tabProjects.backupOnClose, Qt.LeftButton)
|
||||||
assert tabProjects.backupOnClose.isChecked()
|
assert tabProjects.backupOnClose.isChecked()
|
||||||
|
|
||||||
|
# qtbot.stopForInteraction()
|
||||||
|
|
||||||
# Check Browse button
|
# Check Browse button
|
||||||
monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *args, **kwargs: "")
|
monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *args, **kwargs: "")
|
||||||
assert not tabProjects._backupFolder()
|
assert not tabProjects._backupFolder()
|
||||||
@@ -132,98 +135,103 @@ def testGuiPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
|
|||||||
tabProjects.autoSaveDoc.setValue(20)
|
tabProjects.autoSaveDoc.setValue(20)
|
||||||
tabProjects.autoSaveProj.setValue(40)
|
tabProjects.autoSaveProj.setValue(40)
|
||||||
|
|
||||||
# Text Layout Settings
|
# Document Settings
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
tabLayout = nwPrefs.tabLayout
|
tabDocs = nwPrefs.tabDocs
|
||||||
nwPrefs._tabBox.setCurrentWidget(tabLayout)
|
nwPrefs._tabBox.setCurrentWidget(tabDocs)
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
qtbot.mouseClick(tabLayout.fontButton, Qt.LeftButton)
|
qtbot.mouseClick(tabDocs.fontButton, Qt.LeftButton)
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
tabLayout.textStyleSize.setValue(13)
|
tabDocs.textStyleSize.setValue(13)
|
||||||
tabLayout.textFlowMax.setValue(700)
|
tabDocs.textFlowMax.setValue(700)
|
||||||
tabLayout.focusDocWidth.setValue(900)
|
tabDocs.focusDocWidth.setValue(900)
|
||||||
tabLayout.textMargin.setValue(45)
|
tabDocs.textMargin.setValue(45)
|
||||||
tabLayout.tabWidth.setValue(45)
|
tabDocs.tabWidth.setValue(45)
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
assert not tabLayout.textFlowFixed.isChecked()
|
assert not tabDocs.textFlowFixed.isChecked()
|
||||||
qtbot.mouseClick(tabLayout.textFlowFixed, Qt.LeftButton)
|
qtbot.mouseClick(tabDocs.textFlowFixed, Qt.LeftButton)
|
||||||
assert tabLayout.textFlowFixed.isChecked()
|
assert tabDocs.textFlowFixed.isChecked()
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
assert not tabLayout.hideFocusFooter.isChecked()
|
assert not tabDocs.hideFocusFooter.isChecked()
|
||||||
qtbot.mouseClick(tabLayout.hideFocusFooter, Qt.LeftButton)
|
qtbot.mouseClick(tabDocs.hideFocusFooter, Qt.LeftButton)
|
||||||
assert tabLayout.hideFocusFooter.isChecked()
|
assert tabDocs.hideFocusFooter.isChecked()
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
assert tabLayout.textJustify.isChecked()
|
assert tabDocs.textJustify.isChecked()
|
||||||
qtbot.mouseClick(tabLayout.textJustify, Qt.LeftButton)
|
qtbot.mouseClick(tabDocs.textJustify, Qt.LeftButton)
|
||||||
assert not tabLayout.textJustify.isChecked()
|
assert not tabDocs.textJustify.isChecked()
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
|
||||||
assert tabLayout.scrollPastEnd.isChecked()
|
|
||||||
qtbot.mouseClick(tabLayout.scrollPastEnd, Qt.LeftButton)
|
|
||||||
assert not tabLayout.scrollPastEnd.isChecked()
|
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
|
||||||
assert not tabLayout.autoScroll.isChecked()
|
|
||||||
qtbot.mouseClick(tabLayout.autoScroll, Qt.LeftButton)
|
|
||||||
assert tabLayout.autoScroll.isChecked()
|
|
||||||
|
|
||||||
# Editor Settings
|
# Editor Settings
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
tabEditing = nwPrefs.tabEditing
|
tabEditor = nwPrefs.tabEditor
|
||||||
nwPrefs._tabBox.setCurrentWidget(tabEditing)
|
nwPrefs._tabBox.setCurrentWidget(tabEditor)
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
assert tabEditing.highlightQuotes.isChecked()
|
assert not tabEditor.showTabsNSpaces.isChecked()
|
||||||
qtbot.mouseClick(tabEditing.highlightQuotes, Qt.LeftButton)
|
qtbot.mouseClick(tabEditor.showTabsNSpaces, Qt.LeftButton)
|
||||||
assert not tabEditing.highlightQuotes.isChecked()
|
assert tabEditor.showTabsNSpaces.isChecked()
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
assert tabEditing.highlightEmph.isChecked()
|
assert not tabEditor.showLineEndings.isChecked()
|
||||||
qtbot.mouseClick(tabEditing.highlightEmph, Qt.LeftButton)
|
qtbot.mouseClick(tabEditor.showLineEndings, Qt.LeftButton)
|
||||||
assert not tabEditing.highlightEmph.isChecked()
|
assert tabEditor.showLineEndings.isChecked()
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
assert not tabEditing.showTabsNSpaces.isChecked()
|
assert tabEditor.scrollPastEnd.isChecked()
|
||||||
qtbot.mouseClick(tabEditing.showTabsNSpaces, Qt.LeftButton)
|
qtbot.mouseClick(tabEditor.scrollPastEnd, Qt.LeftButton)
|
||||||
assert tabEditing.showTabsNSpaces.isChecked()
|
assert not tabEditor.scrollPastEnd.isChecked()
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
assert not tabEditing.showLineEndings.isChecked()
|
assert not tabEditor.autoScroll.isChecked()
|
||||||
qtbot.mouseClick(tabEditing.showLineEndings, Qt.LeftButton)
|
qtbot.mouseClick(tabEditor.autoScroll, Qt.LeftButton)
|
||||||
assert tabEditing.showLineEndings.isChecked()
|
assert tabEditor.autoScroll.isChecked()
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
tabEditing.bigDocLimit.setValue(500)
|
tabEditor.bigDocLimit.setValue(500)
|
||||||
|
|
||||||
# Auto-Replace Settings
|
# Syntax Settings
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
tabAutoRep = nwPrefs.tabAutoRep
|
tabSyntax = nwPrefs.tabSyntax
|
||||||
nwPrefs._tabBox.setCurrentWidget(tabAutoRep)
|
nwPrefs._tabBox.setCurrentWidget(tabSyntax)
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
assert tabAutoRep.autoSelect.isChecked()
|
assert tabSyntax.highlightQuotes.isChecked()
|
||||||
qtbot.mouseClick(tabAutoRep.autoSelect, Qt.LeftButton)
|
qtbot.mouseClick(tabSyntax.highlightQuotes, Qt.LeftButton)
|
||||||
assert not tabAutoRep.autoSelect.isChecked()
|
assert not tabSyntax.highlightQuotes.isChecked()
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
assert tabAutoRep.autoReplaceMain.isChecked()
|
assert tabSyntax.highlightEmph.isChecked()
|
||||||
qtbot.mouseClick(tabAutoRep.autoReplaceMain, Qt.LeftButton)
|
qtbot.mouseClick(tabSyntax.highlightEmph, Qt.LeftButton)
|
||||||
assert not tabAutoRep.autoReplaceMain.isChecked()
|
assert not tabSyntax.highlightEmph.isChecked()
|
||||||
|
|
||||||
|
# Automation Settings
|
||||||
|
qtbot.wait(keyDelay)
|
||||||
|
tabAuto = nwPrefs.tabAuto
|
||||||
|
nwPrefs._tabBox.setCurrentWidget(tabAuto)
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
assert not tabAutoRep.autoReplaceSQ.isEnabled()
|
assert tabAuto.autoSelect.isChecked()
|
||||||
assert not tabAutoRep.autoReplaceDQ.isEnabled()
|
qtbot.mouseClick(tabAuto.autoSelect, Qt.LeftButton)
|
||||||
assert not tabAutoRep.autoReplaceDash.isEnabled()
|
assert not tabAuto.autoSelect.isChecked()
|
||||||
assert not tabAutoRep.autoReplaceDots.isEnabled()
|
|
||||||
|
qtbot.wait(keyDelay)
|
||||||
|
assert tabAuto.autoReplaceMain.isChecked()
|
||||||
|
qtbot.mouseClick(tabAuto.autoReplaceMain, Qt.LeftButton)
|
||||||
|
assert not tabAuto.autoReplaceMain.isChecked()
|
||||||
|
|
||||||
|
qtbot.wait(keyDelay)
|
||||||
|
assert not tabAuto.autoReplaceSQ.isEnabled()
|
||||||
|
assert not tabAuto.autoReplaceDQ.isEnabled()
|
||||||
|
assert not tabAuto.autoReplaceDash.isEnabled()
|
||||||
|
assert not tabAuto.autoReplaceDots.isEnabled()
|
||||||
|
|
||||||
monkeypatch.setattr(QuotesDialog, "selectedQuote", "'")
|
monkeypatch.setattr(QuotesDialog, "selectedQuote", "'")
|
||||||
monkeypatch.setattr(QuotesDialog, "exec_", lambda *args: QDialog.Accepted)
|
monkeypatch.setattr(QuotesDialog, "exec_", lambda *args: QDialog.Accepted)
|
||||||
qtbot.mouseClick(tabAutoRep.btnDoubleStyleC, Qt.LeftButton)
|
qtbot.mouseClick(tabAuto.btnDoubleStyleC, Qt.LeftButton)
|
||||||
|
|
||||||
# Save and Check Config
|
# Save and Check Config
|
||||||
qtbot.mouseClick(nwPrefs.buttonBox.button(QDialogButtonBox.Ok), Qt.LeftButton)
|
qtbot.mouseClick(nwPrefs.buttonBox.button(QDialogButtonBox.Ok), Qt.LeftButton)
|
||||||
|
|||||||
Reference in New Issue
Block a user