lib/core/settings/Settings.hpp
1 #pragma once
2 #include <QSettings>
3 
4 #include <score_lib_base_export.h>
5 
6 #include <memory>
7 namespace score
8 {
9 class SettingsDelegateFactory;
10 class SettingsDelegateModel;
11 class SettingsModel;
12 template <class Model>
13 class SettingsPresenter;
14 template <class Model>
15 class SettingsView;
16 class ProjectSettingsModel;
17 
18 struct DocumentContext;
19 struct ApplicationContext;
20 } // namespace score
21 
22 namespace score
23 {
41 class SCORE_LIB_BASE_EXPORT Settings final
42 {
43 public:
44  Settings();
45  ~Settings();
46 
47  void setupView();
48  void teardownView();
49 
50  Settings(const Settings&) = delete;
51  Settings(Settings&&) = delete;
52  Settings& operator=(const Settings&) = delete;
53  Settings& operator=(Settings&&) = delete;
54 
55  void setupSettingsPlugin(
56  QSettings& s, const score::ApplicationContext& ctx,
57  SettingsDelegateFactory& plugin);
58  SettingsView<SettingsDelegateModel>& view() const { return *m_settingsView; }
59 
60  auto& settings() const { return m_settings; }
61 
62 private:
63  SettingsView<SettingsDelegateModel>* m_settingsView{};
64  SettingsPresenter<SettingsDelegateModel>* m_settingsPresenter{};
65 
66  std::vector<std::unique_ptr<SettingsDelegateModel>> m_settings;
67 };
68 
69 class SCORE_LIB_BASE_EXPORT ProjectSettings final
70 {
71 public:
73  ~ProjectSettings();
74 
75  void setupView();
76 
77  ProjectSettings(const ProjectSettings&) = delete;
78  ProjectSettings(ProjectSettings&&) = delete;
79  ProjectSettings& operator=(const ProjectSettings&) = delete;
80  ProjectSettings& operator=(ProjectSettings&&) = delete;
81 
82  SettingsView<ProjectSettingsModel>& view() const { return *m_settingsView; }
83 
84  auto& settings() const { return m_settings; }
85 
86  void setup(const score::DocumentContext& ctx);
87 
88 private:
89  SettingsView<ProjectSettingsModel>* m_settingsView{};
90  SettingsPresenter<ProjectSettingsModel>* m_settingsPresenter{};
91 
92  std::vector<ProjectSettingsModel*> m_settings;
93 };
94 }
Definition: lib/core/settings/Settings.hpp:70
The SettingsDelegateFactory class.
Definition: SettingsDelegateFactory.hpp:23
Application-wide user settings registering and handling.
Definition: lib/core/settings/Settings.hpp:42
Definition: SettingsPresenter.hpp:24
Definition: SettingsView.hpp:21
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Used to access all the application-wide state and structures.
Definition: ApplicationContext.hpp:24
Definition: DocumentContext.hpp:18