Open-Typer
Open source typewriting tutor program
Loading...
Searching...
No Matches
ISettings.h
1/*
2 * ISettings.h
3 * This file is part of Open-Typer
4 *
5 * Copyright (C) 2023 - adazem009
6 *
7 * Open-Typer is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * Open-Typer is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Open-Typer. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef ISETTINGS_H
22#define ISETTINGS_H
23
24#include <QVariant>
25#include "global/modularity/ioc.h"
26
27#define INIT_SETTINGS_KEY(keyName, key, defaultValue) \
28 modularity::ioc()->resolve<ISettings>()->addKey(QString::fromStdString(moduleName()), keyName, key, defaultValue)
29
30class ISettings : public QObject, MODULE_EXPORT_INTERFACE
31{
32 Q_OBJECT
33 public:
34 struct Key
35 {
36 Key() = default;
37
38 Key(QString moduleName, QString key)
39 {
40 this->moduleName = moduleName;
41 this->key = key;
42 }
43
44 Key(QString moduleName, QString key, QVariant defaultValue)
45 {
46 this->moduleName = moduleName;
47 this->key = key;
48 this->defaultValue = defaultValue;
49 }
50
51 QString moduleName;
52 QString key;
53 QVariant defaultValue;
54 };
55
56 virtual ~ISettings() { }
57
58 virtual void addKey(QString moduleName, QString keyName, QString key, QVariant defaultValue) = 0;
59 virtual void setValue(QString moduleName, QString keyName, QVariant value) = 0;
60 virtual void setValue(Key key, QVariant value) = 0;
61 virtual QVariant getValue(QString moduleName, QString keyName) = 0;
62 virtual QVariant getValue(Key key) = 0;
63 virtual bool containsKey(QString moduleName, QString keyName) = 0;
64 virtual bool containsKey(Key key) = 0;
65
66 virtual void freeze() = 0;
67 virtual void saveChanges() = 0;
68 virtual void discardChanges() = 0;
69 virtual bool isFrozen() = 0;
70
71 signals:
72 void stateChanged();
73 void saved();
74 void discarded();
75};
76
77#endif // ISETTINGS_H
Definition ISettings.h:31
The Key class is used for the keys on the on screen keyboard.
Definition Key.h:30
Definition ISettings.h:35