Solid::Battery Class
class Solid::BatteryThis device interface is available on batteries. More...
| Header: | #include <Solid/Battery> |
| CMake: | find_package(KF6 REQUIRED COMPONENTS Solid)target_link_libraries(mytarget PRIVATE KF6::Solid) |
| Inherits: | Solid::DeviceInterface |
Public Types
| enum | BatteryType { PdaBattery, UpsBattery, PrimaryBattery, MouseBattery, KeyboardBattery, …, UnknownBattery } |
| enum | ChargeState { NoCharge, Charging, Discharging, FullyCharged } |
| enum | Technology { UnknownTechnology, LithiumIon, LithiumPolymer, LithiumIronPhosphate, LeadAcid, …, NickelMetalHydride } |
Properties
|
|
Public Functions
| int | capacity() const |
| int | chargePercent() const |
| Solid::Battery::ChargeState | chargeState() const |
(since 6.9) int | cycleCount() const |
| double | energy() const |
| double | energyFull() const |
| double | energyFullDesign() const |
| double | energyRate() const |
| bool | isPowerSupply() const |
| bool | isPresent() const |
| bool | isRechargeable() const |
| qlonglong | remainingTime() const |
| QString | serial() const |
| Solid::Battery::Technology | technology() const |
| double | temperature() const |
| qlonglong | timeToEmpty() const |
| qlonglong | timeToFull() const |
| Solid::Battery::BatteryType | type() const |
| double | voltage() const |
Signals
| void | capacityChanged(int value, const QString &udi) |
| void | chargePercentChanged(int value, const QString &udi) |
| void | chargeStateChanged(int newState, const QString &udi = QString()) |
(since 6.9) void | cycleCountChanged(int value, const QString &udi) |
| void | energyChanged(double energy, const QString &udi) |
| void | energyFullChanged(double energy, const QString &udi) |
| void | energyFullDesignChanged(double energy, const QString &udi) |
| void | energyRateChanged(double energyRate, const QString &udi) |
| void | powerSupplyStateChanged(bool newState, const QString &udi) |
| void | presentStateChanged(bool newState, const QString &udi) |
| void | remainingTimeChanged(qlonglong time, const QString &udi) |
| void | temperatureChanged(double temperature, const QString &udi) |
| void | timeToEmptyChanged(qlonglong time, const QString &udi) |
| void | timeToFullChanged(qlonglong time, const QString &udi) |
| void | voltageChanged(double voltage, const QString &udi) |
Static Public Members
| Solid::DeviceInterface::Type | deviceInterfaceType() |
Detailed Description
Member Type Documentation
enum Battery::BatteryType
This enum type defines the type of the device holding the battery
| Constant | Value | Description |
|---|---|---|
Solid::Battery::PdaBattery | 1 | A battery in a Personal Digital Assistant |
Solid::Battery::UpsBattery | 2 | A battery in an Uninterruptible Power Supply |
Solid::Battery::PrimaryBattery | 3 | A primary battery for the system (for example laptop battery) |
Solid::Battery::MouseBattery | 4 | A battery in a mouse |
Solid::Battery::KeyboardBattery | 5 | A battery in a keyboard |
Solid::Battery::KeyboardMouseBattery | 6 | A battery in a combined keyboard and mouse |
Solid::Battery::CameraBattery | 7 | A battery in a camera |
Solid::Battery::PhoneBattery | 8 | A battery in a phone |
Solid::Battery::MonitorBattery | 9 | A battery in a monitor |
Solid::Battery::GamingInputBattery | 10 | A battery in a gaming input device (for example a wireless game pad) |
Solid::Battery::BluetoothBattery (since 5.54) | 11 | A generic Bluetooth device battery (if its type isn't known, a Bluetooth mouse would normally show up as a MouseBattery) |
Solid::Battery::TabletBattery (since 5.88) | 12 | A battery in a graphics tablet or pen |
Solid::Battery::HeadphoneBattery (since 6.0) | 13 | A battery in a headphone |
Solid::Battery::HeadsetBattery (since 6.0) | 14 | A battery in a headset |
Solid::Battery::TouchpadBattery (since 6.0) | 15 | A battery in a touchpad. This is how the Dualsense Wireless Controller is categorized |
Solid::Battery::WearableBattery (since 6.21) | 16 | A battery for a wearable device, watch... |
Solid::Battery::UnknownBattery | 0 | A battery in an unknown device |
enum Battery::ChargeState
This enum type defines charge state of a battery
| Constant | Value | Description |
|---|---|---|
Solid::Battery::NoCharge | 0 | Battery charge is stable, not charging or discharging or the state is Unknown |
Solid::Battery::Charging | 1 | Battery is charging |
Solid::Battery::Discharging | 2 | Battery is discharging |
Solid::Battery::FullyCharged | 3 | The battery is fully charged; a battery not necessarily charges up to 100% |
enum Battery::Technology
Technology used in the battery
| Constant | Value | Description |
|---|---|---|
Solid::Battery::UnknownTechnology | 0 | Unknown |
Solid::Battery::LithiumIon | 1 | Lithium ion |
Solid::Battery::LithiumPolymer | 2 | Lithium polymer |
Solid::Battery::LithiumIronPhosphate | 3 | Lithium iron phosphate |
Solid::Battery::LeadAcid | 4 | Lead acid |
Solid::Battery::NickelCadmium | 5 | Nickel cadmium |
Solid::Battery::NickelMetalHydride | 6 | Nickel metal hydride |
Property Documentation
[read-only] capacity : int
Access functions:
| int | capacity() const |
Notifier signal:
| void | capacityChanged(int value, const QString &udi) |
[read-only] chargePercent : int
Access functions:
| int | chargePercent() const |
Notifier signal:
| void | chargePercentChanged(int value, const QString &udi) |
[read-only] chargeState : ChargeState
Access functions:
| Solid::Battery::ChargeState | chargeState() const |
Notifier signal:
| void | chargeStateChanged(int newState, const QString &udi = QString()) |
[read-only] cycleCount : int
Access functions:
| int | cycleCount() const |
Notifier signal:
| void | cycleCountChanged(int value, const QString &udi) |
[read-only] energy : double
Access functions:
| double | energy() const |
Notifier signal:
| void | energyChanged(double energy, const QString &udi) |
[read-only] energyFull : double
Access functions:
| double | energyFull() const |
Notifier signal:
| void | energyFullChanged(double energy, const QString &udi) |
[read-only] energyFullDesign : double
Access functions:
| double | energyFullDesign() const |
Notifier signal:
| void | energyFullDesignChanged(double energy, const QString &udi) |
[read-only] energyRate : double
Access functions:
| double | energyRate() const |
Notifier signal:
| void | energyRateChanged(double energyRate, const QString &udi) |
[read-only] powerSupply : bool
Access functions:
| bool | isPowerSupply() const |
Notifier signal:
| void | powerSupplyStateChanged(bool newState, const QString &udi) |
[read-only] present : bool
Access functions:
| bool | isPresent() const |
Notifier signal:
| void | presentStateChanged(bool newState, const QString &udi) |
[read-only] rechargeable : const bool
Access functions:
| bool | isRechargeable() const |
[read-only] remainingTime : qlonglong
Access functions:
| qlonglong | remainingTime() const |
Notifier signal:
| void | remainingTimeChanged(qlonglong time, const QString &udi) |
[read-only] serial : const QString
Access functions:
| QString | serial() const |
[read-only] technology : const Technology
Access functions:
| Solid::Battery::Technology | technology() const |
[read-only] temperature : double
Access functions:
| double | temperature() const |
Notifier signal:
| void | temperatureChanged(double temperature, const QString &udi) |
[read-only] timeToEmpty : qlonglong
Access functions:
| qlonglong | timeToEmpty() const |
Notifier signal:
| void | timeToEmptyChanged(qlonglong time, const QString &udi) |
[read-only] timeToFull : qlonglong
Access functions:
| qlonglong | timeToFull() const |
Notifier signal:
| void | timeToFullChanged(qlonglong time, const QString &udi) |
[read-only] type : const BatteryType
Access functions:
| Solid::Battery::BatteryType | type() const |
[read-only] voltage : double
Access functions:
| double | voltage() const |
Notifier signal:
| void | voltageChanged(double voltage, const QString &udi) |
Member Function Documentation
int Battery::capacity() const
Returns the battery capacity normalised to percent, meaning how much energy can it hold compared to what it is designed to.
The capacity of the battery will reduce with age. A capacity value less than 75% is usually a sign that you should renew your battery.
Note: Getter function for property capacity.
[signal] void Battery::capacityChanged(int value, const QString &udi)
This signal is emitted when the capacity of this battery has changed.
Returns the new capacity value of the battery with the given udi.
Note: Notifier signal for property capacity.
int Battery::chargePercent() const
Returns the current charge level of the battery normalised to percent.
Note: Getter function for property chargePercent.
[signal] void Battery::chargePercentChanged(int value, const QString &udi)
This signal is emitted when the charge percent value of this battery has changed.
Returns the new charge percent value of the battery with the given udi.
Note: Notifier signal for property chargePercent.
Solid::Battery::ChargeState Battery::chargeState() const
Retrieves the current charge state of the battery.
It can be in a stable state (no charge), charging or discharging.
Note: Getter function for property chargeState.
See also Solid::Battery::ChargeState.
[signal] void Battery::chargeStateChanged(int newState, const QString &udi = QString())
This signal is emitted when the charge state of this battery has changed.
Returns the new charge state newState of the battery with the given udi.
Note: Notifier signal for property chargeState.
[since 6.9] int Battery::cycleCount() const
Returns the number of charge cycles this battery has experienced so far, or -1 if this information is unavailable.
Note: Getter function for property cycleCount.
This function was introduced in 6.9.
[signal, since 6.9] void Battery::cycleCountChanged(int value, const QString &udi)
This signal is emitted when the number of charge cycles of the battery has changed.
Returns the new value for the charge cycles of the battery with the given udi.
Note: Notifier signal for property cycleCount.
This function was introduced in 6.9.
[static] Solid::DeviceInterface::Type Battery::deviceInterfaceType()
Returns the Solid::DeviceInterface::Type of the Battery device interface.
See also Solid::DeviceInterface::Type.
double Battery::energy() const
Returns the amount of energy (measured in Wh) currently available in the power source.
Note: Getter function for property energy.
[signal] void Battery::energyChanged(double energy, const QString &udi)
This signal is emitted when the energy value of this battery has changed.
Returns the new energy value for the battery with the given udi.
Note: Notifier signal for property energy.
double Battery::energyFull() const
Returns the amount of energy (measured in Wh) the battery has when it is full.
Note: Getter function for property energyFull.
[signal] void Battery::energyFullChanged(double energy, const QString &udi)
This signal is emitted when the energy full value of this battery has changed.
Returns the new full energy value of the battery with the given udi.
Note: Notifier signal for property energyFull.
double Battery::energyFullDesign() const
Returns the amount of energy (measured in Wh) the battery should have by design when it is full.
Note: Getter function for property energyFullDesign.
[signal] void Battery::energyFullDesignChanged(double energy, const QString &udi)
This signal is emitted when the energy full design value of this battery has changed.
Returns the new energy full design value of the battery with the given udi.
Note: Notifier signal for property energyFullDesign.
double Battery::energyRate() const
Amount of energy being drained from the source, measured in W.
If positive, the source is being discharged, if negative it's being charged.
Note: Getter function for property energyRate.
[signal] void Battery::energyRateChanged(double energyRate, const QString &udi)
This signal is emitted when the energy rate value of this battery has changed.
If positive, the source is being discharged, if negative it's being charged.
Returns the new energy rate value of the battery with the given udi.
Note: Notifier signal for property energyRate.
bool Battery::isPowerSupply() const
Indicates if the battery is powering the machine.
Note: Getter function for property powerSupply.
bool Battery::isPresent() const
Returns whether this battery is currently present in its bay.
Note: Getter function for property present.
bool Battery::isRechargeable() const
Indicates if the battery is rechargeable.
Note: Getter function for property rechargeable.
[signal] void Battery::powerSupplyStateChanged(bool newState, const QString &udi)
This signal is emitted when the power supply state of the battery changes.
Returns the newState for the power supply of the battery with the given udi.
Note: Notifier signal for property powerSupply.
[signal] void Battery::presentStateChanged(bool newState, const QString &udi)
This signal is emitted if the battery gets plugged in/out of the battery bay.
Returns the newState of the battery with the given udi.
Note: Notifier signal for property present.
qlonglong Battery::remainingTime() const
Retrieves the current estimated remaining time (in seconds) of the system batteries
Note: Getter function for property remainingTime.
[signal] void Battery::remainingTimeChanged(qlonglong time, const QString &udi)
This signal is emitted when the estimated battery remaining time changes.
Returns the new battery remaining time for the battery with the given udi.
Note: Notifier signal for property remainingTime.
QString Battery::serial() const
The serial number of the battery
Note: Getter function for property serial.
Solid::Battery::Technology Battery::technology() const
Returns the technology used to manufacture the battery.
Note: Getter function for property technology.
See also Solid::Battery::Technology.
double Battery::temperature() const
The temperature of the battery in degrees Celsius.
Note: Getter function for property temperature.
[signal] void Battery::temperatureChanged(double temperature, const QString &udi)
This signal is emitted when the battery temperature has changed.
Returns the new temperature of the battery in degrees Celsius.
Note: Notifier signal for property temperature.
qlonglong Battery::timeToEmpty() const
Time (in seconds) until the battery is empty.
Note: Getter function for property timeToEmpty.
[signal] void Battery::timeToEmptyChanged(qlonglong time, const QString &udi)
This signal is emitted when the time until the battery is empty has changed.
Returns the new remaining time until empty of the battery with the given udi.
Note: Notifier signal for property timeToEmpty.
qlonglong Battery::timeToFull() const
Time (in seconds) until the battery is full.
Note: Getter function for property timeToFull.
[signal] void Battery::timeToFullChanged(qlonglong time, const QString &udi)
This signal is emitted when the time until the battery is full has changed.
Returns the new remaining time until full of the battery with the given udi.
Note: Notifier signal for property timeToFull.
Solid::Battery::BatteryType Battery::type() const
Returns the type of device holding this battery.
Note: Getter function for property type.
See also Solid::Battery::BatteryType.
double Battery::voltage() const
Voltage in the Cell or being recorded by the meter.
Note: Getter function for property voltage.
[signal] void Battery::voltageChanged(double voltage, const QString &udi)
This signal is emitted when the voltage in the cell has changed.
Returns the new voltage of the cell for the battery with the given udi.
Note: Notifier signal for property voltage.