Make some minor changes and update test coverage
This commit is contained in:
@@ -78,15 +78,35 @@ class GuiPreferences(PagedDialog):
|
|||||||
self.resize(*self.mainConf.getPreferencesSize())
|
self.resize(*self.mainConf.getPreferencesSize())
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
self.updateTheme = False
|
self._updateTheme = False
|
||||||
self.updateSyntax = False
|
self._updateSyntax = False
|
||||||
self.needsRestart = False
|
self._needsRestart = False
|
||||||
self.refreshTree = False
|
self._refreshTree = False
|
||||||
|
|
||||||
logger.debug("GuiPreferences initialisation complete")
|
logger.debug("GuiPreferences initialisation complete")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Properties
|
||||||
|
##
|
||||||
|
|
||||||
|
@property
|
||||||
|
def updateTheme(self):
|
||||||
|
return self._updateTheme
|
||||||
|
|
||||||
|
@property
|
||||||
|
def updateSyntax(self):
|
||||||
|
return self._updateSyntax
|
||||||
|
|
||||||
|
@property
|
||||||
|
def needsRestart(self):
|
||||||
|
return self._needsRestart
|
||||||
|
|
||||||
|
@property
|
||||||
|
def refreshTree(self):
|
||||||
|
return self._refreshTree
|
||||||
|
|
||||||
##
|
##
|
||||||
# Slots
|
# Slots
|
||||||
##
|
##
|
||||||
@@ -275,12 +295,12 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
emphLabels = self.emphLabels.isChecked()
|
emphLabels = self.emphLabels.isChecked()
|
||||||
|
|
||||||
# Update Flags
|
# Update Flags
|
||||||
self.prefsGui.updateTheme |= self.mainConf.guiTheme != guiTheme
|
self.prefsGui._updateTheme |= self.mainConf.guiTheme != guiTheme
|
||||||
self.prefsGui.updateSyntax |= self.mainConf.guiSyntax != guiSyntax
|
self.prefsGui._updateSyntax |= self.mainConf.guiSyntax != guiSyntax
|
||||||
self.prefsGui.needsRestart |= self.mainConf.guiLang != guiLang
|
self.prefsGui._needsRestart |= self.mainConf.guiLang != guiLang
|
||||||
self.prefsGui.needsRestart |= self.mainConf.guiFont != guiFont
|
self.prefsGui._needsRestart |= self.mainConf.guiFont != guiFont
|
||||||
self.prefsGui.needsRestart |= self.mainConf.guiFontSize != guiFontSize
|
self.prefsGui._needsRestart |= self.mainConf.guiFontSize != guiFontSize
|
||||||
self.prefsGui.refreshTree |= self.mainConf.emphLabels != emphLabels
|
self.prefsGui._refreshTree |= self.mainConf.emphLabels != emphLabels
|
||||||
|
|
||||||
self.mainConf.guiLang = guiLang
|
self.mainConf.guiLang = guiLang
|
||||||
self.mainConf.guiTheme = guiTheme
|
self.mainConf.guiTheme = guiTheme
|
||||||
|
|||||||
@@ -2526,12 +2526,14 @@ class GuiDocEditSearch(QFrame):
|
|||||||
# Slots
|
# Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _doClose(self):
|
def _doClose(self):
|
||||||
"""Hide the search/replace bar.
|
"""Hide the search/replace bar.
|
||||||
"""
|
"""
|
||||||
self.closeSearch()
|
self.closeSearch()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _doSearch(self):
|
def _doSearch(self):
|
||||||
"""Call the search action function for the document editor.
|
"""Call the search action function for the document editor.
|
||||||
"""
|
"""
|
||||||
@@ -2542,12 +2544,14 @@ class GuiDocEditSearch(QFrame):
|
|||||||
self.docEditor.findNext()
|
self.docEditor.findNext()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _doReplace(self):
|
def _doReplace(self):
|
||||||
"""Call the replace action function for the document editor.
|
"""Call the replace action function for the document editor.
|
||||||
"""
|
"""
|
||||||
self.docEditor.replaceNext()
|
self.docEditor.replaceNext()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot(bool)
|
||||||
def _doToggleReplace(self, theState):
|
def _doToggleReplace(self, theState):
|
||||||
"""Toggle the show/hide of the replace box.
|
"""Toggle the show/hide of the replace box.
|
||||||
"""
|
"""
|
||||||
@@ -2562,36 +2566,42 @@ class GuiDocEditSearch(QFrame):
|
|||||||
self.docEditor.updateDocMargins()
|
self.docEditor.updateDocMargins()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot(bool)
|
||||||
def _doToggleCase(self, theState):
|
def _doToggleCase(self, theState):
|
||||||
"""Enable/disable case sensitive mode.
|
"""Enable/disable case sensitive mode.
|
||||||
"""
|
"""
|
||||||
self.isCaseSense = theState
|
self.isCaseSense = theState
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot(bool)
|
||||||
def _doToggleWord(self, theState):
|
def _doToggleWord(self, theState):
|
||||||
"""Enable/disable whole word search mode.
|
"""Enable/disable whole word search mode.
|
||||||
"""
|
"""
|
||||||
self.isWholeWord = theState
|
self.isWholeWord = theState
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot(bool)
|
||||||
def _doToggleRegEx(self, theState):
|
def _doToggleRegEx(self, theState):
|
||||||
"""Enable/disable regular expression search mode.
|
"""Enable/disable regular expression search mode.
|
||||||
"""
|
"""
|
||||||
self.isRegEx = theState
|
self.isRegEx = theState
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot(bool)
|
||||||
def _doToggleLoop(self, theState):
|
def _doToggleLoop(self, theState):
|
||||||
"""Enable/disable looping the search.
|
"""Enable/disable looping the search.
|
||||||
"""
|
"""
|
||||||
self.doLoop = theState
|
self.doLoop = theState
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot(bool)
|
||||||
def _doToggleProject(self, theState):
|
def _doToggleProject(self, theState):
|
||||||
"""Enable/disable continuing search in next project file.
|
"""Enable/disable continuing search in next project file.
|
||||||
"""
|
"""
|
||||||
self.doNextFile = theState
|
self.doNextFile = theState
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot(bool)
|
||||||
def _doToggleMatchCap(self, theState):
|
def _doToggleMatchCap(self, theState):
|
||||||
"""Enable/disable preserving capitalisation when replacing.
|
"""Enable/disable preserving capitalisation when replacing.
|
||||||
"""
|
"""
|
||||||
@@ -2804,18 +2814,21 @@ class GuiDocEditHeader(QWidget):
|
|||||||
# Slots
|
# Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _editDocument(self):
|
def _editDocument(self):
|
||||||
"""Open the edit item dialog from the main GUI.
|
"""Open the edit item dialog from the main GUI.
|
||||||
"""
|
"""
|
||||||
self.mainGui.editItemLabel(self._docHandle)
|
self.mainGui.editItemLabel(self._docHandle)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _searchDocument(self):
|
def _searchDocument(self):
|
||||||
"""Toggle the visibility of the search box.
|
"""Toggle the visibility of the search box.
|
||||||
"""
|
"""
|
||||||
self.docEditor.toggleSearch()
|
self.docEditor.toggleSearch()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _closeDocument(self):
|
def _closeDocument(self):
|
||||||
"""Trigger the close editor on the main window.
|
"""Trigger the close editor on the main window.
|
||||||
"""
|
"""
|
||||||
@@ -2826,6 +2839,7 @@ class GuiDocEditHeader(QWidget):
|
|||||||
self.minmaxButton.setVisible(False)
|
self.minmaxButton.setVisible(False)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _minmaxDocument(self):
|
def _minmaxDocument(self):
|
||||||
"""Switch on or off Focus Mode.
|
"""Switch on or off Focus Mode.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -889,12 +889,14 @@ class GuiDocViewHeader(QWidget):
|
|||||||
# Slots
|
# Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _closeDocument(self):
|
def _closeDocument(self):
|
||||||
"""Trigger the close editor/viewer on the main window.
|
"""Trigger the close editor/viewer on the main window.
|
||||||
"""
|
"""
|
||||||
self.mainGui.closeDocViewer()
|
self.mainGui.closeDocViewer()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _refreshDocument(self):
|
def _refreshDocument(self):
|
||||||
"""Reload the content of the document.
|
"""Reload the content of the document.
|
||||||
"""
|
"""
|
||||||
@@ -1124,6 +1126,7 @@ class GuiDocViewFooter(QWidget):
|
|||||||
# Slots
|
# Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _doShowHide(self):
|
def _doShowHide(self):
|
||||||
"""Toggle the expand/collapse of the panel.
|
"""Toggle the expand/collapse of the panel.
|
||||||
"""
|
"""
|
||||||
@@ -1131,6 +1134,7 @@ class GuiDocViewFooter(QWidget):
|
|||||||
self.viewMeta.setVisible(not isVisible)
|
self.viewMeta.setVisible(not isVisible)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot(bool)
|
||||||
def _doToggleSticky(self, theState):
|
def _doToggleSticky(self, theState):
|
||||||
"""Toggle the sticky flag for the reference panel.
|
"""Toggle the sticky flag for the reference panel.
|
||||||
"""
|
"""
|
||||||
@@ -1140,6 +1144,7 @@ class GuiDocViewFooter(QWidget):
|
|||||||
self.viewMeta.refreshReferences(self.docViewer.docHandle())
|
self.viewMeta.refreshReferences(self.docViewer.docHandle())
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot(bool)
|
||||||
def _doToggleComments(self, theState):
|
def _doToggleComments(self, theState):
|
||||||
"""Toggle the view comment button and reload the document.
|
"""Toggle the view comment button and reload the document.
|
||||||
"""
|
"""
|
||||||
@@ -1147,6 +1152,7 @@ class GuiDocViewFooter(QWidget):
|
|||||||
self.docViewer.reloadText()
|
self.docViewer.reloadText()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot(bool)
|
||||||
def _doToggleSynopsis(self, theState):
|
def _doToggleSynopsis(self, theState):
|
||||||
"""Toggle the view synopsis button and reload the document.
|
"""Toggle the view synopsis button and reload the document.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -246,12 +246,9 @@ class GuiTheme:
|
|||||||
# Icons
|
# Icons
|
||||||
self.iconCache.loadTheme(self.themeIcons)
|
self.iconCache.loadTheme(self.themeIcons)
|
||||||
|
|
||||||
# Apply Styles
|
|
||||||
qApp.setPalette(self._guiPalette)
|
|
||||||
|
|
||||||
# Update Dependant Colours
|
# Update Dependant Colours
|
||||||
backCol = qApp.palette().window().color()
|
backCol = self._guiPalette.window().color()
|
||||||
textCol = qApp.palette().windowText().color()
|
textCol = self._guiPalette.windowText().color()
|
||||||
|
|
||||||
backLCol = backCol.lightnessF()
|
backLCol = backCol.lightnessF()
|
||||||
textLCol = textCol.lightnessF()
|
textLCol = textCol.lightnessF()
|
||||||
@@ -263,6 +260,9 @@ class GuiTheme:
|
|||||||
|
|
||||||
self.helpText = [int(255*helpLCol)]*3
|
self.helpText = [int(255*helpLCol)]*3
|
||||||
|
|
||||||
|
# Apply Styles
|
||||||
|
qApp.setPalette(self._guiPalette)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def loadSyntax(self):
|
def loadSyntax(self):
|
||||||
|
|||||||
@@ -918,6 +918,8 @@ class GuiMain(QMainWindow):
|
|||||||
self.projView.populateTree()
|
self.projView.populateTree()
|
||||||
|
|
||||||
if dlgConf.updateTheme:
|
if dlgConf.updateTheme:
|
||||||
|
# We are doing this manually instead of connecting to
|
||||||
|
# qApp.paletteChanged since the processing order matters
|
||||||
self.mainTheme.loadTheme()
|
self.mainTheme.loadTheme()
|
||||||
self.docEditor.updateTheme()
|
self.docEditor.updateTheme()
|
||||||
self.docViewer.updateTheme()
|
self.docViewer.updateTheme()
|
||||||
|
|||||||
@@ -69,14 +69,24 @@ def testDlgPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
|
|||||||
monkeypatch.setattr(GuiPreferences, "result", lambda *a: QDialog.Accepted)
|
monkeypatch.setattr(GuiPreferences, "result", lambda *a: QDialog.Accepted)
|
||||||
monkeypatch.setattr(nwGUI.docEditor.spEnchant, "listDictionaries", lambda: [("en", "none")])
|
monkeypatch.setattr(nwGUI.docEditor.spEnchant, "listDictionaries", lambda: [("en", "none")])
|
||||||
|
|
||||||
nwGUI.mainMenu.aPreferences.activate(QAction.Trigger)
|
with monkeypatch.context() as mp:
|
||||||
qtbot.waitUntil(lambda: getGuiItem("GuiPreferences") is not None, timeout=1000)
|
mp.setattr(GuiPreferences, "updateTheme", lambda *a: True)
|
||||||
|
mp.setattr(GuiPreferences, "updateSyntax", lambda *a: True)
|
||||||
|
mp.setattr(GuiPreferences, "needsRestart", lambda *a: True)
|
||||||
|
mp.setattr(GuiPreferences, "refreshTree", lambda *a: True)
|
||||||
|
nwGUI.mainMenu.aPreferences.activate(QAction.Trigger)
|
||||||
|
qtbot.waitUntil(lambda: getGuiItem("GuiPreferences") is not None, timeout=1000)
|
||||||
|
|
||||||
nwPrefs = getGuiItem("GuiPreferences")
|
nwPrefs = getGuiItem("GuiPreferences")
|
||||||
assert isinstance(nwPrefs, GuiPreferences)
|
assert isinstance(nwPrefs, GuiPreferences)
|
||||||
nwPrefs.show()
|
nwPrefs.show()
|
||||||
assert nwPrefs.mainConf.confPath == fncDir
|
assert nwPrefs.mainConf.confPath == fncDir
|
||||||
|
|
||||||
|
assert nwPrefs.updateTheme is False
|
||||||
|
assert nwPrefs.updateSyntax is False
|
||||||
|
assert nwPrefs.needsRestart is False
|
||||||
|
assert nwPrefs.refreshTree is False
|
||||||
|
|
||||||
# General Settings
|
# General Settings
|
||||||
qtbot.wait(KEY_DELAY)
|
qtbot.wait(KEY_DELAY)
|
||||||
tabGeneral = nwPrefs.tabGeneral
|
tabGeneral = nwPrefs.tabGeneral
|
||||||
@@ -220,7 +230,7 @@ def testDlgPreferences_Main(qtbot, monkeypatch, fncDir, outDir, refDir):
|
|||||||
nwPrefs._tabBox.setCurrentWidget(tabQuote)
|
nwPrefs._tabBox.setCurrentWidget(tabQuote)
|
||||||
|
|
||||||
monkeypatch.setattr(GuiQuoteSelect, "selectedQuote", "'")
|
monkeypatch.setattr(GuiQuoteSelect, "selectedQuote", "'")
|
||||||
monkeypatch.setattr(GuiQuoteSelect, "exec_", lambda *args: QDialog.Accepted)
|
monkeypatch.setattr(GuiQuoteSelect, "exec_", lambda *a: QDialog.Accepted)
|
||||||
qtbot.mouseClick(tabQuote.btnDoubleStyleC, Qt.LeftButton)
|
qtbot.mouseClick(tabQuote.btnDoubleStyleC, Qt.LeftButton)
|
||||||
|
|
||||||
# Save and Check Config
|
# Save and Check Config
|
||||||
|
|||||||
Reference in New Issue
Block a user