Solid

inhibition.h
1 /*
2  SPDX-FileCopyrightText: 2014 Alejandro Fiestas Olivares <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #ifndef SOLID_INHIBITION_H
8 #define SOLID_INHIBITION_H
9 
10 #include <QObject>
11 
12 #include "solid_export.h"
13 
14 namespace Solid
15 {
16 
17 class InhibitionPrivate;
18 class AbstractInhibition;
19 /**
20  * Holds an inhibition
21  *
22  * This object is returned by Power::InhibitionJob::inhibition and it
23  * holds a reference to the inhibition that has been performed.
24  *
25  * When this object is deleted the inhibition will be released
26  */
27 class SOLID_EXPORT Inhibition : public QObject
28 {
29  Q_OBJECT
30  Q_PROPERTY(State state READ state NOTIFY stateChanged)
31 public:
32  enum State {
33  Stopped = 0,
34  Started = 1
35  };
36  Q_ENUM(State)
37 
38  /**
39  * This is meant to be instantiated by backends only
40  *
41  * AbstractInhibition is not part of Solid public API so this
42  * constructor is meant to be used only by backends.
43  */
44  explicit Inhibition(AbstractInhibition *backend, QObject *parent=0);
45  virtual ~Inhibition();
46 
47  /**
48  * Returns the current state of the object
49  *
50  * The initial value is Started since that is how InhibitionJob will
51  * return it. The state can be modified by calling stop() and start().
52  * Also stateChanged() signal is available.
53  */
54  State state() const;
55 
56 public Q_SLOTS:
57  /**
58  * Stops the inhibition
59  *
60  * In case the state() is Started, it will stop the inhibition.
61  * This happens asynchronously so connect to stateChanged() signal to know
62  * when stop() has changed the state.
63  */
64  void stop();
65 
66  /**
67  * Starts the inhibition
68  *
69  * In case state() is Stopped, it will resume the inhibition.
70  * This happens asynchronously so connect to stateChanged() signal to
71  * know when start() has changed the state.
72  */
73  void start();
74 
75 protected:
76  InhibitionPrivate *const d_ptr;
77 
78 Q_SIGNALS:
79  void stateChanged(Inhibition::State newState);
80 };
81 }
82 Q_DECLARE_METATYPE(Solid::Inhibition::State)
83 #endif //SOLID_INHIBITION_H
Holds an inhibition.
Definition: inhibition.h:27
Represents an inhibition, allows to stop and start it.
The single responsibility of this class is to create arguments valid for logind Inhibit call...
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Mar 4 2021 22:51:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.