blob: c86f040e346992442bb122218c9cb37a6771796f (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
/*
* Copyright (C) 2013-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "settings/lib/ISettingControl.h"
#include "settings/lib/ISettingControlCreator.h"
#define SETTING_XML_ELM_CONTROL_FORMATLABEL "formatlabel"
#define SETTING_XML_ELM_CONTROL_HIDDEN "hidden"
#define SETTING_XML_ELM_CONTROL_VERIFYNEW "verifynew"
#define SETTING_XML_ELM_CONTROL_HEADING "heading"
#define SETTING_XML_ELM_CONTROL_HIDEVALUE "hidevalue"
#define SETTING_XML_ELM_CONTROL_MULTISELECT "multiselect"
#define SETTING_XML_ELM_CONTROL_POPUP "popup"
#define SETTING_XML_ELM_CONTROL_FORMATVALUE "value"
#define SETTING_XML_ELM_CONTROL_ADDBUTTONLABEL "addbuttonlabel"
#define SETTING_XML_ATTR_SHOW_MORE "more"
#define SETTING_XML_ATTR_SHOW_DETAILS "details"
#define SETTING_XML_ATTR_SEPARATOR_POSITION "separatorposition"
#define SETTING_XML_ATTR_HIDE_SEPARATOR "hideseparator"
class CVariant;
class CSettingControlCreator : public ISettingControlCreator
{
public:
// implementation of ISettingControlCreator
std::shared_ptr<ISettingControl> CreateControl(const std::string &controlType) const override;
protected:
CSettingControlCreator() = default;
~CSettingControlCreator() override = default;
};
class CSettingControlCheckmark : public ISettingControl
{
public:
CSettingControlCheckmark()
{
m_format = "boolean";
}
~CSettingControlCheckmark() override = default;
// implementation of ISettingControl
std::string GetType() const override { return "toggle"; }
bool SetFormat(const std::string &format) override;
};
class CSettingControlFormattedRange : public ISettingControl
{
public:
~CSettingControlFormattedRange() override = default;
bool Deserialize(const TiXmlNode *node, bool update = false) override;
int GetFormatLabel() const { return m_formatLabel; }
void SetFormatLabel(int formatLabel) { m_formatLabel = formatLabel; }
const std::string& GetFormatString() const { return m_formatString; }
void SetFormatString(const std::string &formatString) { m_formatString = formatString; }
int GetMinimumLabel() const { return m_minimumLabel; }
void SetMinimumLabel(int minimumLabel) { m_minimumLabel = minimumLabel; }
protected:
CSettingControlFormattedRange() = default;
int m_formatLabel = -1;
std::string m_formatString = "{}";
int m_minimumLabel = -1;
};
class CSettingControlSpinner : public CSettingControlFormattedRange
{
public:
CSettingControlSpinner() = default;
~CSettingControlSpinner() override = default;
// implementation of ISettingControl
std::string GetType() const override { return "spinner"; }
// specialization of CSettingControlFormattedRange
bool SetFormat(const std::string &format) override;
};
class CSettingControlEdit : public ISettingControl
{
public:
CSettingControlEdit()
{
m_delayed = true;
}
~CSettingControlEdit() override = default;
// implementation of ISettingControl
std::string GetType() const override { return "edit"; }
bool Deserialize(const TiXmlNode *node, bool update = false) override;
bool SetFormat(const std::string &format) override;
bool IsHidden() const { return m_hidden; }
void SetHidden(bool hidden) { m_hidden = hidden; }
bool VerifyNewValue() const { return m_verifyNewValue; }
void SetVerifyNewValue(bool verifyNewValue) { m_verifyNewValue = verifyNewValue; }
int GetHeading() const { return m_heading; }
void SetHeading(int heading) { m_heading = heading; }
protected:
bool m_hidden = false;
bool m_verifyNewValue = false;
int m_heading = -1;
};
class CSettingControlButton : public ISettingControl
{
public:
CSettingControlButton() = default;
~CSettingControlButton() override = default;
// implementation of ISettingControl
std::string GetType() const override { return "button"; }
bool Deserialize(const TiXmlNode *node, bool update = false) override;
bool SetFormat(const std::string &format) override;
int GetHeading() const { return m_heading; }
void SetHeading(int heading) { m_heading = heading; }
bool HideValue() const { return m_hideValue; }
void SetHideValue(bool hideValue) { m_hideValue = hideValue; }
bool ShowAddonDetails() const { return m_showAddonDetails; }
void SetShowAddonDetails(bool showAddonDetails) { m_showAddonDetails = showAddonDetails; }
bool ShowInstalledAddons() const { return m_showInstalledAddons; }
void SetShowInstalledAddons(bool showInstalledAddons) { m_showInstalledAddons = showInstalledAddons; }
bool ShowInstallableAddons() const { return m_showInstallableAddons; }
void SetShowInstallableAddons(bool showInstallableAddons) { m_showInstallableAddons = showInstallableAddons; }
bool ShowMoreAddons() const { return !m_showInstallableAddons && m_showMoreAddons; }
void SetShowMoreAddons(bool showMoreAddons) { m_showMoreAddons = showMoreAddons; }
bool UseImageThumbs() const { return m_useImageThumbs; }
void SetUseImageThumbs(bool useImageThumbs) { m_useImageThumbs = useImageThumbs; }
bool UseFileDirectories() const { return m_useFileDirectories; }
void SetUseFileDirectories(bool useFileDirectories) { m_useFileDirectories = useFileDirectories; }
bool HasActionData() const { return !m_actionData.empty(); }
const std::string& GetActionData() const { return m_actionData; }
void SetActionData(const std::string& actionData) { m_actionData = actionData; }
bool CloseDialog() const { return m_closeDialog; }
void SetCloseDialog(bool closeDialog) { m_closeDialog = closeDialog; }
protected:
int m_heading = -1;
bool m_hideValue = false;
bool m_showAddonDetails = true;
bool m_showInstalledAddons = true;
bool m_showInstallableAddons = false;
bool m_showMoreAddons = true;
bool m_useImageThumbs = false;
bool m_useFileDirectories = false;
std::string m_actionData;
bool m_closeDialog = false;
};
class CSetting;
using SettingControlListValueFormatter =
std::string (*)(const std::shared_ptr<const CSetting>& setting);
class CSettingControlList : public CSettingControlFormattedRange
{
public:
CSettingControlList() = default;
~CSettingControlList() override = default;
// implementation of ISettingControl
std::string GetType() const override { return "list"; }
// specialization of CSettingControlFormattedRange
bool Deserialize(const TiXmlNode *node, bool update = false) override;
bool SetFormat(const std::string &format) override;
int GetHeading() const { return m_heading; }
void SetHeading(int heading) { m_heading = heading; }
bool CanMultiSelect() const { return m_multiselect; }
void SetMultiSelect(bool multiselect) { m_multiselect = multiselect; }
bool HideValue() const { return m_hideValue; }
void SetHideValue(bool hideValue) { m_hideValue = hideValue; }
int GetAddButtonLabel() const { return m_addButtonLabel; }
void SetAddButtonLabel(int label) { m_addButtonLabel = label; }
SettingControlListValueFormatter GetFormatter() const { return m_formatter; }
void SetFormatter(SettingControlListValueFormatter formatter) { m_formatter = formatter; }
bool UseDetails() const { return m_useDetails; }
void SetUseDetails(bool useDetails) { m_useDetails = useDetails; }
protected:
int m_heading = -1;
bool m_multiselect = false;
bool m_hideValue = false;
int m_addButtonLabel = -1;
SettingControlListValueFormatter m_formatter = nullptr;
bool m_useDetails{false};
};
class CSettingControlSlider;
using SettingControlSliderFormatter =
std::string (*)(const std::shared_ptr<const CSettingControlSlider>& control,
const CVariant& value,
const CVariant& minimum,
const CVariant& step,
const CVariant& maximum);
class CSettingControlSlider : public ISettingControl
{
public:
CSettingControlSlider() = default;
~CSettingControlSlider() override = default;
// implementation of ISettingControl
std::string GetType() const override { return "slider"; }
bool Deserialize(const TiXmlNode *node, bool update = false) override;
bool SetFormat(const std::string &format) override;
int GetHeading() const { return m_heading; }
void SetHeading(int heading) { m_heading = heading; }
bool UsePopup() const { return m_popup; }
void SetPopup(bool popup) { m_popup = popup; }
int GetFormatLabel() const { return m_formatLabel; }
void SetFormatLabel(int formatLabel) { m_formatLabel = formatLabel; }
const std::string& GetFormatString() const { return m_formatString; }
void SetFormatString(const std::string &formatString) { m_formatString = formatString; }
std::string GetDefaultFormatString() const;
SettingControlSliderFormatter GetFormatter() const { return m_formatter; }
void SetFormatter(SettingControlSliderFormatter formatter) { m_formatter = formatter; }
protected:
int m_heading = -1;
bool m_popup = false;
int m_formatLabel = -1;
std::string m_formatString;
SettingControlSliderFormatter m_formatter = nullptr;
};
class CSettingControlRange : public ISettingControl
{
public:
CSettingControlRange() = default;
~CSettingControlRange() override = default;
// implementation of ISettingControl
std::string GetType() const override { return "range"; }
bool Deserialize(const TiXmlNode *node, bool update = false) override;
bool SetFormat(const std::string &format) override;
int GetFormatLabel() const { return m_formatLabel; }
void SetFormatLabel(int formatLabel) { m_formatLabel = formatLabel; }
int GetValueFormatLabel() const { return m_valueFormatLabel; }
void SetValueFormatLabel(int valueFormatLabel) { m_valueFormatLabel = valueFormatLabel; }
const std::string& GetValueFormat() const { return m_valueFormat; }
void SetValueFormat(const std::string &valueFormat) { m_valueFormat = valueFormat; }
protected:
int m_formatLabel = 21469;
int m_valueFormatLabel = -1;
std::string m_valueFormat = "{}";
};
class CSettingControlTitle : public ISettingControl
{
public:
CSettingControlTitle() = default;
~CSettingControlTitle() override = default;
// implementation of ISettingControl
std::string GetType() const override { return "title"; }
bool Deserialize(const TiXmlNode *node, bool update = false) override;
bool IsSeparatorHidden() const { return m_separatorHidden; }
void SetSeparatorHidden(bool hidden) { m_separatorHidden = hidden; }
bool IsSeparatorBelowLabel() const { return m_separatorBelowLabel; }
void SetSeparatorBelowLabel(bool below) { m_separatorBelowLabel = below; }
protected:
bool m_separatorHidden = false;
bool m_separatorBelowLabel = true;
};
class CSettingControlLabel : public ISettingControl
{
public:
CSettingControlLabel();
~CSettingControlLabel() override = default;
// implementation of ISettingControl
std::string GetType() const override { return "label"; }
};
class CSettingControlColorButton : public ISettingControl
{
public:
CSettingControlColorButton() { m_format = "string"; }
~CSettingControlColorButton() override = default;
// implementation of ISettingControl
std::string GetType() const override { return "colorbutton"; }
bool SetFormat(const std::string& format) override;
};
|