summaryrefslogtreecommitdiffstats
blob: 13f59fa34cd816b8a5038095b608d69600a0fde2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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_;
    };
}