Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPrefixedOptionDataWrapper.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef KISPREFIXEDOPTIONDATAWRAPPER_H
7#define KISPREFIXEDOPTIONDATAWRAPPER_H
8
9#include <QString>
11
18template <typename T>
20{
21 static constexpr bool supports_prefix = true;
22
23 KisPrefixedOptionDataWrapper(const QString &_prefix)
24 : prefix(_prefix)
25 {
26 }
27
28 bool read(const KisPropertiesConfiguration *setting) {
29 if (!setting) return false;
30
31 if (prefix.isEmpty()) {
32 return T::read(setting);
33 } else {
34 KisPropertiesConfiguration prefixedSetting;
35 setting->getPrefixedProperties(prefix, &prefixedSetting);
36 return T::read(&prefixedSetting);
37 }
38 }
39
40 void write(KisPropertiesConfiguration *setting) const {
41 if (prefix.isEmpty()) {
42 T::write(setting);
43 } else {
44 KisPropertiesConfiguration prefixedSetting;
45 T::write(&prefixedSetting);
46 setting->setPrefixedProperties(prefix, &prefixedSetting);
47 }
48 }
49
50 QString prefix;
51};
52
53#endif // KISPREFIXEDOPTIONDATAWRAPPER_H
KisPrefixedOptionDataWrapper(const QString &_prefix)
void write(KisPropertiesConfiguration *setting) const
bool read(const KisPropertiesConfiguration *setting)
void setPrefixedProperties(const QString &prefix, const KisPropertiesConfiguration *config)
void getPrefixedProperties(const QString &prefix, KisPropertiesConfiguration *config) const