Changeset View
Changeset View
Standalone View
Standalone View
resources/pop3/settings.cpp
Show All 16 Lines | 1 | /* Copyright 2010 Thomas McGuire <mcguire@kde.org> | |||
---|---|---|---|---|---|
17 | Boston, MA 02110-1301, USA. | 17 | Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | #include "settings.h" | 19 | #include "settings.h" | ||
20 | #include "settingsadaptor.h" | 20 | #include "settingsadaptor.h" | ||
21 | 21 | | |||
22 | #include <KWallet> | 22 | #include <KWallet> | ||
23 | #include "pop3resource_debug.h" | 23 | #include "pop3resource_debug.h" | ||
24 | 24 | | |||
25 | class SettingsHelper | 25 | Settings::Settings(const KSharedConfigPtr &config, Options options) | ||
26 | { | | |||
27 | public: | | |||
28 | SettingsHelper() : q(nullptr) | | |||
29 | { | | |||
30 | } | | |||
31 | | ||||
32 | ~SettingsHelper() | | |||
33 | { | | |||
34 | qCWarning(POP3RESOURCE_LOG) << q; | | |||
35 | delete q; | | |||
36 | q = nullptr; | | |||
37 | } | | |||
38 | | ||||
39 | Settings *q; | | |||
40 | }; | | |||
41 | | ||||
42 | Q_GLOBAL_STATIC(SettingsHelper, s_globalSettings) | | |||
43 | | ||||
44 | Settings *Settings::self() | | |||
45 | { | | |||
46 | Q_ASSERT_X(s_globalSettings->q, "Settings::self()", "You must create an instance first!"); | | |||
47 | return s_globalSettings->q; | | |||
48 | } | | |||
49 | | ||||
50 | Settings::Settings(const KSharedConfigPtr &config) | | |||
51 | : SettingsBase(config) | 26 | : SettingsBase(config) | ||
52 | { | 27 | { | ||
53 | Q_ASSERT(!s_globalSettings->q); | 28 | if (options & Option::ExportToDBus) { | ||
54 | s_globalSettings->q = this; | | |||
55 | new SettingsAdaptor(this); | 29 | new SettingsAdaptor(this); | ||
56 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/Settings"), this, | 30 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/Settings"), this, | ||
57 | QDBusConnection::ExportAdaptors | QDBusConnection::ExportScriptableContents); | 31 | QDBusConnection::ExportAdaptors | QDBusConnection::ExportScriptableContents); | ||
58 | } | 32 | } | ||
33 | } | ||||
59 | 34 | | |||
60 | void Settings::setWindowId(WId id) | 35 | void Settings::setWindowId(WId id) | ||
61 | { | 36 | { | ||
62 | mWinId = id; | 37 | mWinId = id; | ||
63 | } | 38 | } | ||
64 | 39 | | |||
65 | void Settings::setResourceId(const QString &resourceIdentifier) | 40 | void Settings::setResourceId(const QString &resourceIdentifier) | ||
66 | { | 41 | { | ||
Show All 19 Lines |