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(cycleCountChanged(int, QString)), this, SIGNAL(cycleCountChanged(int, QString)));
25
26 connect(backendObject, SIGNAL(powerSupplyStateChanged(bool, QString)), this, SIGNAL(powerSupplyStateChanged(bool, QString)));
27
28 connect(backendObject, SIGNAL(chargeStateChanged(int, QString)), this, SIGNAL(chargeStateChanged(int, QString)));
29
30 connect(backendObject, SIGNAL(timeToEmptyChanged(qlonglong, QString)), this, SIGNAL(timeToEmptyChanged(qlonglong, QString)));
31
32 connect(backendObject, SIGNAL(timeToFullChanged(qlonglong, QString)), this, SIGNAL(timeToFullChanged(qlonglong, QString)));
33
34 connect(backendObject, SIGNAL(energyChanged(double, QString)), this, SIGNAL(energyChanged(double, QString)));
35
36 connect(backendObject, SIGNAL(energyFullChanged(double, QString)), this, SIGNAL(energyFullChanged(double, QString)));
37
38 connect(backendObject, SIGNAL(energyFullDesignChanged(double, QString)), this, SIGNAL(energyFullDesignChanged(double, QString)));
39
40 connect(backendObject, SIGNAL(energyRateChanged(double, QString)), this, SIGNAL(energyRateChanged(double, QString)));
41
42 connect(backendObject, SIGNAL(voltageChanged(double, QString)), this, SIGNAL(voltageChanged(double, QString)));
43
44 connect(backendObject, SIGNAL(temperatureChanged(double, QString)), this, SIGNAL(temperatureChanged(double, QString)));
45
46 connect(backendObject, SIGNAL(remainingTimeChanged(qlonglong, QString)), this, SIGNAL(remainingTimeChanged(qlonglong, QString)));
47}
48
52
54{
55 Q_D(const Battery);
56 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), false, isPresent());
57}
58
59Solid::Battery::BatteryType Solid::Battery::type() const
60{
61 Q_D(const Battery);
62 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), UnknownBattery, type());
63}
64
65int Solid::Battery::chargePercent() const
66{
67 Q_D(const Battery);
68 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, chargePercent());
69}
70
71int Solid::Battery::capacity() const
72{
73 Q_D(const Battery);
74 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 100, capacity());
75}
76
77int Solid::Battery::cycleCount() const
78{
79 Q_D(const Battery);
80 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), -1, cycleCount());
81}
82
84{
85 Q_D(const Battery);
86 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), false, isRechargeable());
87}
88
90{
91 Q_D(const Battery);
92 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), true, isPowerSupply());
93}
94
95Solid::Battery::ChargeState Solid::Battery::chargeState() const
96{
97 Q_D(const Battery);
98 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), NoCharge, chargeState());
99}
100
101qlonglong Solid::Battery::timeToEmpty() const
102{
103 Q_D(const Battery);
104 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, timeToEmpty());
105}
106
107qlonglong Solid::Battery::timeToFull() const
108{
109 Q_D(const Battery);
110 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, timeToFull());
111}
112
113Solid::Battery::Technology Solid::Battery::technology() const
114{
115 Q_D(const Battery);
116 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), UnknownTechnology, technology());
117}
118
119double Solid::Battery::energy() const
120{
121 Q_D(const Battery);
122 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energy());
123}
124
125double Solid::Battery::energyFull() const
126{
127 Q_D(const Battery);
128 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyFull());
129}
130
131double Solid::Battery::energyFullDesign() const
132{
133 Q_D(const Battery);
134 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyFullDesign());
135}
136
137double Solid::Battery::energyRate() const
138{
139 Q_D(const Battery);
140 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyRate());
141}
142
143double Solid::Battery::voltage() const
144{
145 Q_D(const Battery);
146 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, voltage());
147}
148
149double Solid::Battery::temperature() const
150{
151 Q_D(const Battery);
152 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, temperature());
153}
154
155QString Solid::Battery::serial() const
156{
157 Q_D(const Battery);
158 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), QString(), serial());
159}
160
161qlonglong Solid::Battery::remainingTime() const
162{
163 Q_D(const Battery);
164 return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), -1, remainingTime());
165}
166
167#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 Sat Dec 21 2024 17:03:23 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.