# class Battery

###

Module | solid
Namespace | Solid
Class | Battery
Inherits | Solid::DeviceInterface

This device interface is available on batteries.

### enums

- BatteryType { UnknownBattery, PdaBattery, UpsBattery, PrimaryBattery, MouseBattery, KeyboardBattery, KeyboardMouseBattery, CameraBattery }
- ChargeState { NoCharge, Charging, Discharging }

enum details

### methods

- Battery (backendObject)

  returns ctor
  Not implemented
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  backendObject | QObject |

  Creates a new Battery object. You generally won't need this. It's created when necessary using Device.as().

  backendObject - the device interface object provided by the backend

  See also Solid.Device.as()

- Battery (a0)

  returns ctor
  Not implemented
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QObject |

- chargePercent ( )

  returns int

  Retrieves the current charge level of the battery normalised to percent.

  Returns the current charge level normalised to percent

- chargePercentChanged (value, udi)

  returns Nothing
  SIGNAL ("chargePercentChanged (int, const QString&)")

  Argument | Type | Default
  --- | --- | ---
  value | int |
  udi | QString |

  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

- chargeState ( )

  returns Solid::Battery.ChargeState

  Retrieves the current charge state of the battery. It can be in a stable state (no charge), charging or discharging.

  Returns the current battery charge state

  See also Solid.Battery.ChargeState

- chargeStateChanged (newState, udi)

  returns Nothing
  SIGNAL ("chargeStateChanged (int, const QString&)")

  Argument | Type | Default
  --- | --- | ---
  newState | int |
  udi | QString |

  This signal is emitted when the charge state of this battery has changed.

  newState - the new charge state of the battery, it's one of the type Solid.Battery.ChargeState

  See also Solid.Battery.ChargeState

  udi - the UDI of the battery with the new charge state

- deviceInterfaceType ( )

  returns Solid::DeviceInterface.Type
  static

  Get the Solid.DeviceInterface.Type of the Battery device interface.

  Returns the Battery device interface type

  See also Solid.DeviceInterface.Type

- isPlugged ( )

  returns bool

  Indicates if this battery is plugged.

  Returns true if the battery is plugged, false otherwise

- isRechargeable ( )

  returns bool

  Indicates if the battery is rechargeable.

  Returns true if the battery is rechargeable, false otherwise (one time usage)

- plugStateChanged (newState, udi)

  returns Nothing
  SIGNAL ("plugStateChanged (bool, const QString&)")

  Argument | Type | Default
  --- | --- | ---
  newState | bool |
  udi | QString |

  This signal is emitted if the battery get plugged in/out of the battery bay.

  newState - the new plugging state of the battery, type is boolean

  udi - the UDI of the battery with the new plugging state

- type ( )

  returns Solid::Battery.BatteryType

  Retrieves the type of device holding this battery.

  Returns the type of device holding this battery

  See also Solid.Battery.BatteryType

### enums - detail

- BatteryType { UnknownBattery, PdaBattery, UpsBattery, PrimaryBattery, MouseBattery, KeyboardBattery, KeyboardMouseBattery, CameraBattery }

  This enum type defines the type of the device holding the battery

  - PdaBattery : A battery in a Personal Digital Assistant - UpsBattery : A battery in an Uninterruptible Power Supply - PrimaryBattery : A primary battery for the system (for example laptop battery) - MouseBattery : A battery in a mouse - KeyboardBattery : A battery in a keyboard - KeyboardMouseBattery : A battery in a combined keyboard and mouse - CameraBattery : A battery in a camera - UnknownBattery : A battery in an unknown device

  | UnknownBattery | - | - |
  | PdaBattery | - | - |
  | UpsBattery | - | - |
  | PrimaryBattery | - | - |
  | MouseBattery | - | - |
  | KeyboardBattery | - | - |
  | KeyboardMouseBattery | - | - |
  | CameraBattery | - | - |

- ChargeState { NoCharge, Charging, Discharging }

  This enum type defines charge state of a battery

  - NoCharge : Battery charge is stable, not charging or discharging or the state is Unknown - Charging : Battery is charging - Discharging : Battery is discharging

  | NoCharge | - | - |
  | Charging | - | - |
  | Discharging | - | - |