diff --git a/docs/events/index.rst b/docs/events/index.rst index f0a55169..a86f83a5 100644 --- a/docs/events/index.rst +++ b/docs/events/index.rst @@ -356,3 +356,9 @@ SlicingFailed * ``stl``: the STL's filename * ``gcode``: the sliced GCODE's filename * ``reason``: the reason for the slicing having failed + +Settings +-------- + +SettingsUpdated + The internal settings were updated. diff --git a/src/octoprint/events.py b/src/octoprint/events.py index 701505ad..83b55354 100644 --- a/src/octoprint/events.py +++ b/src/octoprint/events.py @@ -81,6 +81,9 @@ class Events(object): SLICING_FAILED = "SlicingFailed" SLICING_CANCELLED = "SlicingCancelled" + # Settings + SETTINGS_UPDATED = "SettingsUpdated" + def eventManager(): global _instance diff --git a/src/octoprint/server/api/settings.py b/src/octoprint/server/api/settings.py index 5e4421a8..c0efc0dc 100644 --- a/src/octoprint/server/api/settings.py +++ b/src/octoprint/server/api/settings.py @@ -9,6 +9,7 @@ import logging from flask import request, jsonify +from octoprint.events import eventManager, Events from octoprint.settings import settings from octoprint.printer import getConnectionOptions @@ -226,7 +227,8 @@ def setSettings(): plugin.on_settings_save(data["plugins"][name]) - s.save() + if s.save(): + eventManager().fire(Events.SETTINGS_UPDATED) return getSettings() diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index f76f51d2..3a859d7b 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -431,12 +431,13 @@ class Settings(object): def save(self, force=False): if not self._dirty and not force: - return + return False with open(self._configfile, "wb") as configFile: yaml.safe_dump(self._config, configFile, default_flow_style=False, indent=" ", allow_unicode=True) self._dirty = False self.load() + return True #~~ getter