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
qgnomeportalinterface_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 QGNOMEPORTALINTERFACE_P_H
6#define QGNOMEPORTALINTERFACE_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 <QtCore/qtconfigmacros.h>
21
22#include <QtCore/QObject>
23#include <QtGui/private/qdbuslistener_p.h>
24
26
27class Q_GUI_EXPORT QGnomePortalInterface : public QObject
28{
29 Q_OBJECT
30
31public:
32 QGnomePortalInterface(QObject *parent = nullptr);
33 ~QGnomePortalInterface() = default;
34
35 Qt::ColorScheme colorScheme(Qt::ColorScheme fallback = Qt::ColorScheme::Unknown) const;
36 Qt::ContrastPreference contrastPreference(
37 Qt::ContrastPreference fallback = Qt::ContrastPreference::NoPreference) const;
38
39private:
40 void querySettings();
41 void updateColorScheme(Qt::ColorScheme colorScheme);
42 void updateContrast(Qt::ContrastPreference contrast);
43
44Q_SIGNALS:
45 void colorSchemeChanged(Qt::ColorScheme);
46 void contrastChanged(Qt::ContrastPreference);
47 void themeNameChanged(const QString &themeName);
48
49private Q_SLOTS:
50 void dbusSettingChanged(QDBusListener::Provider, QDBusListener::Setting, const QVariant &value);
51
52private:
53 mutable uint m_version = 0; // cached version value
54 std::optional<Qt::ColorScheme> m_colorScheme;
55 std::optional<Qt::ContrastPreference> m_contrast;
56 std::unique_ptr<QDBusListener> m_dbus;
57 static constexpr QLatin1StringView s_service{ "org.freedesktop.portal.Desktop" };
58 static constexpr QLatin1StringView s_path{ "/org/freedesktop/portal/desktop" };
59 static constexpr QLatin1StringView s_interface{ "org.freedesktop.portal.Settings" };
60};
61
62QT_END_NAMESPACE
63
64#endif // QGNOMEPORTALINTERFACE_P_H
QT_REQUIRE_CONFIG(dbus)