Add types to the Preferences dialog, and update tests
This commit is contained in:
@@ -26,7 +26,7 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from PyQt5.QtGui import QFont
|
from PyQt5.QtGui import QFont
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt, pyqtSlot
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QWidget, QComboBox, QSpinBox, QPushButton, QDialogButtonBox,
|
QDialog, QWidget, QComboBox, QSpinBox, QPushButton, QDialogButtonBox,
|
||||||
QLineEdit, QFileDialog, QFontDialog, QDoubleSpinBox
|
QLineEdit, QFileDialog, QFontDialog, QDoubleSpinBox
|
||||||
@@ -43,12 +43,11 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class GuiPreferences(NPagedDialog):
|
class GuiPreferences(NPagedDialog):
|
||||||
|
|
||||||
def __init__(self, mainGui):
|
def __init__(self, parent: QWidget) -> None:
|
||||||
super().__init__(parent=mainGui)
|
super().__init__(parent=parent)
|
||||||
|
|
||||||
logger.debug("Create: GuiPreferences")
|
logger.debug("Create: GuiPreferences")
|
||||||
self.setObjectName("GuiPreferences")
|
self.setObjectName("GuiPreferences")
|
||||||
|
|
||||||
self.setWindowTitle(self.tr("Preferences"))
|
self.setWindowTitle(self.tr("Preferences"))
|
||||||
|
|
||||||
self.tabGeneral = GuiPreferencesGeneral(self)
|
self.tabGeneral = GuiPreferencesGeneral(self)
|
||||||
@@ -93,26 +92,27 @@ class GuiPreferences(NPagedDialog):
|
|||||||
##
|
##
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def updateTheme(self):
|
def updateTheme(self) -> bool:
|
||||||
return self._updateTheme
|
return self._updateTheme
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def updateSyntax(self):
|
def updateSyntax(self) -> bool:
|
||||||
return self._updateSyntax
|
return self._updateSyntax
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def needsRestart(self):
|
def needsRestart(self) -> bool:
|
||||||
return self._needsRestart
|
return self._needsRestart
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def refreshTree(self):
|
def refreshTree(self) -> bool:
|
||||||
return self._refreshTree
|
return self._refreshTree
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Private Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
def _doSave(self):
|
@pyqtSlot()
|
||||||
|
def _doSave(self) -> None:
|
||||||
"""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.
|
||||||
"""
|
"""
|
||||||
@@ -132,9 +132,9 @@ class GuiPreferences(NPagedDialog):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _doClose(self):
|
@pyqtSlot()
|
||||||
"""Close the preferences without saving the changes.
|
def _doClose(self) -> None:
|
||||||
"""
|
"""Close the preferences without saving the changes."""
|
||||||
self._saveWindowSize()
|
self._saveWindowSize()
|
||||||
self.reject()
|
self.reject()
|
||||||
return
|
return
|
||||||
@@ -143,9 +143,8 @@ class GuiPreferences(NPagedDialog):
|
|||||||
# Internal Functions
|
# Internal Functions
|
||||||
##
|
##
|
||||||
|
|
||||||
def _saveWindowSize(self):
|
def _saveWindowSize(self) -> None:
|
||||||
"""Save the dialog window size.
|
"""Save the dialog window size."""
|
||||||
"""
|
|
||||||
CONFIG.setPreferencesWinSize(self.width(), self.height())
|
CONFIG.setPreferencesWinSize(self.width(), self.height())
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -154,7 +153,7 @@ class GuiPreferences(NPagedDialog):
|
|||||||
|
|
||||||
class GuiPreferencesGeneral(QWidget):
|
class GuiPreferencesGeneral(QWidget):
|
||||||
|
|
||||||
def __init__(self, prefsGui):
|
def __init__(self, prefsGui: GuiPreferences) -> None:
|
||||||
super().__init__(parent=prefsGui)
|
super().__init__(parent=prefsGui)
|
||||||
|
|
||||||
self.prefsGui = prefsGui
|
self.prefsGui = prefsGui
|
||||||
@@ -285,9 +284,8 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def saveValues(self):
|
def saveValues(self) -> None:
|
||||||
"""Save the values set for this tab.
|
"""Save the values set for this tab."""
|
||||||
"""
|
|
||||||
guiLocale = self.guiLocale.currentData()
|
guiLocale = self.guiLocale.currentData()
|
||||||
guiTheme = self.guiTheme.currentData()
|
guiTheme = self.guiTheme.currentData()
|
||||||
guiSyntax = self.guiSyntax.currentData()
|
guiSyntax = self.guiSyntax.currentData()
|
||||||
@@ -316,12 +314,12 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Private Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
def _selectFont(self):
|
@pyqtSlot()
|
||||||
"""Open the QFontDialog and set a font for the font style.
|
def _selectFont(self) -> None:
|
||||||
"""
|
"""Open the QFontDialog and set a font for the font style."""
|
||||||
currFont = QFont()
|
currFont = QFont()
|
||||||
currFont.setFamily(CONFIG.guiFont)
|
currFont.setFamily(CONFIG.guiFont)
|
||||||
currFont.setPointSize(CONFIG.guiFontSize)
|
currFont.setPointSize(CONFIG.guiFontSize)
|
||||||
@@ -336,7 +334,7 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
|
|
||||||
class GuiPreferencesProjects(QWidget):
|
class GuiPreferencesProjects(QWidget):
|
||||||
|
|
||||||
def __init__(self, prefsGui):
|
def __init__(self, prefsGui: GuiPreferences) -> None:
|
||||||
super().__init__(parent=prefsGui)
|
super().__init__(parent=prefsGui)
|
||||||
|
|
||||||
# The Form
|
# The Form
|
||||||
@@ -438,9 +436,8 @@ class GuiPreferencesProjects(QWidget):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def saveValues(self):
|
def saveValues(self) -> None:
|
||||||
"""Save the values set for this tab.
|
"""Save the values set for this tab."""
|
||||||
"""
|
|
||||||
# Automatic Save
|
# Automatic Save
|
||||||
CONFIG.autoSaveDoc = self.autoSaveDoc.value()
|
CONFIG.autoSaveDoc = self.autoSaveDoc.value()
|
||||||
CONFIG.autoSaveProj = self.autoSaveProj.value()
|
CONFIG.autoSaveProj = self.autoSaveProj.value()
|
||||||
@@ -457,12 +454,12 @@ class GuiPreferencesProjects(QWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Private Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
def _backupFolder(self):
|
@pyqtSlot()
|
||||||
"""Open a dialog to select the backup folder.
|
def _backupFolder(self) -> None:
|
||||||
"""
|
"""Open a dialog to select the backup folder."""
|
||||||
currDir = self.backupPath or ""
|
currDir = self.backupPath or ""
|
||||||
newDir = QFileDialog.getExistingDirectory(
|
newDir = QFileDialog.getExistingDirectory(
|
||||||
self, self.tr("Backup Directory"), str(currDir), options=QFileDialog.ShowDirsOnly
|
self, self.tr("Backup Directory"), str(currDir), options=QFileDialog.ShowDirsOnly
|
||||||
@@ -472,15 +469,13 @@ class GuiPreferencesProjects(QWidget):
|
|||||||
self.mainForm.setHelpText(
|
self.mainForm.setHelpText(
|
||||||
self.backupPathRow, self.tr("Path: {0}").format(self.backupPath)
|
self.backupPathRow, self.tr("Path: {0}").format(self.backupPath)
|
||||||
)
|
)
|
||||||
return True
|
return
|
||||||
|
return
|
||||||
|
|
||||||
return False
|
@pyqtSlot(bool)
|
||||||
|
def _toggledBackupOnClose(self, state: bool) -> None:
|
||||||
def _toggledBackupOnClose(self, theState):
|
"""Toggle switch that depends on the backup on close switch."""
|
||||||
"""Enable or disable switch that depends on the backup on close
|
self.askBeforeBackup.setEnabled(state)
|
||||||
switch.
|
|
||||||
"""
|
|
||||||
self.askBeforeBackup.setEnabled(theState)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class GuiPreferencesProjects
|
# END Class GuiPreferencesProjects
|
||||||
@@ -488,7 +483,7 @@ class GuiPreferencesProjects(QWidget):
|
|||||||
|
|
||||||
class GuiPreferencesDocuments(QWidget):
|
class GuiPreferencesDocuments(QWidget):
|
||||||
|
|
||||||
def __init__(self, prefsGui):
|
def __init__(self, prefsGui: GuiPreferences) -> None:
|
||||||
super().__init__(parent=prefsGui)
|
super().__init__(parent=prefsGui)
|
||||||
|
|
||||||
# The Form
|
# The Form
|
||||||
@@ -604,9 +599,8 @@ class GuiPreferencesDocuments(QWidget):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def saveValues(self):
|
def saveValues(self) -> None:
|
||||||
"""Save the values set for this tab.
|
"""Save the values set for this tab."""
|
||||||
"""
|
|
||||||
# Text Style
|
# Text Style
|
||||||
CONFIG.setTextFont(self.textFont.text(), self.textSize.value())
|
CONFIG.setTextFont(self.textFont.text(), self.textSize.value())
|
||||||
|
|
||||||
@@ -621,12 +615,12 @@ class GuiPreferencesDocuments(QWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Private Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _selectFont(self):
|
def _selectFont(self):
|
||||||
"""Open the QFontDialog and set a font for the font style.
|
"""Open the QFontDialog and set a font for the font style."""
|
||||||
"""
|
|
||||||
currFont = QFont()
|
currFont = QFont()
|
||||||
currFont.setFamily(CONFIG.textFont)
|
currFont.setFamily(CONFIG.textFont)
|
||||||
currFont.setPointSize(CONFIG.textSize)
|
currFont.setPointSize(CONFIG.textSize)
|
||||||
@@ -642,7 +636,7 @@ class GuiPreferencesDocuments(QWidget):
|
|||||||
|
|
||||||
class GuiPreferencesEditor(QWidget):
|
class GuiPreferencesEditor(QWidget):
|
||||||
|
|
||||||
def __init__(self, prefsGui):
|
def __init__(self, prefsGui: GuiPreferences) -> None:
|
||||||
super().__init__(parent=prefsGui)
|
super().__init__(parent=prefsGui)
|
||||||
|
|
||||||
# The Form
|
# The Form
|
||||||
@@ -759,7 +753,7 @@ class GuiPreferencesEditor(QWidget):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def saveValues(self):
|
def saveValues(self) -> None:
|
||||||
"""Save the values set for this tab."""
|
"""Save the values set for this tab."""
|
||||||
# Spell Checking
|
# Spell Checking
|
||||||
CONFIG.spellLanguage = self.spellLanguage.currentData()
|
CONFIG.spellLanguage = self.spellLanguage.currentData()
|
||||||
@@ -784,7 +778,7 @@ class GuiPreferencesEditor(QWidget):
|
|||||||
|
|
||||||
class GuiPreferencesSyntax(QWidget):
|
class GuiPreferencesSyntax(QWidget):
|
||||||
|
|
||||||
def __init__(self, prefsGui):
|
def __init__(self, prefsGui: GuiPreferences) -> None:
|
||||||
super().__init__(parent=prefsGui)
|
super().__init__(parent=prefsGui)
|
||||||
|
|
||||||
self.prefsGui = prefsGui
|
self.prefsGui = prefsGui
|
||||||
@@ -850,9 +844,8 @@ class GuiPreferencesSyntax(QWidget):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def saveValues(self):
|
def saveValues(self) -> None:
|
||||||
"""Save the values set for this tab.
|
"""Save the values set for this tab."""
|
||||||
"""
|
|
||||||
highlightQuotes = self.highlightQuotes.isChecked()
|
highlightQuotes = self.highlightQuotes.isChecked()
|
||||||
allowOpenSQuote = self.allowOpenSQuote.isChecked()
|
allowOpenSQuote = self.allowOpenSQuote.isChecked()
|
||||||
allowOpenDQuote = self.allowOpenDQuote.isChecked()
|
allowOpenDQuote = self.allowOpenDQuote.isChecked()
|
||||||
@@ -872,15 +865,14 @@ class GuiPreferencesSyntax(QWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Private Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
def _toggleHighlightQuotes(self, theState):
|
@pyqtSlot(bool)
|
||||||
"""Enables or disables switches controlled by the highlight
|
def _toggleHighlightQuotes(self, state: bool) -> None:
|
||||||
quotes switch.
|
"""Toggle switches controlled by the highlight quotes switch."""
|
||||||
"""
|
self.allowOpenSQuote.setEnabled(state)
|
||||||
self.allowOpenSQuote.setEnabled(theState)
|
self.allowOpenDQuote.setEnabled(state)
|
||||||
self.allowOpenDQuote.setEnabled(theState)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class GuiPreferencesSyntax
|
# END Class GuiPreferencesSyntax
|
||||||
@@ -888,7 +880,7 @@ class GuiPreferencesSyntax(QWidget):
|
|||||||
|
|
||||||
class GuiPreferencesAutomation(QWidget):
|
class GuiPreferencesAutomation(QWidget):
|
||||||
|
|
||||||
def __init__(self, prefsGui):
|
def __init__(self, prefsGui: GuiPreferences) -> None:
|
||||||
super().__init__(parent=prefsGui)
|
super().__init__(parent=prefsGui)
|
||||||
|
|
||||||
# The Form
|
# The Form
|
||||||
@@ -999,9 +991,8 @@ class GuiPreferencesAutomation(QWidget):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def saveValues(self):
|
def saveValues(self) -> None:
|
||||||
"""Save the values set for this tab.
|
"""Save the values set for this tab."""
|
||||||
"""
|
|
||||||
# Automatic Features
|
# Automatic Features
|
||||||
CONFIG.autoSelect = self.autoSelect.isChecked()
|
CONFIG.autoSelect = self.autoSelect.isChecked()
|
||||||
CONFIG.doReplace = self.doReplace.isChecked()
|
CONFIG.doReplace = self.doReplace.isChecked()
|
||||||
@@ -1020,18 +1011,17 @@ class GuiPreferencesAutomation(QWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Private Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
def _toggleAutoReplaceMain(self, theState):
|
@pyqtSlot(bool)
|
||||||
"""Enables or disables switches controlled by the main auto
|
def _toggleAutoReplaceMain(self, state: bool) -> None:
|
||||||
replace switch.
|
"""Toggle switches controlled by the auto replace switch."""
|
||||||
"""
|
self.doReplaceSQuote.setEnabled(state)
|
||||||
self.doReplaceSQuote.setEnabled(theState)
|
self.doReplaceDQuote.setEnabled(state)
|
||||||
self.doReplaceDQuote.setEnabled(theState)
|
self.doReplaceDash.setEnabled(state)
|
||||||
self.doReplaceDash.setEnabled(theState)
|
self.doReplaceDots.setEnabled(state)
|
||||||
self.doReplaceDots.setEnabled(theState)
|
self.fmtPadThin.setEnabled(state)
|
||||||
self.fmtPadThin.setEnabled(theState)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class GuiPreferencesAutomation
|
# END Class GuiPreferencesAutomation
|
||||||
@@ -1039,7 +1029,7 @@ class GuiPreferencesAutomation(QWidget):
|
|||||||
|
|
||||||
class GuiPreferencesQuotes(QWidget):
|
class GuiPreferencesQuotes(QWidget):
|
||||||
|
|
||||||
def __init__(self, prefsGui):
|
def __init__(self, prefsGui: GuiPreferences) -> None:
|
||||||
super().__init__(parent=prefsGui)
|
super().__init__(parent=prefsGui)
|
||||||
|
|
||||||
# The Form
|
# The Form
|
||||||
@@ -1123,9 +1113,8 @@ class GuiPreferencesQuotes(QWidget):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def saveValues(self):
|
def saveValues(self) -> None:
|
||||||
"""Save the values set for this tab.
|
"""Save the values set for this tab."""
|
||||||
"""
|
|
||||||
# Quotation Style
|
# Quotation Style
|
||||||
CONFIG.fmtSQuoteOpen = self.quoteSym["SO"].text()
|
CONFIG.fmtSQuoteOpen = self.quoteSym["SO"].text()
|
||||||
CONFIG.fmtSQuoteClose = self.quoteSym["SC"].text()
|
CONFIG.fmtSQuoteClose = self.quoteSym["SC"].text()
|
||||||
@@ -1134,12 +1123,11 @@ class GuiPreferencesQuotes(QWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Internal Functions
|
||||||
##
|
##
|
||||||
|
|
||||||
def _getQuote(self, qType):
|
def _getQuote(self, qType: str) -> None:
|
||||||
"""Dialog for single quote open.
|
"""Dialog for single quote open."""
|
||||||
"""
|
|
||||||
qtBox = GuiQuoteSelect(self, currentQuote=self.quoteSym[qType].text())
|
qtBox = GuiQuoteSelect(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)
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ repdash = True
|
|||||||
repdots = True
|
repdots = True
|
||||||
autoscroll = False
|
autoscroll = False
|
||||||
autoscrollpos = 30
|
autoscrollpos = 30
|
||||||
|
scrollpastend = True
|
||||||
fmtsquoteopen = ‘
|
fmtsquoteopen = ‘
|
||||||
fmtsquoteclose = ’
|
fmtsquoteclose = ’
|
||||||
fmtdquoteopen = “
|
fmtdquoteopen = “
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ repdash = True
|
|||||||
repdots = True
|
repdots = True
|
||||||
autoscroll = True
|
autoscroll = True
|
||||||
autoscrollpos = 30
|
autoscrollpos = 30
|
||||||
|
scrollpastend = True
|
||||||
fmtsquoteopen = ‘
|
fmtsquoteopen = ‘
|
||||||
fmtsquoteclose = ’
|
fmtsquoteclose = ’
|
||||||
fmtdquoteopen = “
|
fmtdquoteopen = “
|
||||||
|
|||||||
Reference in New Issue
Block a user