Split General tab in Preferences into General and Projects
This commit is contained in:
+79
-39
@@ -55,15 +55,17 @@ class GuiPreferences(PagedDialog):
|
|||||||
|
|
||||||
self.setWindowTitle("Preferences")
|
self.setWindowTitle("Preferences")
|
||||||
|
|
||||||
self.tabGeneral = GuiConfigEditGeneralTab(self.theParent)
|
self.tabGeneral = GuiConfigEditGeneralTab(self.theParent)
|
||||||
self.tabLayout = GuiConfigEditLayoutTab(self.theParent)
|
self.tabProjects = GuiConfigEditProjectsTab(self.theParent)
|
||||||
self.tabEditing = GuiConfigEditEditingTab(self.theParent)
|
self.tabLayout = GuiConfigEditLayoutTab(self.theParent)
|
||||||
self.tabAutoRep = GuiConfigEditAutoReplaceTab(self.theParent)
|
self.tabEditing = GuiConfigEditEditingTab(self.theParent)
|
||||||
|
self.tabAutoRep = GuiConfigEditAutoReplaceTab(self.theParent)
|
||||||
|
|
||||||
self.addTab(self.tabGeneral, "General")
|
self.addTab(self.tabGeneral, "General")
|
||||||
self.addTab(self.tabLayout, "Text Layout")
|
self.addTab(self.tabProjects, "Projects")
|
||||||
self.addTab(self.tabEditing, "Editor")
|
self.addTab(self.tabLayout, "Text Layout")
|
||||||
self.addTab(self.tabAutoRep, "Auto-Replace")
|
self.addTab(self.tabEditing, "Editor")
|
||||||
|
self.addTab(self.tabAutoRep, "Auto-Replace")
|
||||||
|
|
||||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
||||||
self.buttonBox.accepted.connect(self._doSave)
|
self.buttonBox.accepted.connect(self._doSave)
|
||||||
@@ -91,6 +93,10 @@ class GuiPreferences(PagedDialog):
|
|||||||
validEntries &= retA
|
validEntries &= retA
|
||||||
needsRestart |= retB
|
needsRestart |= retB
|
||||||
|
|
||||||
|
retA, retB = self.tabProjects.saveValues()
|
||||||
|
validEntries &= retA
|
||||||
|
needsRestart |= retB
|
||||||
|
|
||||||
retA, retB = self.tabLayout.saveValues()
|
retA, retB = self.tabLayout.saveValues()
|
||||||
validEntries &= retA
|
validEntries &= retA
|
||||||
needsRestart |= retB
|
needsRestart |= retB
|
||||||
@@ -222,6 +228,70 @@ class GuiConfigEditGeneralTab(QWidget):
|
|||||||
self.showFullPath
|
self.showFullPath
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def saveValues(self):
|
||||||
|
"""Save the values set for this tab.
|
||||||
|
"""
|
||||||
|
validEntries = True
|
||||||
|
needsRestart = False
|
||||||
|
|
||||||
|
guiTheme = self.selectTheme.currentData()
|
||||||
|
guiIcons = self.selectIcons.currentData()
|
||||||
|
guiDark = self.preferDarkIcons.isChecked()
|
||||||
|
guiFont = self.guiFont.text()
|
||||||
|
guiFontSize = self.guiFontSize.value()
|
||||||
|
showFullPath = self.showFullPath.isChecked()
|
||||||
|
|
||||||
|
# Check if restart is needed
|
||||||
|
needsRestart |= self.mainConf.guiTheme != guiTheme
|
||||||
|
needsRestart |= self.mainConf.guiIcons != guiIcons
|
||||||
|
needsRestart |= self.mainConf.guiFont != guiFont
|
||||||
|
needsRestart |= self.mainConf.guiFontSize != guiFontSize
|
||||||
|
|
||||||
|
self.mainConf.guiTheme = guiTheme
|
||||||
|
self.mainConf.guiIcons = guiIcons
|
||||||
|
self.mainConf.guiDark = guiDark
|
||||||
|
self.mainConf.guiFont = guiFont
|
||||||
|
self.mainConf.guiFontSize = guiFontSize
|
||||||
|
self.mainConf.showFullPath = showFullPath
|
||||||
|
|
||||||
|
self.mainConf.confChanged = True
|
||||||
|
|
||||||
|
return validEntries, needsRestart
|
||||||
|
|
||||||
|
##
|
||||||
|
# Slots
|
||||||
|
##
|
||||||
|
|
||||||
|
def _selectFont(self):
|
||||||
|
"""Open the QFontDialog and set a font for the font style.
|
||||||
|
"""
|
||||||
|
currFont = QFont()
|
||||||
|
currFont.setFamily(self.mainConf.guiFont)
|
||||||
|
currFont.setPointSize(self.mainConf.guiFontSize)
|
||||||
|
theFont, theStatus = QFontDialog.getFont(currFont, self)
|
||||||
|
if theStatus:
|
||||||
|
self.guiFont.setText(theFont.family())
|
||||||
|
self.guiFontSize.setValue(theFont.pointSize())
|
||||||
|
return
|
||||||
|
|
||||||
|
# END Class GuiConfigEditGeneralTab
|
||||||
|
|
||||||
|
class GuiConfigEditProjectsTab(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)
|
||||||
|
|
||||||
# AutoSave Settings
|
# AutoSave Settings
|
||||||
# =================
|
# =================
|
||||||
self.mainForm.addGroupLabel("Automatic Save")
|
self.mainForm.addGroupLabel("Automatic Save")
|
||||||
@@ -292,30 +362,12 @@ class GuiConfigEditGeneralTab(QWidget):
|
|||||||
validEntries = True
|
validEntries = True
|
||||||
needsRestart = False
|
needsRestart = False
|
||||||
|
|
||||||
guiTheme = self.selectTheme.currentData()
|
|
||||||
guiIcons = self.selectIcons.currentData()
|
|
||||||
guiDark = self.preferDarkIcons.isChecked()
|
|
||||||
guiFont = self.guiFont.text()
|
|
||||||
guiFontSize = self.guiFontSize.value()
|
|
||||||
showFullPath = self.showFullPath.isChecked()
|
|
||||||
autoSaveDoc = self.autoSaveDoc.value()
|
autoSaveDoc = self.autoSaveDoc.value()
|
||||||
autoSaveProj = self.autoSaveProj.value()
|
autoSaveProj = self.autoSaveProj.value()
|
||||||
backupPath = self.backupPath
|
backupPath = self.backupPath
|
||||||
backupOnClose = self.backupOnClose.isChecked()
|
backupOnClose = self.backupOnClose.isChecked()
|
||||||
askBeforeBackup = self.askBeforeBackup.isChecked()
|
askBeforeBackup = self.askBeforeBackup.isChecked()
|
||||||
|
|
||||||
# Check if restart is needed
|
|
||||||
needsRestart |= self.mainConf.guiTheme != guiTheme
|
|
||||||
needsRestart |= self.mainConf.guiIcons != guiIcons
|
|
||||||
needsRestart |= self.mainConf.guiFont != guiFont
|
|
||||||
needsRestart |= self.mainConf.guiFontSize != guiFontSize
|
|
||||||
|
|
||||||
self.mainConf.guiTheme = guiTheme
|
|
||||||
self.mainConf.guiIcons = guiIcons
|
|
||||||
self.mainConf.guiDark = guiDark
|
|
||||||
self.mainConf.guiFont = guiFont
|
|
||||||
self.mainConf.guiFontSize = guiFontSize
|
|
||||||
self.mainConf.showFullPath = showFullPath
|
|
||||||
self.mainConf.autoSaveDoc = autoSaveDoc
|
self.mainConf.autoSaveDoc = autoSaveDoc
|
||||||
self.mainConf.autoSaveProj = autoSaveProj
|
self.mainConf.autoSaveProj = autoSaveProj
|
||||||
self.mainConf.backupPath = backupPath
|
self.mainConf.backupPath = backupPath
|
||||||
@@ -357,19 +409,7 @@ class GuiConfigEditGeneralTab(QWidget):
|
|||||||
self.askBeforeBackup.setEnabled(theState)
|
self.askBeforeBackup.setEnabled(theState)
|
||||||
return
|
return
|
||||||
|
|
||||||
def _selectFont(self):
|
# END Class GuiConfigEditProjectsTab
|
||||||
"""Open the QFontDialog and set a font for the font style.
|
|
||||||
"""
|
|
||||||
currFont = QFont()
|
|
||||||
currFont.setFamily(self.mainConf.guiFont)
|
|
||||||
currFont.setPointSize(self.mainConf.guiFontSize)
|
|
||||||
theFont, theStatus = QFontDialog.getFont(currFont, self)
|
|
||||||
if theStatus:
|
|
||||||
self.guiFont.setText(theFont.family())
|
|
||||||
self.guiFontSize.setValue(theFont.pointSize())
|
|
||||||
return
|
|
||||||
|
|
||||||
# END Class GuiConfigEditGeneralTab
|
|
||||||
|
|
||||||
class GuiConfigEditLayoutTab(QWidget):
|
class GuiConfigEditLayoutTab(QWidget):
|
||||||
|
|
||||||
|
|||||||
+22
-14
@@ -1057,6 +1057,7 @@ def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp, nwRef, tmpC
|
|||||||
nwGUI.mainConf = tmpConf
|
nwGUI.mainConf = tmpConf
|
||||||
nwPrefs.mainConf = tmpConf
|
nwPrefs.mainConf = tmpConf
|
||||||
nwPrefs.tabGeneral.mainConf = tmpConf
|
nwPrefs.tabGeneral.mainConf = tmpConf
|
||||||
|
nwPrefs.tabProjects.mainConf = tmpConf
|
||||||
nwPrefs.tabLayout.mainConf = tmpConf
|
nwPrefs.tabLayout.mainConf = tmpConf
|
||||||
nwPrefs.tabEditing.mainConf = tmpConf
|
nwPrefs.tabEditing.mainConf = tmpConf
|
||||||
nwPrefs.tabAutoRep.mainConf = tmpConf
|
nwPrefs.tabAutoRep.mainConf = tmpConf
|
||||||
@@ -1065,7 +1066,6 @@ def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp, nwRef, tmpC
|
|||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
tabGeneral = nwPrefs.tabGeneral
|
tabGeneral = nwPrefs.tabGeneral
|
||||||
nwPrefs._tabBox.setCurrentWidget(tabGeneral)
|
nwPrefs._tabBox.setCurrentWidget(tabGeneral)
|
||||||
tabGeneral.backupPath = "no/where"
|
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
assert not tabGeneral.preferDarkIcons.isChecked()
|
assert not tabGeneral.preferDarkIcons.isChecked()
|
||||||
@@ -1077,27 +1077,35 @@ def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp, nwRef, tmpC
|
|||||||
qtbot.mouseClick(tabGeneral.showFullPath, Qt.LeftButton)
|
qtbot.mouseClick(tabGeneral.showFullPath, Qt.LeftButton)
|
||||||
assert not tabGeneral.showFullPath.isChecked()
|
assert not tabGeneral.showFullPath.isChecked()
|
||||||
|
|
||||||
# Check Browse button
|
|
||||||
monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *args, **kwargs: "")
|
|
||||||
assert not tabGeneral._backupFolder()
|
|
||||||
monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *args, **kwargs: "some/dir")
|
|
||||||
qtbot.mouseClick(tabGeneral.backupGetPath, Qt.LeftButton)
|
|
||||||
|
|
||||||
# Check font button
|
# Check font button
|
||||||
monkeypatch.setattr(QFontDialog, "getFont", lambda font, obj: (font, True))
|
monkeypatch.setattr(QFontDialog, "getFont", lambda font, obj: (font, True))
|
||||||
qtbot.mouseClick(tabGeneral.fontButton, Qt.LeftButton)
|
qtbot.mouseClick(tabGeneral.fontButton, Qt.LeftButton)
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
assert not tabGeneral.backupOnClose.isChecked()
|
tabGeneral.guiFontSize.setValue(12)
|
||||||
qtbot.mouseClick(tabGeneral.backupOnClose, Qt.LeftButton)
|
|
||||||
assert tabGeneral.backupOnClose.isChecked()
|
# Projects Settings
|
||||||
|
qtbot.wait(keyDelay)
|
||||||
|
tabProjects = nwPrefs.tabProjects
|
||||||
|
nwPrefs._tabBox.setCurrentWidget(tabProjects)
|
||||||
|
tabProjects.backupPath = "no/where"
|
||||||
|
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
tabGeneral.guiFontSize.setValue(12)
|
assert not tabProjects.backupOnClose.isChecked()
|
||||||
tabGeneral.autoSaveDoc.setValue(20)
|
qtbot.mouseClick(tabProjects.backupOnClose, Qt.LeftButton)
|
||||||
tabGeneral.autoSaveProj.setValue(40)
|
assert tabProjects.backupOnClose.isChecked()
|
||||||
|
|
||||||
# Text Layour Settings
|
# Check Browse button
|
||||||
|
monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *args, **kwargs: "")
|
||||||
|
assert not tabProjects._backupFolder()
|
||||||
|
monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *args, **kwargs: "some/dir")
|
||||||
|
qtbot.mouseClick(tabProjects.backupGetPath, Qt.LeftButton)
|
||||||
|
|
||||||
|
qtbot.wait(keyDelay)
|
||||||
|
tabProjects.autoSaveDoc.setValue(20)
|
||||||
|
tabProjects.autoSaveProj.setValue(40)
|
||||||
|
|
||||||
|
# Text Layout Settings
|
||||||
qtbot.wait(keyDelay)
|
qtbot.wait(keyDelay)
|
||||||
tabLayout = nwPrefs.tabLayout
|
tabLayout = nwPrefs.tabLayout
|
||||||
nwPrefs._tabBox.setCurrentWidget(tabLayout)
|
nwPrefs._tabBox.setCurrentWidget(tabLayout)
|
||||||
|
|||||||
Reference in New Issue
Block a user