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 Qt::MotionPreference motionPreference(
39 Qt::MotionPreference fallback = Qt::MotionPreference::NoPreference) const;
40
41private:
42 void querySettings();
43 void updateColorScheme(Qt::ColorScheme colorScheme);
44 void updateContrast(Qt::ContrastPreference contrast);
45 void updateMotion(Qt::MotionPreference motion);
46
47Q_SIGNALS:
48 void colorSchemeChanged(Qt::ColorScheme);
49 void contrastChanged(Qt::ContrastPreference);
50 void motionChanged(Qt::MotionPreference);
51 void themeNameChanged(const QString &themeName);
52
53private Q_SLOTS:
54 void dbusSettingChanged(QDBusListener::Provider, QDBusListener::Setting, const QVariant &value);
55
56private:
57 mutable uint m_version = 0; // cached version value
58 std::optional<Qt::ColorScheme> m_colorScheme;
59 std::optional<Qt::ContrastPreference> m_contrast;
60 std::optional<Qt::MotionPreference> m_motion;
61 std::unique_ptr<QDBusListener> m_dbus;
62 static constexpr QLatin1StringView s_service{ "org.freedesktop.portal.Desktop" };
63 static constexpr QLatin1StringView s_path{ "/org/freedesktop/portal/desktop" };
64 static constexpr QLatin1StringView s_interface{ "org.freedesktop.portal.Settings" };
65};
66
67QT_END_NAMESPACE
68
69#endif // QGNOMEPORTALINTERFACE_P_H
Combined button and popup list for selecting options.
QT_REQUIRE_CONFIG(dbus)