summaryrefslogtreecommitdiffstats
path: root/framework/settings/settings.h
diff options
context:
space:
mode:
Diffstat (limited to 'framework/settings/settings.h')
-rw-r--r--framework/settings/settings.h89
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
26namespace Kube {
27
28class Settings : public QObject {
29 Q_OBJECT
30 Q_PROPERTY(QByteArray identifier READ identifier WRITE setIdentifier)
31public:
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();
41private:
42 void load();
43 QSharedPointer<QSettings> getSettings();
44 QByteArray mIdentifier;
45};
46
47class Account;
48class Identity;
49class Transport;
50
51class ApplicationContext : public Settings
52{
53 Q_OBJECT
54public:
55 ApplicationContext();
56 Account currentAccount() const;
57
58};
59
60class Account : public Settings
61{
62 Q_OBJECT
63public:
64 Account(const QByteArray &identifier);
65 Identity primaryIdentity() const;
66};
67
68class Identity : public Settings
69{
70 Q_OBJECT
71public:
72 Identity(const QByteArray &identifier);
73 Transport transport() const;
74};
75
76class Transport : public Settings
77{
78 Q_OBJECT
79public:
80 Transport(const QByteArray &identifier);
81 QByteArray username() const;
82 QByteArray password() const;
83 QByteArray server() const;
84};
85
86}
87
88Q_DECLARE_METATYPE(Kube::Settings*);
89