File indexing completed on 2024-09-29 13:11:34
0001 /* 0002 * SPDX-FileCopyrightText: 2020 Red Hat Inc 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 * 0006 * SPDX-FileCopyrightText: 2020 Jan Grulich <jgrulich@redhat.com> 0007 */ 0008 0009 #ifndef XDG_DESKTOP_PORTAL_KDE_BACKGROUND_H 0010 #define XDG_DESKTOP_PORTAL_KDE_BACKGROUND_H 0011 0012 #include <QDBusAbstractAdaptor> 0013 #include <QDBusContext> 0014 #include <QDBusObjectPath> 0015 #include <QSet> 0016 0017 namespace KWayland 0018 { 0019 namespace Client 0020 { 0021 class PlasmaWindow; 0022 } 0023 } 0024 0025 class KNotification; 0026 0027 class BackgroundPortal : public QDBusAbstractAdaptor 0028 { 0029 Q_OBJECT 0030 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.impl.portal.Background") 0031 public: 0032 explicit BackgroundPortal(QObject *parent, QDBusContext *context); 0033 ~BackgroundPortal() override; 0034 0035 enum ApplicationState { 0036 Background = 0, 0037 Running = 1, 0038 Active = 2, 0039 }; 0040 0041 enum AutostartFlag { 0042 None = 0x0, 0043 Activatable = 0x1, 0044 }; 0045 Q_DECLARE_FLAGS(AutostartFlags, AutostartFlag) 0046 0047 enum NotifyResult { 0048 Forbid = 0, 0049 Allow = 1, 0050 AllowOnce = 2, 0051 }; 0052 0053 public Q_SLOTS: 0054 QVariantMap GetAppState(); 0055 0056 uint NotifyBackground(const QDBusObjectPath &handle, const QString &app_id, const QString &name, QVariantMap &results); 0057 0058 bool EnableAutostart(const QString &app_id, bool enable, const QStringList &commandline, uint flags); 0059 Q_SIGNALS: 0060 void RunningApplicationsChanged(); 0061 0062 private: 0063 void addWindow(KWayland::Client::PlasmaWindow *window); 0064 void setActiveWindow(const QString &appId, bool active); 0065 0066 uint m_notificationCounter = 0; 0067 QList<KWayland::Client::PlasmaWindow *> m_windows; 0068 QVariantMap m_appStates; 0069 QSet<QString> m_backgroundAppWarned; 0070 QDBusContext *const m_context; 0071 }; 0072 Q_DECLARE_OPERATORS_FOR_FLAGS(BackgroundPortal::AutostartFlags) 0073 0074 #endif // XDG_DESKTOP_PORTAL_KDE_BACKGROUND_H