tsettings.h - sailfish-safe - Sailfish frontend for safe(1)
(HTM) git clone git://git.z3bra.org/sailfish-safe.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
tsettings.h (1493B)
---
1 /*
2 * Copyright (C) 2019 Daniel Vrátil <dvratil@kde.org>
3 * 2021 Willy Goiffon <contact@z3bra.org>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19 #ifndef SETTINGS_H
20 #define SETTINGS_H
21
22 #include <QObject>
23 #include <QSettings>
24
25 #include <memory>
26
27 #define DECLARE_OPTION(type, lc, uc) \
28 private: Q_PROPERTY(type lc READ lc WRITE set##uc NOTIFY lc##Changed) \
29 public: type lc() const; \
30 public: void set##uc(type val); \
31 Q_SIGNALS: void lc##Changed();
32
33
34 class Settings : public QObject
35 {
36 Q_OBJECT
37 public:
38 static Settings *self();
39 static void destroy();
40
41 Q_INVOKABLE void save();
42
43 DECLARE_OPTION(int, expirationTimeout, ExpirationTimeout)
44
45 private:
46 explicit Settings();
47 std::unique_ptr<QSettings> mSettings;
48
49 static std::unique_ptr<Settings> kInstance;
50 };
51
52 #undef DECLARE_OPTION
53
54 #endif // SETTINGS_H