Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdbuslistener_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QDBUSLISTENER_P_H
6#define QDBUSLISTENER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <qpa/qplatformtheme.h>
20#include <private/qflatmap_p.h>
21#include <QDBusVariant>
22
23QT_BEGIN_NAMESPACE
24
25class QDBusListener : public QObject
26{
27 Q_OBJECT
28
29public:
30
31 enum class Provider {
32 Kde,
33 Gtk,
34 Gnome,
35 };
36 Q_ENUM(Provider)
37
38 enum class Setting {
39 Theme,
40 ApplicationStyle,
41 ColorScheme,
42 Contrast,
43 };
44 Q_ENUM(Setting)
45
46 QDBusListener();
47 QDBusListener(const QString &service, const QString &path,
48 const QString &interface, const QString &signal);
49
50private Q_SLOTS:
51 void onSettingChanged(const QString &location, const QString &key, const QDBusVariant &value);
52
53Q_SIGNALS:
54 void settingChanged(QDBusListener::Provider provider,
55 QDBusListener::Setting setting,
56 const QVariant &value);
57
58private:
59 struct DBusKey
60 {
61 QString location;
62 QString key;
63 DBusKey(const QString &loc, const QString &k) : location(loc), key(k) {};
64 bool operator<(const DBusKey &other) const
65 {
66 return location + key < other.location + other.key;
67 }
68 };
69
70 struct ChangeSignal
71 {
72 Provider provider;
73 Setting setting;
74 ChangeSignal(Provider p, Setting s) : provider(p), setting(s) {}
75 };
76
77 QFlatMap <DBusKey, ChangeSignal> m_signalMap;
78
79 void init(const QString &service, const QString &path,
80 const QString &interface, const QString &signal);
81
82 std::optional<ChangeSignal> findSignal(const QString &location, const QString &key) const;
83 void populateSignalMap();
84 void loadJson(const QString &fileName);
85 void saveJson(const QString &fileName) const;
86};
87
88QT_END_NAMESPACE
89#endif // QDBUSLISTENER_P_H
\inmodule QtCore\reentrant
#define CHECK(cvref)
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")
#define LOG
#define PARSE(var, enumeration, string)