1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef PERSISTENTSETTINGS_H
6#define PERSISTENTSETTINGS_H
7
8#include <QVariant>
9#include <QString>
10
11class PersistentSettingsReader
12{
13public:
14 PersistentSettingsReader();
15 QVariant restoreValue(const QString &variable, const QVariant &defaultValue = QVariant()) const;
16 QVariantMap restoreValues() const;
17 bool load(const QString &QString);
18
19private:
20 QMap<QString, QVariant> valueMap;
21};
22
23class PersistentSettingsWriter
24{
25public:
26 PersistentSettingsWriter(const QString &_fileName, const QString &_docType);
27 ~PersistentSettingsWriter();
28
29 bool save(const QVariantMap &data, QString *errorString) const;
30#ifdef QT_GUI_LIB
31 bool save(const QVariantMap &data, QWidget *parent) const;
32#endif
33
34 QString getFileName() const;
35
36 void setContents(const QVariantMap &data);
37
38private:
39 bool write(const QVariantMap &data, QString *errorString) const;
40
41 const QString fileName;
42 const QString docType;
43 mutable QMap<QString, QVariant> savedData;
44};
45
46#endif // PERSISTENTSETTINGS_H
47