KCGroups

kapplicationscopelister.h
1 // SPDX-FileCopyrightText: 2020 Henri Chain <[email protected]>
2 // SPDX-FileCopyrightText: 2020 Kevin Ottens <[email protected]>
3 //
4 // SPDX-License-Identifier: LGPL-2.1-or-later
5 
6 #ifndef KAPPLICATIONSCOPELISTER_H
7 #define KAPPLICATIONSCOPELISTER_H
8 
9 #include "kcgroups_export.h"
10 #include <QObject>
11 
12 class KApplicationScopeListerPrivate;
13 
14 /**
15  * @brief Keeps an updated list of desktop application systemd scopes
16  */
17 class KCGROUPS_EXPORT KApplicationScopeLister : public QObject
18 {
19  Q_OBJECT
20 
21  /**
22  * @brief code of the last error that occurred (NoError if none)
23  * @accessors lastError()
24  * @notifySignal errorOccurred
25  */
26  Q_PROPERTY(ErrorCode lastError READ lastError NOTIFY errorOccurred)
27 
28  /**
29  * @brief list of dbus paths that corresponds to currently running applications
30  * @accessors paths()
31  * @notifySignal pathsChanged()
32  */
33  Q_PROPERTY(QStringList paths READ paths NOTIFY pathsChanged)
34 
35 public:
36  /**
37  * @brief The types of error that can occur
38  */
39  enum ErrorCode {
40  /**
41  * Default value. no error occurred
42  */
44 
45  /**
46  * Error while listing applications
47  */
49 
50  /**
51  * Error while trying to subscribe to systemd manager signals
52  */
53  CannotSubscribeError
54  };
55  Q_ENUM(ErrorCode)
56 
57  explicit KApplicationScopeLister(QObject *parent = nullptr);
58  ~KApplicationScopeLister() override;
59 
60  QStringList paths() const;
61  ErrorCode lastError() const;
62 
63 Q_SIGNALS:
64  /**
65  * @brief emitted when there is an error
66  * @param lastError: the error code
67  */
68  void errorOccurred(KApplicationScopeLister::ErrorCode lastError);
69 
70  /**
71  * @brief emitted when a path is added or removed
72  * @param paths: the new list of paths
73  */
74  void pathsChanged(const QStringList &paths);
75 
76  /**
77  * @brief emitted when a new application is launched
78  * @param path: dbus path of new application
79  * @param id: unit id of new application
80  */
81  void pathAdded(const QString &path, const QString &id);
82 
83  /**
84  * @brief emitted when an application is stopped
85  * @param path: dbus path of stopped application
86  */
87  void pathRemoved(const QString &path);
88 
89 private:
90  KApplicationScopeListerPrivate *const d;
91 };
92 
93 #endif // KAPPLICATIONSCOPELISTER_H
Q_PROPERTY(...)
Q_ENUM(...)
Keeps an updated list of desktop application systemd scopes.
ErrorCode
The types of error that can occur.
Q_SIGNALSQ_SIGNALS
@ CannotListError
Error while listing applications.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Dec 1 2023 04:13:56 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.