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
24class KColorSchemeWatcherPrivate
25{
26public:
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
43KColorSchemeWatcher::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
52KColorSchemeWatcher::~KColorSchemeWatcher()
53{
54}
55
56KColorSchemeWatcher::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

source code of kguiaddons/src/colors/kcolorschemewatcher.cpp