diff options
Diffstat (limited to 'Swift/Controllers/Highlighting/HighlightManager.h')
-rw-r--r-- | Swift/Controllers/Highlighting/HighlightManager.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Swift/Controllers/Highlighting/HighlightManager.h b/Swift/Controllers/Highlighting/HighlightManager.h new file mode 100644 index 0000000..13f59fa --- /dev/null +++ b/Swift/Controllers/Highlighting/HighlightManager.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2012 Maciej Niedzielski + * Licensed under the simplified BSD license. + * See Documentation/Licenses/BSD-simplified.txt for more information. + */ + +/* + * Copyright (c) 2014-2017 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#pragma once + +#include <memory> +#include <string> + +#include <boost/signals2.hpp> + +#include <Swift/Controllers/Highlighting/HighlightConfiguration.h> + +namespace Swift { + + class NickResolver; + class SettingsProvider; + class Highlighter; + + class HighlightManager { + public: + HighlightManager(SettingsProvider* settings); + + Highlighter* createHighlighter(NickResolver* nickResolver); + + std::shared_ptr<HighlightConfiguration> getConfiguration() const { + return highlightConfiguration_; + } + + void setConfiguration(const HighlightConfiguration& config) { + *highlightConfiguration_ = config; + storeSettings(); + } + + void resetToDefaultConfiguration(); + + void storeSettings(); + void loadSettings(); + + boost::signals2::signal<void (const HighlightAction&)> onHighlight; + + private: + void handleSettingChanged(const std::string& settingPath); + + static HighlightConfiguration getDefaultConfig(); + + static HighlightConfiguration highlightConfigurationFromString(const std::string& dataString); + static std::string highlightConfigurationToString(const HighlightConfiguration& configuration); + + private: + SettingsProvider* settings_; + bool storingSettings_; + std::shared_ptr<HighlightConfiguration> highlightConfiguration_; + boost::signals2::scoped_connection handleSettingChangedConnection_; + }; +} |