Solid

frontend/battery.cpp
1 /*
2  SPDX-FileCopyrightText: 2006-2007 Kevin Ottens <[email protected]>
3  SPDX-FileCopyrightText: 2012 Lukas Tinkl <[email protected]>
4  SPDX-FileCopyrightText: 2014 Kai Uwe Broulik <[email protected]>
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 
15 Solid::Battery::Battery(QObject *backendObject)
16  : DeviceInterface(*new BatteryPrivate(), backendObject)
17 {
18  connect(backendObject, SIGNAL(presentStateChanged(bool,QString)),
19  this, SIGNAL(presentStateChanged(bool,QString)));
20 
21  connect(backendObject, SIGNAL(chargePercentChanged(int,QString)),
22  this, SIGNAL(chargePercentChanged(int,QString)));
23 
24  connect(backendObject, SIGNAL(capacityChanged(int,QString)),
25  this, SIGNAL(capacityChanged(int,QString)));
26 
27  connect(backendObject, SIGNAL(powerSupplyStateChanged(bool,QString)),
28  this, SIGNAL(powerSupplyStateChanged(bool,QString)));
29 
30  connect(backendObject, SIGNAL(chargeStateChanged(int,QString)),
31  this, SIGNAL(chargeStateChanged(int,QString)));
32 
33  connect(backendObject, SIGNAL(timeToEmptyChanged(qlonglong,QString)),
34  this, SIGNAL(timeToEmptyChanged(qlonglong,QString)));
35 
36  connect(backendObject, SIGNAL(timeToFullChanged(qlonglong,QString)),
37  this, SIGNAL(timeToFullChanged(qlonglong,QString)));
38 
39  connect(backendObject, SIGNAL(energyChanged(double,QString)),
40  this, SIGNAL(energyChanged(double,QString)));
41 
42  connect(backendObject, SIGNAL(energyFullChanged(double,QString)),
43  this, SIGNAL(energyFullChanged(double,QString)));
44 
45  connect(backendObject, SIGNAL(energyFullDesignChanged(double,QString)),
46  this, SIGNAL(energyFullDesignChanged(double,QString)));
47 
48  connect(backendObject, SIGNAL(energyRateChanged(double,QString)),
49  this, SIGNAL(energyRateChanged(double,QString)));
50 
51  connect(backendObject, SIGNAL(voltageChanged(double,QString)),
52  this, SIGNAL(voltageChanged(double,QString)));
53 
54  connect(backendObject, SIGNAL(temperatureChanged(double,QString)),
55  this, SIGNAL(temperatureChanged(double,QString)));
56 
57  connect(backendObject, SIGNAL(remainingTimeChanged(qlonglong,QString)),
58  this, SIGNAL(remainingTimeChanged(qlonglong,QString)));
59 }
60 
62 {
63 
64 }
65 
67 {
68  Q_D(const Battery);
69  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), false, isPresent());
70 }
71 
73 {
74  Q_D(const Battery);
75  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), UnknownBattery, type());
76 }
77 
79 {
80  Q_D(const Battery);
81  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, chargePercent());
82 }
83 
84 int Solid::Battery::capacity() const
85 {
86  Q_D(const Battery);
87  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 100, capacity());
88 }
89 
91 {
92  Q_D(const Battery);
93  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), false, isRechargeable());
94 }
95 
97 {
98  Q_D(const Battery);
99  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), true, isPowerSupply());
100 }
101 
103 {
104  Q_D(const Battery);
105  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), NoCharge, chargeState());
106 }
107 
108 qlonglong Solid::Battery::timeToEmpty() const
109 {
110  Q_D(const Battery);
111  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, timeToEmpty());
112 }
113 
114 qlonglong Solid::Battery::timeToFull() const
115 {
116  Q_D(const Battery);
117  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0, timeToFull());
118 }
119 
121 {
122  Q_D(const Battery);
123  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), UnknownTechnology, technology());
124 }
125 
126 double Solid::Battery::energy() const
127 {
128  Q_D(const Battery);
129  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energy());
130 }
131 
132 double Solid::Battery::energyFull() const
133 {
134  Q_D(const Battery);
135  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyFull());
136 }
137 
139 {
140  Q_D(const Battery);
141  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyFullDesign());
142 }
143 
144 double Solid::Battery::energyRate() const
145 {
146  Q_D(const Battery);
147  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, energyRate());
148 }
149 
150 double Solid::Battery::voltage() const
151 {
152  Q_D(const Battery);
153  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, voltage());
154 }
155 
156 double Solid::Battery::temperature() const
157 {
158  Q_D(const Battery);
159  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), 0.0, temperature());
160 }
161 
163 {
164  Q_D(const Battery);
165  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), false, isRecalled());
166 }
167 
169 {
170  Q_D(const Battery);
171  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), QString(), recallVendor());
172 }
173 
175 {
176  Q_D(const Battery);
177  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), QString(), recallUrl());
178 }
179 
181 {
182  Q_D(const Battery);
183  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), QString(), serial());
184 }
185 
186 qlonglong Solid::Battery::remainingTime() const
187 {
188  Q_D(const Battery);
189  return_SOLID_CALL(Ifaces::Battery *, d->backendObject(), -1, remainingTime());
190 }
qlonglong timeToEmpty() const
Time (in seconds) until the battery is empty.
bool isPresent() const
Indicates if this battery is currently present in its bay.
Solid::Battery::Technology technology() const
Retrieves the technology used to manufacture the battery.
double voltage() const
Voltage in the Cell or being recorded by the meter.
QString recallVendor() const
The vendor that has recalled the battery.
double energyFull() const
Amount of energy (measured in Wh) the battery has when it is full.
qlonglong timeToFull() const
Time (in seconds) until the battery is full.
int chargePercent() const
Retrieves the current charge level of the battery normalised to percent.
double energyRate() const
Amount of energy being drained from the source, measured in W.
double temperature() const
The temperature of the battery in degrees Celsius.
This device interface is available on batteries.
QString recallUrl() const
The website URL of the vendor that has recalled the battery.
double energy() const
Amount of energy (measured in Wh) currently available in the power source.
Solid::Battery::BatteryType type() const
Retrieves the type of device holding this battery.
int capacity() const
Retrieves the battery capacity normalised to percent, meaning how much energy can it hold compared to...
Technology
Technology used in the battery.
bool isRecalled() const
The battery may have been recalled by the vendor due to a suspected fault.
virtual ~Battery()
Destroys a Battery object.
bool isRechargeable() const
Indicates if the battery is rechargeable.
ChargeState
This enum type defines charge state of a battery.
qlonglong remainingTime() const
Retrieves the current estimated remaining time of the system batteries.
QString serial() const
The serial number of the battery.
bool isPowerSupply() const
Indicates if the battery is powering the machine.
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
double energyFullDesign() const
Amount of energy (measured in Wh) the battery should have by design hen it is full.
Solid::Battery::ChargeState chargeState() const
Retrieves the current charge state of the battery.
BatteryType
This enum type defines the type of the device holding the battery.
This device interface is available on batteries.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Sep 19 2020 22:49:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.