Only update config if actually modified
This commit is contained in:
parent
8935b99188
commit
ee3357a943
@ -465,12 +465,12 @@ class ConfigEditor(QDialog):
|
|||||||
restore = self.form.buttonBox.button(QDialogButtonBox.RestoreDefaults)
|
restore = self.form.buttonBox.button(QDialogButtonBox.RestoreDefaults)
|
||||||
restore.clicked.connect(self.onRestoreDefaults)
|
restore.clicked.connect(self.onRestoreDefaults)
|
||||||
self.updateHelp()
|
self.updateHelp()
|
||||||
self.updateText()
|
self.updateText(self.conf)
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def onRestoreDefaults(self):
|
def onRestoreDefaults(self):
|
||||||
self.conf = self.mgr.addonConfigDefaults(self.addon)
|
default_conf = self.mgr.addonConfigDefaults(self.addon)
|
||||||
self.updateText()
|
self.updateText(default_conf)
|
||||||
|
|
||||||
def updateHelp(self):
|
def updateHelp(self):
|
||||||
txt = self.mgr.addonConfigHelp(self.addon)
|
txt = self.mgr.addonConfigHelp(self.addon)
|
||||||
@ -479,22 +479,22 @@ class ConfigEditor(QDialog):
|
|||||||
else:
|
else:
|
||||||
self.form.scrollArea.setVisible(False)
|
self.form.scrollArea.setVisible(False)
|
||||||
|
|
||||||
def updateText(self):
|
def updateText(self, conf):
|
||||||
self.form.editor.setPlainText(
|
self.form.editor.setPlainText(
|
||||||
json.dumps(self.conf,sort_keys=True,indent=4, separators=(',', ': ')))
|
json.dumps(conf,sort_keys=True,indent=4, separators=(',', ': ')))
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
txt = self.form.editor.toPlainText()
|
txt = self.form.editor.toPlainText()
|
||||||
try:
|
try:
|
||||||
self.conf = json.loads(txt)
|
new_conf = json.loads(txt)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
showInfo(_("Invalid configuration: ") + repr(e))
|
showInfo(_("Invalid configuration: ") + repr(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
self.mgr.writeConfig(self.addon, self.conf)
|
if new_conf != self.conf:
|
||||||
|
self.mgr.writeConfig(self.addon, new_conf)
|
||||||
|
act = self.mgr.configUpdatedAction(self.addon)
|
||||||
|
if act:
|
||||||
|
act()
|
||||||
|
|
||||||
act = self.mgr.configUpdatedAction(self.addon)
|
|
||||||
if act:
|
|
||||||
act()
|
|
||||||
|
|
||||||
super().accept()
|
super().accept()
|
||||||
|
Loading…
Reference in New Issue
Block a user