Solid

frontend/battery.cpp
1/*
2 SPDX-FileCopyrightText: 2006-2007 Kevin Ottens <ervin@kde.org>
3 SPDX-FileCopyrightText: 2012 Lukas Tinkl <ltinkl@redhat.com>
4 SPDX-FileCopyrightText: 2014 Kai Uwe Broulik <kde@privat.broulik.de>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7*/
8
9#include "battery.h"
10#include "battery_p.h"
11
12#include "soliddefs_p.h"
13#include <solid/devices/ifaces/battery.h>
14
15Solid::Battery::Battery(QObject *backendObject)
16 : DeviceInterface(*new BatteryPrivate(), backendObject)
17{
18 connect(backendObject, SIGNAL(presentStateChanged(bool, QString)), this, SIGNAL(presentStateChanged(bool, QString)));
19
20 connect(backendObject, SIGNAL(chargePercentChanged(int, QString)), this, SIGNAL(chargePercentChanged(int, QString)));
21
22 connect(backendObject, SIGNAL(capacityChanged(int, QString)), this, SIGNAL(capacityChanged(int, QString)));
23
24 connect(backendObject, SIGNAL(powerSupplyStateChanged(bool, QString)), this, SIGNAL(powerSupplyStateChanged(bool, QString)));
25
26 connect(backendObject, SIGNAL(chargeStateChanged(int, QString)), this, SIGNAL(chargeStateChanged(int, QString)));
27
28 connect(backendObject, SIGNAL(timeToEmptyChanged(qlonglong, QString)), this, SIGNAL(timeToEmptyChanged(qlonglong, QString)));
29
30 connect(backendObject, SIGNAL(timeToFullChanged(qlonglong, QString)), this, SIGNAL(timeToFullChanged(qlonglong, QString)));
31
32 connect(backendObject, SIGNAL(energyChanged(double, QString)), this, SIGNAL(energyChanged(double, QString)));
33
34 connect(backendObject, SIGNAL(energyFullChanged(double, QString)), this, SIGNAL(energyFullChanged(double, QString)));
35
36 connect(backendObject, SIGNAL(energyFullDesignChanged(double, QString)), this, SIGNAL(energyFullDesignChanged(double, QString)));
37
38 connect(backendObject, SIGNAL(energyRateChanged(double, QString)), this, SIGNAL(energyRateChanged(double, QString)));
39
40 connect(backendObject, SIGNAL(voltageChanged(double, QString)), this, SIGNAL(voltageChanged(double, QString)));
41
42 connect(backendObject, SIGNAL(temperatureChanged(double, QString)), this, SIGNAL(temperatureChanged(double, QString)));
43
44 connect(backendObject, SIGNAL(remainingTimeChanged(qlonglong, QString)), this, SIGNAL(remainingTimeChanged(qlonglong, QString)));
45}
46
50
52{
53 Q_D(const Battery);
54 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), false, isPresent());
55}
56
57Solid::Battery::BatteryType Solid::Battery::type() const
58{
59 Q_D(const Battery);
60 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), UnknownBattery, type());
61}
62
63int Solid::Battery::chargePercent() const
64{
65 Q_D(const Battery);
66 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, chargePercent());
67}
68
69int Solid::Battery::capacity() const
70{
71 Q_D(const Battery);
72 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 100, capacity());
73}
74
76{
77 Q_D(const Battery);
78 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), false, isRechargeable());
79}
80
82{
83 Q_D(const Battery);
84 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), true, isPowerSupply());
85}
86
87Solid::Battery::ChargeState Solid::Battery::chargeState() const
88{
89 Q_D(const Battery);
90 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), NoCharge, chargeState());
91}
92
93qlonglong Solid::Battery::timeToEmpty() const
94{
95 Q_D(const Battery);
96 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, timeToEmpty());
97}
98
99qlonglong Solid::Battery::timeToFull() const
100{
101 Q_D(const Battery);
102 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, timeToFull());
103}
104
105Solid::Battery::Technology Solid::Battery::technology() const
106{
107 Q_D(const Battery);
108 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), UnknownTechnology, technology());
109}
110
111double Solid::Battery::energy() const
112{
113 Q_D(const Battery);
114 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energy());
115}
116
117double Solid::Battery::energyFull() const
118{
119 Q_D(const Battery);
120 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyFull());
121}
122
123double Solid::Battery::energyFullDesign() const
124{
125 Q_D(const Battery);
126 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyFullDesign());
127}
128
129double Solid::Battery::energyRate() const
130{
131 Q_D(const Battery);
132 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyRate());
133}
134
135double Solid::Battery::voltage() const
136{
137 Q_D(const Battery);
138 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, voltage());
139}
140
141double Solid::Battery::temperature() const
142{
143 Q_D(const Battery);
144 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, temperature());
145}
146
147QString Solid::Battery::serial() const
148{
149 Q_D(const Battery);
150 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), QString(), serial());
151}
152
153qlonglong Solid::Battery::remainingTime() const
154{
155 Q_D(const Battery);
156 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), -1, remainingTime());
157}
158
159#include "moc_battery.cpp"
This device interface is available on batteries.
BatteryType
This enum type defines the type of the device holding the battery.
bool isPresent() const
Indicates if this battery is currently present in its bay.
Technology
Technology used in the battery.
bool isRechargeable() const
Indicates if the battery is rechargeable.
~Battery() override
Destroys a Battery object.
bool isPowerSupply() const
Indicates if the battery is powering the machine.
ChargeState
This enum type defines charge state of a battery.
This device interface is available on batteries.
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.