1 | /* |
---|---|
2 | * SPDX-FileCopyrightText: 2021 Nicolas Fella <nicolas.fella@gmx.de> |
3 | * |
4 | * SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #include "kcolorschemewatcher.h" |
8 | |
9 | #include "kcolorschemewatcher_qt.h" |
10 | #include "kcolorschemewatcherbackend.h" |
11 | |
12 | #ifdef Q_OS_WINDOWS |
13 | #include "kcolorschemewatcher_win.h" |
14 | #endif |
15 | |
16 | #ifdef Q_OS_MACOS |
17 | #include "kcolorschemewatcher_mac.h" |
18 | #endif |
19 | |
20 | #ifdef QT_DBUS_LIB |
21 | #include "kcolorschemewatcher_xdg.h" |
22 | #endif |
23 | |
24 | class KColorSchemeWatcherPrivate |
25 | { |
26 | public: |
27 | std::unique_ptr<KColorSchemeWatcherBackend> backend; |
28 | |
29 | KColorSchemeWatcherPrivate() |
30 | { |
31 | #ifdef Q_OS_WINDOWS |
32 | backend = std::make_unique<KColorSchemeWatcherWin>(); |
33 | #elif defined(Q_OS_MACOS) |
34 | backend = std::make_unique<KColorSchemeWatcherMac>(); |
35 | #elif defined(QT_DBUS_LIB) |
36 | backend = std::make_unique<KColorSchemeWatcherXDG>(); |
37 | #else |
38 | backend = std::make_unique<KColorSchemeWatcherQt>(); |
39 | #endif |
40 | } |
41 | }; |
42 | |
43 | KColorSchemeWatcher::KColorSchemeWatcher(QObject *parent) |
44 | : QObject(parent) |
45 | , d(new KColorSchemeWatcherPrivate) |
46 | { |
47 | if (d->backend) { |
48 | connect(sender: d->backend.get(), signal: &KColorSchemeWatcherBackend::systemPreferenceChanged, context: this, slot: &KColorSchemeWatcher::systemPreferenceChanged); |
49 | } |
50 | } |
51 | |
52 | KColorSchemeWatcher::~KColorSchemeWatcher() |
53 | { |
54 | } |
55 | |
56 | KColorSchemeWatcher::ColorPreference KColorSchemeWatcher::systemPreference() const |
57 | { |
58 | if (d->backend) { |
59 | return d->backend->systemPreference(); |
60 | } |
61 | |
62 | return NoPreference; |
63 | } |
64 | |
65 | #include "moc_kcolorschemewatcher.cpp" |
66 |