Moved config of spell check and qriting guides

This commit is contained in:
Veronica K. B. Olsen
2020-05-03 19:10:00 +02:00
parent 6c0c908989
commit 0e0b61be8c
+102 -80
View File
@@ -62,14 +62,14 @@ class GuiConfigEditor(QDialog):
self.tabGeneral = GuiConfigEditGeneralTab(self.theParent) self.tabGeneral = GuiConfigEditGeneralTab(self.theParent)
self.tabLayout = GuiConfigEditLayoutTab(self.theParent) self.tabLayout = GuiConfigEditLayoutTab(self.theParent)
self.tabMain = GuiConfigEditGeneral(self.theParent) self.tabEditing = GuiConfigEditEditingTab(self.theParent)
self.tabEditor = GuiConfigEditEditor(self.theParent) self.tabEditor = GuiConfigEditEditor(self.theParent)
self.tabWidget = QTabWidget() self.tabWidget = QTabWidget()
self.tabWidget.setMinimumWidth(600) self.tabWidget.setMinimumWidth(600)
self.tabWidget.addTab(self.tabGeneral, "General") self.tabWidget.addTab(self.tabGeneral, "General")
self.tabWidget.addTab(self.tabLayout, "Layout") self.tabWidget.addTab(self.tabLayout, "Layout")
self.tabWidget.addTab(self.tabMain, "General") self.tabWidget.addTab(self.tabEditing, "Editing")
self.tabWidget.addTab(self.tabEditor, "Editor") self.tabWidget.addTab(self.tabEditor, "Editor")
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
@@ -108,7 +108,7 @@ class GuiConfigEditor(QDialog):
validEntries &= retA validEntries &= retA
needsRestart |= retB needsRestart |= retB
retA, retB = self.tabMain.saveValues() retA, retB = self.tabEditing.saveValues()
validEntries &= retA validEntries &= retA
needsRestart |= retB needsRestart |= retB
@@ -183,7 +183,7 @@ class GuiConfigEditGeneralTab(QWidget):
self.mainForm.addRow( self.mainForm.addRow(
"Prefer icons for dark backgrounds", "Prefer icons for dark backgrounds",
self.preferDarkIcons, self.preferDarkIcons,
"May improve the look of icons on dark themes" "May improve the look of icons on dark themes."
) )
# AutoSave Settings # AutoSave Settings
@@ -233,7 +233,7 @@ class GuiConfigEditGeneralTab(QWidget):
self.mainForm.addRow( self.mainForm.addRow(
"Run backup when closing project", "Run backup when closing project",
self.backupOnClose, self.backupOnClose,
"This option can be overridden in project settings" "This option can be overridden in project settings."
) )
## Ask before backup ## Ask before backup
@@ -333,7 +333,7 @@ class GuiConfigEditLayoutTab(QWidget):
self.mainForm.addRow( self.mainForm.addRow(
"Font family", "Font family",
self.textStyleFont, self.textStyleFont,
"For the document editor and viewer" "For the document editor and viewer."
) )
self.textStyleSize = QSpinBox(self) self.textStyleSize = QSpinBox(self)
@@ -378,7 +378,7 @@ class GuiConfigEditLayoutTab(QWidget):
self.mainForm.addRow( self.mainForm.addRow(
"Disable maximum text width in Normal mode", "Disable maximum text width in Normal mode",
self.textFlowFixed, self.textFlowFixed,
"Only fixed margins are applied to the document" "Only fixed margins are applied to the document."
) )
self.textJustify = QSwitch() self.textJustify = QSwitch()
@@ -390,13 +390,13 @@ class GuiConfigEditLayoutTab(QWidget):
self.textMargin = QSpinBox(self) self.textMargin = QSpinBox(self)
self.textMargin.setMinimum(0) self.textMargin.setMinimum(0)
self.textMargin.setMaximum(2000) self.textMargin.setMaximum(900)
self.textMargin.setSingleStep(1) self.textMargin.setSingleStep(1)
self.textMargin.setValue(self.mainConf.textMargin) self.textMargin.setValue(self.mainConf.textMargin)
self.mainForm.addRow( self.mainForm.addRow(
"Document text margin", "Document text margin",
self.textMargin, self.textMargin,
"The minimum horizontal text margin if max with is enabled", "The minimum horizontal text margin if max with is enabled.",
theUnit="px" theUnit="px"
) )
@@ -408,10 +408,28 @@ class GuiConfigEditLayoutTab(QWidget):
self.mainForm.addRow( self.mainForm.addRow(
"Editor tab width", "Editor tab width",
self.tabWidth, self.tabWidth,
"This feature requires Qt 5.9 or later", "This feature requires Qt 5.9 or later.",
theUnit="px" theUnit="px"
) )
# Writing Guides
# ==============
self.mainForm.addGroupLabel("Writing Guides")
self.showTabsNSpaces = QSwitch()
self.showTabsNSpaces.setChecked(self.mainConf.showTabsNSpaces)
self.mainForm.addRow(
"Show tabs and spaces",
self.showTabsNSpaces
)
self.showLineEndings = QSwitch()
self.showLineEndings.setChecked(self.mainConf.showLineEndings)
self.mainForm.addRow(
"Show line endings",
self.showLineEndings
)
return return
def saveValues(self): def saveValues(self):
@@ -419,23 +437,27 @@ class GuiConfigEditLayoutTab(QWidget):
validEntries = True validEntries = True
needsRestart = False needsRestart = False
textFont = self.textStyleFont.currentFont().family() textFont = self.textStyleFont.currentFont().family()
textSize = self.textStyleSize.value() textSize = self.textStyleSize.value()
textWidth = self.textFlowMax.value() textWidth = self.textFlowMax.value()
zenWidth = self.zenDocWidth.value() zenWidth = self.zenDocWidth.value()
textFixedW = not self.textFlowFixed.isChecked() textFixedW = not self.textFlowFixed.isChecked()
doJustify = self.textJustify.isChecked() doJustify = self.textJustify.isChecked()
textMargin = self.textMargin.value() textMargin = self.textMargin.value()
tabWidth = self.tabWidth.value() tabWidth = self.tabWidth.value()
showTabsNSpaces = self.showTabsNSpaces.isChecked()
showLineEndings = self.showLineEndings.isChecked()
self.mainConf.textFont = textFont self.mainConf.textFont = textFont
self.mainConf.textSize = textSize self.mainConf.textSize = textSize
self.mainConf.textWidth = textWidth self.mainConf.textWidth = textWidth
self.mainConf.zenWidth = zenWidth self.mainConf.zenWidth = zenWidth
self.mainConf.textFixedW = textFixedW self.mainConf.textFixedW = textFixedW
self.mainConf.doJustify = doJustify self.mainConf.doJustify = doJustify
self.mainConf.textMargin = textMargin self.mainConf.textMargin = textMargin
self.mainConf.tabWidth = tabWidth self.mainConf.tabWidth = tabWidth
self.mainConf.showTabsNSpaces = showTabsNSpaces
self.mainConf.showLineEndings = showLineEndings
self.mainConf.confChanged = True self.mainConf.confChanged = True
@@ -443,7 +465,7 @@ class GuiConfigEditLayoutTab(QWidget):
# END Class GuiConfigEditLayoutTab # END Class GuiConfigEditLayoutTab
class GuiConfigEditGeneral(QWidget): class GuiConfigEditEditingTab(QWidget):
def __init__(self, theParent): def __init__(self, theParent):
QWidget.__init__(self, theParent) QWidget.__init__(self, theParent)
@@ -451,24 +473,27 @@ class GuiConfigEditGeneral(QWidget):
self.mainConf = nw.CONFIG self.mainConf = nw.CONFIG
self.theParent = theParent self.theParent = theParent
self.theTheme = theParent.theTheme self.theTheme = theParent.theTheme
self.outerBox = QGridLayout()
# The Form
self.mainForm = QConfigLayout()
self.mainForm.setHelpTextStyle(self.theTheme.helpText)
self.setLayout(self.mainForm)
# Spell Checking # Spell Checking
self.spellLang = QGroupBox("Spell Checker", self) # ==============
self.spellLangForm = QGridLayout(self) self.mainForm.addGroupLabel("Spell Checking")
self.spellLang.setLayout(self.spellLangForm)
self.spellLangList = QComboBox(self) self.spellLangList = QComboBox(self)
self.spellToolList = QComboBox(self) self.spellToolList = QComboBox(self)
self.spellToolList.addItem("Internal (difflib)", NWSpellCheck.SP_INTERNAL) self.spellToolList.addItem("Internal (difflib)", NWSpellCheck.SP_INTERNAL)
self.spellToolList.addItem("Spell Enchant (pyenchant)", NWSpellCheck.SP_ENCHANT) self.spellToolList.addItem("Spell Enchant (pyenchant)", NWSpellCheck.SP_ENCHANT)
self.spellToolList.addItem("SymSpell (symspellpy)", NWSpellCheck.SP_SYMSPELL) # self.spellToolList.addItem("SymSpell (symspellpy)", NWSpellCheck.SP_SYMSPELL)
theModel = self.spellToolList.model() theModel = self.spellToolList.model()
idEnchant = self.spellToolList.findData(NWSpellCheck.SP_ENCHANT) idEnchant = self.spellToolList.findData(NWSpellCheck.SP_ENCHANT)
idSymSpell = self.spellToolList.findData(NWSpellCheck.SP_SYMSPELL) # idSymSpell = self.spellToolList.findData(NWSpellCheck.SP_SYMSPELL)
theModel.item(idEnchant).setEnabled(self.mainConf.hasEnchant) theModel.item(idEnchant).setEnabled(self.mainConf.hasEnchant)
theModel.item(idSymSpell).setEnabled(self.mainConf.hasSymSpell) # theModel.item(idSymSpell).setEnabled(self.mainConf.hasSymSpell)
self.spellToolList.currentIndexChanged.connect(self._doUpdateSpellTool) self.spellToolList.currentIndexChanged.connect(self._doUpdateSpellTool)
toolIdx = self.spellToolList.findData(self.mainConf.spellTool) toolIdx = self.spellToolList.findData(self.mainConf.spellTool)
@@ -476,30 +501,27 @@ class GuiConfigEditGeneral(QWidget):
self.spellToolList.setCurrentIndex(toolIdx) self.spellToolList.setCurrentIndex(toolIdx)
self._doUpdateSpellTool(0) self._doUpdateSpellTool(0)
self.spellBigDoc = QSpinBox(self) self.mainForm.addRow(
self.spellBigDoc.setMinimum(10) "Spell check provider",
self.spellBigDoc.setMaximum(10000) self.spellToolList,
self.spellBigDoc.setSingleStep(10) "Note that the internal spell check tool is quite slow."
self.spellBigDoc.setToolTip(( )
"Disable spell checking when loading large documents. " self.mainForm.addRow(
"Spell checking will only run on paragraphs you edit." "Spell check language",
)) self.spellLangList
self.spellBigDoc.setValue(self.mainConf.bigDocLimit) )
self.spellLangForm.addWidget(QLabel("Provider"), 0, 0) self.bigDocLimit = QSpinBox(self)
self.spellLangForm.addWidget(self.spellToolList, 0, 1, 1, 3) self.bigDocLimit.setMinimum(10)
self.spellLangForm.addWidget(QLabel("Language"), 1, 0) self.bigDocLimit.setMaximum(10000)
self.spellLangForm.addWidget(self.spellLangList, 1, 1, 1, 3) self.bigDocLimit.setSingleStep(10)
self.spellLangForm.addWidget(QLabel("Size limit"), 2, 0) self.bigDocLimit.setValue(self.mainConf.bigDocLimit)
self.spellLangForm.addWidget(self.spellBigDoc, 2, 1) self.mainForm.addRow(
self.spellLangForm.addWidget(QLabel("kb"), 2, 2) "Big document limit",
self.spellLangForm.setColumnStretch(4, 1) self.bigDocLimit,
"Disables full spell checking over the size limit.",
# Assemble theUnit="kb"
self.outerBox.addWidget(self.spellLang, 1, 0) )
self.outerBox.setColumnStretch(1, 1)
self.outerBox.setRowStretch(4, 1)
self.setLayout(self.outerBox)
return return
@@ -508,13 +530,13 @@ class GuiConfigEditGeneral(QWidget):
validEntries = True validEntries = True
needsRestart = False needsRestart = False
spellTool = self.spellToolList.currentData() spellTool = self.spellToolList.currentData()
spellLanguage = self.spellLangList.currentData() spellLanguage = self.spellLangList.currentData()
bigDocLimit = self.spellBigDoc.value() bigDocLimit = self.bigDocLimit.value()
self.mainConf.spellTool = spellTool self.mainConf.spellTool = spellTool
self.mainConf.spellLanguage = spellLanguage self.mainConf.spellLanguage = spellLanguage
self.mainConf.bigDocLimit = bigDocLimit self.mainConf.bigDocLimit = bigDocLimit
self.mainConf.confChanged = True self.mainConf.confChanged = True
@@ -557,7 +579,7 @@ class GuiConfigEditGeneral(QWidget):
return return
# END Class GuiConfigEditGeneral # END Class GuiConfigEditEditingTab
class GuiConfigEditEditor(QWidget): class GuiConfigEditEditor(QWidget):
@@ -656,24 +678,24 @@ class GuiConfigEditEditor(QWidget):
self.quoteStyleForm.setColumnStretch(4, 1) self.quoteStyleForm.setColumnStretch(4, 1)
self.quoteStyleForm.setRowStretch(4, 1) self.quoteStyleForm.setRowStretch(4, 1)
# Writing Guides # # Writing Guides
self.showGuides = QGroupBox("Writing Guides", self) # self.showGuides = QGroupBox("Writing Guides", self)
self.showGuidesForm = QGridLayout(self) # self.showGuidesForm = QGridLayout(self)
self.showGuides.setLayout(self.showGuidesForm) # self.showGuides.setLayout(self.showGuidesForm)
self.showTabsNSpaces = QCheckBox("Show tabs and spaces",self) # self.showTabsNSpaces = QCheckBox("Show tabs and spaces",self)
self.showTabsNSpaces.setChecked(self.mainConf.showTabsNSpaces) # self.showTabsNSpaces.setChecked(self.mainConf.showTabsNSpaces)
self.showLineEndings = QCheckBox("Show line endings",self) # self.showLineEndings = QCheckBox("Show line endings",self)
self.showLineEndings.setChecked(self.mainConf.showLineEndings) # self.showLineEndings.setChecked(self.mainConf.showLineEndings)
self.showGuidesForm.addWidget(self.showTabsNSpaces, 0, 0) # self.showGuidesForm.addWidget(self.showTabsNSpaces, 0, 0)
self.showGuidesForm.addWidget(self.showLineEndings, 1, 0) # self.showGuidesForm.addWidget(self.showLineEndings, 1, 0)
# Assemble # Assemble
self.outerBox.addWidget(self.autoReplace, 3, 0, 2, 1) self.outerBox.addWidget(self.autoReplace, 3, 0, 2, 1)
self.outerBox.addWidget(self.quoteStyle, 2, 1, 2, 1) self.outerBox.addWidget(self.quoteStyle, 2, 1, 2, 1)
self.outerBox.addWidget(self.showGuides, 4, 1) # self.outerBox.addWidget(self.showGuides, 4, 1)
self.outerBox.setColumnStretch(2, 1) self.outerBox.setColumnStretch(2, 1)
self.outerBox.setRowStretch(5, 1) self.outerBox.setRowStretch(5, 1)
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
@@ -735,11 +757,11 @@ class GuiConfigEditEditor(QWidget):
) )
validEntries = False validEntries = False
showTabsNSpaces = self.showTabsNSpaces.isChecked() # showTabsNSpaces = self.showTabsNSpaces.isChecked()
showLineEndings = self.showLineEndings.isChecked() # showLineEndings = self.showLineEndings.isChecked()
self.mainConf.showTabsNSpaces = showTabsNSpaces # self.mainConf.showTabsNSpaces = showTabsNSpaces
self.mainConf.showLineEndings = showLineEndings # self.mainConf.showLineEndings = showLineEndings
self.mainConf.confChanged = True self.mainConf.confChanged = True