KCGroups

kapplicationscopelister.h
1// SPDX-FileCopyrightText: 2020 Henri Chain <henri.chain@enioka.com>
2// SPDX-FileCopyrightText: 2020 Kevin Ottens <kevin.ottens@enioka.com>
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
12class KApplicationScopeListerPrivate;
13
14/**
15 * @brief Keeps an updated list of desktop application systemd scopes
16 */
17class 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
35public:
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
64 /**
65 * @brief emitted when there is an error
66 * @param lastError: the error code
67 */
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
89private:
90 KApplicationScopeListerPrivate *const d;
91};
92
93#endif // KAPPLICATIONSCOPELISTER_H
Keeps an updated list of desktop application systemd scopes.
void pathRemoved(const QString &path)
emitted when an application is stopped
void pathsChanged(const QStringList &paths)
emitted when a path is added or removed
void errorOccurred(KApplicationScopeLister::ErrorCode lastError)
emitted when there is an error
void pathAdded(const QString &path, const QString &id)
emitted when a new application is launched
ErrorCode
The types of error that can occur.
@ CannotListError
Error while listing applications.
Q_ENUM(...)
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:41 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.