Open-Typer
Open source typewriting tutor program
Loading...
Searching...
No Matches
Settings.h
1/*
2 * Settings.h
3 * This file is part of Open-Typer
4 *
5 * Copyright (C) 2022-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 SETTINGS_H
22#define SETTINGS_H
23
24#include <QSettings>
25#include <QRgb>
26#include <QColor>
27#include "../ISettings.h"
28#include "global/internal/FileUtils.h"
29
31class Q_DECL_EXPORT Settings : public ISettings
32{
33 Q_OBJECT
34 public:
35 static std::shared_ptr<Settings> instance();
36 static void init(void);
37 void addKey(QString moduleName, QString keyName, QString key, QVariant defaultValue) override;
38 Q_INVOKABLE void setValue(QString moduleName, QString keyName, QVariant value) override;
39 void setValue(Key key, QVariant value) override;
40 Q_INVOKABLE QVariant getValue(QString moduleName, QString keyName) override;
41 QVariant getValue(Key key) override;
42 Q_INVOKABLE bool containsKey(QString moduleName, QString keyName) override;
43 bool containsKey(Key key) override;
44 Q_INVOKABLE void freeze(void) override;
45 Q_INVOKABLE void saveChanges(void) override;
46 Q_INVOKABLE void discardChanges(void) override;
47 Q_INVOKABLE bool isFrozen(void) override;
48
49 protected:
50 static QVariant get(QString key, QVariant defaultValue);
51 static bool contains(QString key);
52 static void set(QString key, QVariant value);
53
54 private:
55 static std::shared_ptr<Settings> m_instance;
56 static QSettings *settingsInstance;
57 static QSettings *mainSettingsInstance;
58 static bool frozen;
59 static QMap<QPair<QString, QString>, Key> m_keys;
60 static void copySettings(QSettings *source, QSettings *target);
61#ifdef Q_OS_WASM
62 static bool tempSettingsCopied;
63 static void copyTempSettings(void);
64#endif // Q_OS_WASM
65};
66
67#endif // SETTINGS_H
Definition ISettings.h:31
The Settings class manages the application settings.
Definition Settings.h:32
Definition ISettings.h:35