File indexing completed on 2024-12-01 03:45:34
0001 /* 0002 SPDX-FileCopyrightText: 2014 Alejandro Fiestas Olivares <afiestas@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #ifndef SOLID_ADD_INHIBITION_JOB 0008 #define SOLID_ADD_INHIBITION_JOB 0009 0010 #include "power.h" 0011 0012 #include <solid/job.h> 0013 0014 #include "solid_export.h" 0015 0016 namespace Solid 0017 { 0018 class Inhibition; 0019 class InhibitionJobPrivate; 0020 class SOLID_EXPORT InhibitionJob : public Job 0021 { 0022 Q_OBJECT 0023 public: 0024 enum Error { 0025 InvalidInhibitions = Job::UserDefinedError, 0026 EmptyDescription, 0027 }; 0028 Q_ENUM(Error) 0029 0030 /** 0031 * Instantiate InhibitionJob 0032 * 0033 * When this job emits result(Solid::Job*) and in case no 0034 * error has happened, an Inhibition object will be 0035 * returned using inhibition(). Delete the returned object 0036 * as soon as the inhibition should be released. 0037 * 0038 * At least one action to inhibit and description should be 0039 * added. 0040 */ 0041 explicit InhibitionJob(QObject *parent = nullptr); 0042 0043 /** 0044 * Sets th list of action to inhibit 0045 * 0046 * @param inhibitions list of actions to inhibit 0047 */ 0048 void setInhibitions(Power::InhibitionTypes inhibitions); 0049 0050 /** 0051 * Returns the list of actions this job will inhibit 0052 * 0053 * @return List of Power::Imhibitions 0054 */ 0055 Power::InhibitionTypes inhibitions() const; 0056 0057 /** 0058 * Sets the description of this inhibition 0059 * 0060 * @param description explains why the inhibition is required 0061 */ 0062 void setDescription(const QString &description); 0063 0064 /** 0065 * Returns the description to be used 0066 */ 0067 QString description() const; 0068 0069 /** 0070 * Returns the inhibition 0071 * 0072 * The result of this job is an object called Inhibition 0073 * which should be kept as long as the inhibition is desired. 0074 * 0075 * If this method is called before result(Solid::Job*) is emitted, 0076 * it will return nullptr. 0077 */ 0078 Inhibition *inhibition() const; 0079 0080 private Q_SLOTS: 0081 void doStart() override; 0082 0083 /** 0084 * We have to re-declare the signal because 0085 * if not, Q_PROPERTY wouldn't work. 0086 */ 0087 Q_SIGNALS: 0088 void result(Solid::Job *); 0089 0090 private: 0091 Q_DECLARE_PRIVATE(InhibitionJob) 0092 }; 0093 } 0094 #endif // SOLID_ADD_INHIBITION_JOB