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
(since 4.11) int | capacity() const |
int | chargePercent() const |
Solid::Battery::ChargeState | chargeState() const |
double | energy() const |
(since 5.7) double | energyFull() const |
(since 5.7) double | energyFullDesign() const |
double | energyRate() const |
bool | isPowerSupply() const |
bool | isPresent() const |
bool | isRechargeable() const |
(since 5.8) qlonglong | remainingTime() const |
(since 5.0) QString | serial() const |
Solid::Battery::Technology | technology() const |
(since 5.0) double | temperature() const |
(since 5.0) qlonglong | timeToEmpty() const |
(since 5.0) qlonglong | timeToFull() const |
Solid::Battery::BatteryType | type() const |
double | voltage() const |
Signals
(since 4.11) void | capacityChanged(int value, const QString &udi) |
void | chargePercentChanged(int value, const QString &udi) |
void | chargeStateChanged(int newState, const QString &udi = QString()) |
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) |
(since 4.11) void | powerSupplyStateChanged(bool newState, const QString &udi) |
void | presentStateChanged(bool newState, const QString &udi) |
(since 5.8) void | remainingTimeChanged(qlonglong time, const QString &udi) |
(since 5.0) void | temperatureChanged(double temperature, const QString &udi) |
(since 5.0) void | timeToEmptyChanged(qlonglong time, const QString &udi) |
(since 5.0) void | timeToFullChanged(qlonglong time, const QString &udi) |
(since 5.0) 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 Qt 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 Qt 5.88) | 12 | A battery in a graphics tablet or pen |
Solid::Battery::HeadphoneBattery (since Qt 6.0) | 13 | A battery in a headphone |
Solid::Battery::HeadsetBattery (since Qt 6.0) | 14 | A battery in a headset |
Solid::Battery::TouchpadBattery (since Qt 6.0) | 15 | A battery in a touchpad. This is how the Dualsense Wireless Controller is categorized |
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 : const int
Access functions:
int | capacity() const |
Notifier signal:
void | capacityChanged(int value, const QString &udi) |
[read-only]
chargePercent : const int
Access functions:
int | chargePercent() const |
Notifier signal:
void | chargePercentChanged(int value, const QString &udi) |
[read-only]
chargeState : const ChargeState
Access functions:
Solid::Battery::ChargeState | chargeState() const |
Notifier signal:
void | chargeStateChanged(int newState, const QString &udi = QString()) |
[read-only]
energy : const double
Access functions:
double | energy() const |
Notifier signal:
void | energyChanged(double energy, const QString &udi) |
[read-only]
energyFull : const double
Access functions:
double | energyFull() const |
Notifier signal:
void | energyFullChanged(double energy, const QString &udi) |
[read-only]
energyFullDesign : const double
Access functions:
double | energyFullDesign() const |
Notifier signal:
void | energyFullDesignChanged(double energy, const QString &udi) |
[read-only]
energyRate : const double
Access functions:
double | energyRate() const |
Notifier signal:
void | energyRateChanged(double energyRate, const QString &udi) |
[read-only]
powerSupply : const bool
Access functions:
bool | isPowerSupply() const |
Notifier signal:
void | powerSupplyStateChanged(bool newState, const QString &udi) |
[read-only]
present : const 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 : const 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 : const double
Access functions:
double | temperature() const |
Notifier signal:
void | temperatureChanged(double temperature, const QString &udi) |
[read-only]
timeToEmpty : const qlonglong
Access functions:
qlonglong | timeToEmpty() const |
Notifier signal:
void | timeToEmptyChanged(qlonglong time, const QString &udi) |
[read-only]
timeToFull : const 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 : const double
Access functions:
double | voltage() const |
Notifier signal:
void | voltageChanged(double voltage, const QString &udi) |
Member Function Documentation
[since 4.11]
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.
This function was introduced in 4.11.
[signal, since 4.11]
void Battery::capacityChanged(int value, const QString &udi)
This signal is emitted when the capacity of this battery has changed.
value the new capacity of the battery
udi the UDI of the battery with the new capacity
Note: Notifier signal for property capacity.
This function was introduced in 4.11.
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.
value the new charge percent value of the battery
udi the UDI of the battery with the new charge percent
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.
newState the new charge state of the battery
udi the UDI of the battery with the new charge state
Note: Notifier signal for property chargeState.
[static]
Solid::DeviceInterface::Type Battery::deviceInterfaceType()
Get the Solid::DeviceInterface::Type of the Battery device interface.
See also Solid::DeviceInterface::Type.
double Battery::energy() const
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.
energy the new energy value of the battery
udi the UDI of the battery with the new energy value
Note: Notifier signal for property energy.
[since 5.7]
double Battery::energyFull() const
Amount of energy (measured in Wh) the battery has when it is full.
Note: Getter function for property energyFull.
This function was introduced in 5.7.
[signal]
void Battery::energyFullChanged(double energy, const QString &udi)
This signal is emitted when the energy full value of this battery has changed.
energy the new energy full value of the battery
udi the UDI of the battery with the new energy full value
Note: Notifier signal for property energyFull.
[since 5.7]
double Battery::energyFullDesign() const
Amount of energy (measured in Wh) the battery should have by design hen it is full.
Returns amount of battery energy when full by design in Wh
Note: Getter function for property energyFullDesign.
This function was introduced in 5.7.
[signal]
void Battery::energyFullDesignChanged(double energy, const QString &udi)
This signal is emitted when the energy full design value of this battery has changed.
energy the new energy full design value of the battery
udi the UDI of the battery with the new energy full design value
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.
energyRate the new energy rate value of the battery
udi the UDI of the battery with the new charge percent
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
Indicates if this battery is currently present in its bay.
Returns true
if the battery is present, false
otherwise
Note: Getter function for property present.
bool Battery::isRechargeable() const
Indicates if the battery is rechargeable.
Note: Getter function for property rechargeable.
[signal, since 4.11]
void Battery::powerSupplyStateChanged(bool newState, const QString &udi)
This signal is emitted when the power supply state of the battery changes.
newState the new power supply state
udi the UDI of the battery with the new power supply state
Note: Notifier signal for property powerSupply.
This function was introduced in 4.11.
[signal]
void Battery::presentStateChanged(bool newState, const QString &udi)
This signal is emitted if the battery gets plugged in/out of the battery bay.
newState the new plugging state of the battery
udi the UDI of the battery with thew new plugging state
Note: Notifier signal for property present.
[since 5.8]
qlonglong Battery::remainingTime() const
Retrieves the current estimated remaining time (in seconds) of the system batteries
Note: Getter function for property remainingTime.
This function was introduced in 5.8.
[signal, since 5.8]
void Battery::remainingTimeChanged(qlonglong time, const QString &udi)
This signal is emitted when the estimated battery remaining time changes.
time the new remaining time
udi the UDI of the battery with the new remaining time
Note: Notifier signal for property remainingTime.
This function was introduced in 5.8.
[since 5.0]
QString Battery::serial() const
The serial number of the battery
Note: Getter function for property serial.
This function was introduced in 5.0.
Solid::Battery::Technology Battery::technology() const
Retrieves the technology used to manufacture the battery.
Note: Getter function for property technology.
See also Solid::Battery::Technology.
[since 5.0]
double Battery::temperature() const
The temperature of the battery in degrees Celsius.
Note: Getter function for property temperature.
This function was introduced in 5.0.
[signal, since 5.0]
void Battery::temperatureChanged(double temperature, const QString &udi)
This signal is emitted when the battery temperature has changed.
temperature the new temperature of the battery in degrees Celsius
udi the UDI of the battery with the new temperature
Note: Notifier signal for property temperature.
This function was introduced in 5.0.
[since 5.0]
qlonglong Battery::timeToEmpty() const
Time (in seconds) until the battery is empty.
Note: Getter function for property timeToEmpty.
This function was introduced in 5.0.
[signal, since 5.0]
void Battery::timeToEmptyChanged(qlonglong time, const QString &udi)
This signal is emitted when the time until the battery is empty has changed.
time the new remaining time
udi the UDI of the battery with the new remaining time
Note: Notifier signal for property timeToEmpty.
This function was introduced in 5.0.
[since 5.0]
qlonglong Battery::timeToFull() const
Time (in seconds) until the battery is full.
Note: Getter function for property timeToFull.
This function was introduced in 5.0.
[signal, since 5.0]
void Battery::timeToFullChanged(qlonglong time, const QString &udi)
This signal is emitted when the time until the battery is full has changed.
time the new remaining time
udi the UDI of the battery with the new remaining time
Note: Notifier signal for property timeToFull.
This function was introduced in 5.0.
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, since 5.0]
void Battery::voltageChanged(double voltage, const QString &udi)
This signal is emitted when the voltage in the cell has changed.
voltage the new voltage of the cell
udi the UDI of the battery with the new voltage
Note: Notifier signal for property voltage.
This function was introduced in 5.0.