Move quote symbols to new Preferences tab

This commit is contained in:
Veronica K. B. Olsen
2021-03-14 14:32:05 +01:00
parent 9f979c02f8
commit a172c4b725
2 changed files with 58 additions and 22 deletions
+52 -21
View File
@@ -61,6 +61,7 @@ class GuiPreferences(PagedDialog):
self.tabEditor = GuiPreferencesEditor(self.theParent)
self.tabSyntax = GuiPreferencesSyntax(self.theParent)
self.tabAuto = GuiPreferencesAutomation(self.theParent)
self.tabQuote = GuiPreferencesQuotes(self.theParent)
self.addTab(self.tabGeneral, self.tr("General"))
self.addTab(self.tabProjects, self.tr("Projects"))
@@ -68,6 +69,7 @@ class GuiPreferences(PagedDialog):
self.addTab(self.tabEditor, self.tr("Editor"))
self.addTab(self.tabSyntax, self.tr("Highlighting"))
self.addTab(self.tabAuto, self.tr("Automation"))
self.addTab(self.tabQuote, self.tr("Quotes"))
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.accepted.connect(self._doSave)
@@ -1034,6 +1036,55 @@ class GuiPreferencesAutomation(QWidget):
self.tr("Three consecutive dots become ellipsis.")
)
return
def saveValues(self):
"""Save the values set for this tab.
"""
# Automatic Features
self.mainConf.autoSelect = self.autoSelect.isChecked()
self.mainConf.doReplace = self.doReplace.isChecked()
# Replace as You Type
self.mainConf.doReplaceSQuote = self.doReplaceSQuote.isChecked()
self.mainConf.doReplaceDQuote = self.doReplaceDQuote.isChecked()
self.mainConf.doReplaceDash = self.doReplaceDash.isChecked()
self.mainConf.doReplaceDots = self.doReplaceDots.isChecked()
self.mainConf.confChanged = True
return
##
# Slots
##
def _toggleAutoReplaceMain(self, theState):
"""Enables or disables switches controlled by the main auto
replace switch.
"""
self.doReplaceSQuote.setEnabled(theState)
self.doReplaceDQuote.setEnabled(theState)
self.doReplaceDash.setEnabled(theState)
self.doReplaceDots.setEnabled(theState)
return
# END Class GuiPreferencesAutomation
class GuiPreferencesQuotes(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)
# Quotation Style
# ===============
self.mainForm.addGroupLabel(self.tr("Quotation Style"))
@@ -1113,16 +1164,6 @@ class GuiPreferencesAutomation(QWidget):
def saveValues(self):
"""Save the values set for this tab.
"""
# Automatic Features
self.mainConf.autoSelect = self.autoSelect.isChecked()
self.mainConf.doReplace = self.doReplace.isChecked()
# Replace as You Type
self.mainConf.doReplaceSQuote = self.doReplaceSQuote.isChecked()
self.mainConf.doReplaceDQuote = self.doReplaceDQuote.isChecked()
self.mainConf.doReplaceDash = self.doReplaceDash.isChecked()
self.mainConf.doReplaceDots = self.doReplaceDots.isChecked()
# Quotation Style
self.mainConf.fmtSingleQuotes[0] = self.quoteSym["SO"].text()
self.mainConf.fmtSingleQuotes[1] = self.quoteSym["SC"].text()
@@ -1137,16 +1178,6 @@ class GuiPreferencesAutomation(QWidget):
# Slots
##
def _toggleAutoReplaceMain(self, theState):
"""Enables or disables switches controlled by the main auto
replace switch.
"""
self.doReplaceSQuote.setEnabled(theState)
self.doReplaceDQuote.setEnabled(theState)
self.doReplaceDash.setEnabled(theState)
self.doReplaceDots.setEnabled(theState)
return
def _getQuote(self, qType):
"""Dialog for single quote open.
"""
@@ -1156,4 +1187,4 @@ class GuiPreferencesAutomation(QWidget):
return
# END Class GuiPreferencesAutomation
# END Class GuiPreferencesQuotes
+6 -1
View File
@@ -229,9 +229,14 @@ def testGuiPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
assert not tabAuto.doReplaceDash.isEnabled()
assert not tabAuto.doReplaceDots.isEnabled()
# Quotation Style
qtbot.wait(keyDelay)
tabQuote = nwPrefs.tabQuote
nwPrefs._tabBox.setCurrentWidget(tabQuote)
monkeypatch.setattr(QuotesDialog, "selectedQuote", "'")
monkeypatch.setattr(QuotesDialog, "exec_", lambda *args: QDialog.Accepted)
qtbot.mouseClick(tabAuto.btnDoubleStyleC, Qt.LeftButton)
qtbot.mouseClick(tabQuote.btnDoubleStyleC, Qt.LeftButton)
# Save and Check Config
qtbot.mouseClick(nwPrefs.buttonBox.button(QDialogButtonBox.Ok), Qt.LeftButton)