Solid

acpluggedjob.cpp
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#include "acpluggedjob.h"
8#include "acpluggedjob_p.h"
9#include "backends/abstractacpluggedjob.h"
10#include "powerbackendloader.h"
11
12#include <QDebug>
13
14using namespace Solid;
15
16AcPluggedJobPrivate::AcPluggedJobPrivate()
17{
18 backendJob = nullptr;
19 plugged = false;
20 backendJobFinished = false;
21}
22
23AcPluggedJob::AcPluggedJob(QObject *parent)
24 : Job(*new AcPluggedJobPrivate(), parent)
25{
26}
27
28void AcPluggedJob::doStart()
29{
30 Q_D(AcPluggedJob);
31 d->backendJob = PowerBackendLoader::AcPluggedJob();
32 connect(d->backendJob, &AbstractAcPluggedJob::result, [this, d]() {
33 d->backendJobFinished = true;
34 d->plugged = d->backendJob->isPlugged();
35 emitResult();
36 });
37
38 d->backendJob->start();
39}
40
41bool AcPluggedJob::isPlugged() const
42{
43 if (d_func()->backendJobFinished) {
44 return d_func()->plugged;
45 }
46 qWarning() << "isPlugged called without having called start";
47 return false;
48}
49
50#include "moc_acpluggedjob.cpp"
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
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
Q_D(Todo)
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.