Solid

inhibitionjob.h
1/*
2 SPDX-FileCopyrightText: 2014 Alejandro Fiestas Olivares <afiestas@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef SOLID_ADD_INHIBITION_JOB
8#define SOLID_ADD_INHIBITION_JOB
9
10#include "power.h"
11
12#include <solid/job.h>
13
14#include "solid_export.h"
15
16namespace Solid
17{
18class Inhibition;
19class InhibitionJobPrivate;
20class SOLID_EXPORT InhibitionJob : public Job
21{
22 Q_OBJECT
23public:
24 enum Error {
25 InvalidInhibitions = Job::UserDefinedError,
26 EmptyDescription,
27 };
28 Q_ENUM(Error)
29
30 /**
31 * Instantiate InhibitionJob
32 *
33 * When this job emits result(Solid::Job*) and in case no
34 * error has happened, an Inhibition object will be
35 * returned using inhibition(). Delete the returned object
36 * as soon as the inhibition should be released.
37 *
38 * At least one action to inhibit and description should be
39 * added.
40 */
41 explicit InhibitionJob(QObject *parent = nullptr);
42
43 /**
44 * Sets th list of action to inhibit
45 *
46 * @param inhibitions list of actions to inhibit
47 */
48 void setInhibitions(Power::InhibitionTypes inhibitions);
49
50 /**
51 * Returns the list of actions this job will inhibit
52 *
53 * @return List of Power::Imhibitions
54 */
55 Power::InhibitionTypes inhibitions() const;
56
57 /**
58 * Sets the description of this inhibition
59 *
60 * @param description explains why the inhibition is required
61 */
62 void setDescription(const QString &description);
63
64 /**
65 * Returns the description to be used
66 */
67 QString description() const;
68
69 /**
70 * Returns the inhibition
71 *
72 * The result of this job is an object called Inhibition
73 * which should be kept as long as the inhibition is desired.
74 *
75 * If this method is called before result(Solid::Job*) is emitted,
76 * it will return nullptr.
77 */
78 Inhibition *inhibition() const;
79
80private Q_SLOTS:
81 void doStart() override;
82
83 /**
84 * We have to re-declare the signal because
85 * if not, Q_PROPERTY wouldn't work.
86 */
87Q_SIGNALS:
88 void result(Solid::Job *);
89
90private:
91 Q_DECLARE_PRIVATE(InhibitionJob)
92};
93}
94#endif // SOLID_ADD_INHIBITION_JOB
This class represents an asynchronous job performed by Solid, it is usually not used directly but ins...
Definition job.h:37
The single responsibility of this class is to create arguments valid for logind Inhibit call.
Definition fakebattery.h:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:56:28 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.