1 /* 2 * Copyright (C) 2013-2018 Team Kodi 3 * This file is part of Kodi - https://kodi.tv 4 * 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 * See LICENSES/README.md for more information. 7 */ 8 9 #pragma once 10 11 #include <memory> 12 13 class CSetting; 14 class TiXmlNode; 15 16 class ISettingCallback 17 { 18 public: 19 virtual ~ISettingCallback() = default; 20 21 /*! 22 \brief The value of the given setting is being changed. 23 24 This callback is triggered whenever the value of a setting is being 25 changed. The given CSetting already contains the new value and the handler 26 of the callback has the possibility to allow or revert changing the value 27 of the setting. In case of a revert OnSettingChanging() is called again to 28 inform all listeners that the value change has been reverted. 29 30 \param setting The setting whose value is being changed (already containing the changed value) 31 \return True if the new value is acceptable otherwise false 32 */ OnSettingChanging(const std::shared_ptr<const CSetting> & setting)33 virtual bool OnSettingChanging(const std::shared_ptr<const CSetting>& setting) { return true; } 34 35 /*! 36 \brief The value of the given setting has changed. 37 38 This callback is triggered whenever the value of a setting has been 39 successfully changed (i.e. none of the OnSettingChanging() handlers) 40 has reverted the change. 41 42 \param setting The setting whose value has been changed 43 */ OnSettingChanged(const std::shared_ptr<const CSetting> & setting)44 virtual void OnSettingChanged(const std::shared_ptr<const CSetting>& setting) {} 45 46 /*! 47 \brief The given setting has been activated. 48 49 This callback is triggered whenever the given setting has been activated. 50 This callback is only fired for CSettingAction settings. 51 52 \param setting The setting which has been activated. 53 */ OnSettingAction(const std::shared_ptr<const CSetting> & setting)54 virtual void OnSettingAction(const std::shared_ptr<const CSetting>& setting) {} 55 56 /*! 57 \brief The given setting needs to be updated. 58 59 This callback is triggered when a setting needs to be updated because its 60 value is outdated. This only happens when initially loading the value of a 61 setting and will not be triggered afterwards. 62 63 \param setting The setting which needs to be updated. 64 \param oldSettingId The id of the previous setting. 65 \param oldSettingNode The old setting node 66 \return True if the setting has been successfully updated otherwise false 67 */ OnSettingUpdate(const std::shared_ptr<CSetting> & setting,const char * oldSettingId,const TiXmlNode * oldSettingNode)68 virtual bool OnSettingUpdate(const std::shared_ptr<CSetting>& setting, 69 const char* oldSettingId, 70 const TiXmlNode* oldSettingNode) 71 { 72 return false; 73 } 74 75 /*! 76 \brief The given property of the given setting has changed 77 78 This callback is triggered when a property (e.g. enabled or the list of 79 dynamic options) has changed. 80 81 \param setting The setting which has a changed property 82 \param propertyName The string representation of the changed property 83 */ OnSettingPropertyChanged(const std::shared_ptr<const CSetting> & setting,const char * propertyName)84 virtual void OnSettingPropertyChanged(const std::shared_ptr<const CSetting>& setting, 85 const char* propertyName) 86 { 87 } 88 }; 89