diff options
Diffstat (limited to 'framework/settings/settings.h')
-rw-r--r-- | framework/settings/settings.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/framework/settings/settings.h b/framework/settings/settings.h new file mode 100644 index 00000000..bfee55cb --- /dev/null +++ b/framework/settings/settings.h | |||
@@ -0,0 +1,89 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include <QObject> | ||
22 | #include <QByteArray> | ||
23 | #include <QSettings> | ||
24 | #include <QSharedPointer> | ||
25 | |||
26 | namespace Kube { | ||
27 | |||
28 | class Settings : public QObject { | ||
29 | Q_OBJECT | ||
30 | Q_PROPERTY(QByteArray identifier READ identifier WRITE setIdentifier) | ||
31 | public: | ||
32 | Settings(QObject *parent = 0); | ||
33 | Settings(const QByteArray &id, QObject *parent = 0); | ||
34 | virtual ~Settings(); | ||
35 | Settings(const Settings&); | ||
36 | |||
37 | void setIdentifier(const QByteArray &id); | ||
38 | QByteArray identifier() const; | ||
39 | |||
40 | Q_INVOKABLE void save(); | ||
41 | private: | ||
42 | void load(); | ||
43 | QSharedPointer<QSettings> getSettings(); | ||
44 | QByteArray mIdentifier; | ||
45 | }; | ||
46 | |||
47 | class Account; | ||
48 | class Identity; | ||
49 | class Transport; | ||
50 | |||
51 | class ApplicationContext : public Settings | ||
52 | { | ||
53 | Q_OBJECT | ||
54 | public: | ||
55 | ApplicationContext(); | ||
56 | Account currentAccount() const; | ||
57 | |||
58 | }; | ||
59 | |||
60 | class Account : public Settings | ||
61 | { | ||
62 | Q_OBJECT | ||
63 | public: | ||
64 | Account(const QByteArray &identifier); | ||
65 | Identity primaryIdentity() const; | ||
66 | }; | ||
67 | |||
68 | class Identity : public Settings | ||
69 | { | ||
70 | Q_OBJECT | ||
71 | public: | ||
72 | Identity(const QByteArray &identifier); | ||
73 | Transport transport() const; | ||
74 | }; | ||
75 | |||
76 | class Transport : public Settings | ||
77 | { | ||
78 | Q_OBJECT | ||
79 | public: | ||
80 | Transport(const QByteArray &identifier); | ||
81 | QByteArray username() const; | ||
82 | QByteArray password() const; | ||
83 | QByteArray server() const; | ||
84 | }; | ||
85 | |||
86 | } | ||
87 | |||
88 | Q_DECLARE_METATYPE(Kube::Settings*); | ||
89 | |||