Solid

inhibition.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_INHIBITION_H
8#define SOLID_INHIBITION_H
9
10#include <QObject>
11
12#include "solid_export.h"
13
14namespace Solid
15{
16class InhibitionPrivate;
17class AbstractInhibition;
18/**
19 * Holds an inhibition
20 *
21 * This object is returned by Power::InhibitionJob::inhibition and it
22 * holds a reference to the inhibition that has been performed.
23 *
24 * When this object is deleted the inhibition will be released
25 */
26class SOLID_EXPORT Inhibition : public QObject
27{
28 Q_OBJECT
29 Q_PROPERTY(State state READ state NOTIFY stateChanged)
30public:
31 enum State {
32 Stopped = 0,
33 Started = 1,
34 };
35 Q_ENUM(State)
36
37 /**
38 * This is meant to be instantiated by backends only
39 *
40 * AbstractInhibition is not part of Solid public API so this
41 * constructor is meant to be used only by backends.
42 */
43 explicit Inhibition(AbstractInhibition *backend, QObject *parent = nullptr);
44 virtual ~Inhibition();
45
46 /**
47 * Returns the current state of the object
48 *
49 * The initial value is Started since that is how InhibitionJob will
50 * return it. The state can be modified by calling stop() and start().
51 * Also stateChanged() signal is available.
52 */
53 State state() const;
54
55public Q_SLOTS:
56 /**
57 * Stops the inhibition
58 *
59 * In case the state() is Started, it will stop the inhibition.
60 * This happens asynchronously so connect to stateChanged() signal to know
61 * when stop() has changed the state.
62 */
63 void stop();
64
65 /**
66 * Starts the inhibition
67 *
68 * In case state() is Stopped, it will resume the inhibition.
69 * This happens asynchronously so connect to stateChanged() signal to
70 * know when start() has changed the state.
71 */
72 void start();
73
74protected:
75 InhibitionPrivate *const d_ptr;
76
77Q_SIGNALS:
78 void stateChanged(Inhibition::State newState);
79};
80}
81
82#endif // SOLID_INHIBITION_H
Represents an inhibition, allows to stop and start it.
Holds an inhibition.
Definition inhibition.h:27
void stop(Ekos::AlignState mode)
Q_SCRIPTABLE Q_NOREPLY void start()
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 Tue Mar 26 2024 11:17:12 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.