diff --git a/nw/gui/preferences.py b/nw/gui/preferences.py index e57519f2..cce7f1be 100644 --- a/nw/gui/preferences.py +++ b/nw/gui/preferences.py @@ -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 diff --git a/tests/test_gui/test_gui_preferences.py b/tests/test_gui/test_gui_preferences.py index 1611499d..70e5aba1 100644 --- a/tests/test_gui/test_gui_preferences.py +++ b/tests/test_gui/test_gui_preferences.py @@ -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)