Loading...
Searching...
No Matches
SettingsDelegateFactory.hpp
1#pragma once
2#include <score/plugins/InterfaceList.hpp>
3#include <score/plugins/settingsdelegate/SettingsDelegateModel.hpp>
4#include <score/plugins/settingsdelegate/SettingsDelegatePresenter.hpp>
5#include <score/plugins/settingsdelegate/SettingsDelegateView.hpp>
6#include <score/tools/SafeCast.hpp>
7
8#include <score_lib_base_export.h>
9
10class QSettings;
11namespace score
12{
13struct ApplicationContext;
14template <class Model>
15class SettingsPresenter;
16
22class SCORE_LIB_BASE_EXPORT SettingsDelegateFactory : public score::InterfaceBase
23{
24 SCORE_INTERFACE(SettingsDelegateFactory, "f18653bc-7ca9-44aa-a08b-4188d086b46e")
25
26public:
28 GlobalSettingsPresenter* makePresenter(
30
31 virtual GlobalSettingsView* makeView() = 0;
32
33 virtual std::unique_ptr<SettingsDelegateModel>
34 makeModel(QSettings& settings, const score::ApplicationContext& ctx) = 0;
35
36protected:
37 virtual GlobalSettingsPresenter* makePresenter_impl(
39 = 0;
40};
41
43
44template <typename Model_T, typename Presenter_T, typename View_T>
46{
47 std::unique_ptr<SettingsDelegateModel>
48 makeModel(QSettings& settings, const score::ApplicationContext& ctx) override
49 {
50 return std::make_unique<Model_T>(settings, ctx);
51 }
52
53 score::GlobalSettingsView* makeView() override { return new View_T; }
54
55 score::GlobalSettingsPresenter* makePresenter_impl(
57 QObject* parent) override
58 {
59 return new Presenter_T{safe_cast<Model_T&>(m), safe_cast<View_T&>(v), parent};
60 }
61};
62
63#define SCORE_DECLARE_SETTINGS_FACTORY(Factory, Model, Presenter, View, Uuid) \
64 class Factory final : public score::SettingsDelegateFactory_T<Model, Presenter, View> \
65 { \
66 SCORE_CONCRETE(Uuid) \
67 };
68}
Base class for plug-in interfaces.
Definition Interface.hpp:52
InterfaceList Default implementation of InterfaceListBase.
Definition InterfaceList.hpp:80
Definition SettingsDelegateFactory.hpp:46
The SettingsDelegateFactory class.
Definition SettingsDelegateFactory.hpp:23
Definition SettingsDelegateModel.hpp:16
Definition SettingsDelegatePresenter.hpp:17
Definition SettingsDelegateView.hpp:18
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