1
/* This file is part of the KDE project
2
Copyright (C) 2006 Kevin Ottens <ervin@kde.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License version 2 as published by the Free Software Foundation.
8
This library is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
Library General Public License for more details.
13
You should have received a copy of the GNU Library General Public License
14
along with this library; see the file COPYING.LIB. If not, write to
15
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
Boston, MA 02110-1301, USA.
20
#ifndef SOLID_BATTERY_H
21
#define SOLID_BATTERY_H
23
#include <kdelibs_export.h>
25
#include <solid/capability.h>
30
* This capability is available on batteries.
32
class SOLID_EXPORT Battery : public Capability
35
Q_ENUMS( BatteryType LevelType ChargeState )
36
Q_PROPERTY( bool plugged READ isPlugged )
37
Q_PROPERTY( BatteryType type READ type )
38
Q_PROPERTY( QString chargeLevelUnit READ chargeLevelUnit )
39
Q_PROPERTY( int charge READ charge )
40
Q_PROPERTY( int chargePercent READ chargePercent )
41
Q_PROPERTY( QString voltageUnit READ voltageUnit )
42
Q_PROPERTY( int voltage READ voltage )
43
Q_PROPERTY( bool rechargeable READ isRechargeable )
44
Q_PROPERTY( ChargeState chargeState READ chargeState )
48
* This enum type defines the type of the device holding the battery
50
* - PdaBattery : A battery in a Personal Digital Assistant
51
* - UpsBattery : A battery in an Uninterruptible Power Supply
52
* - PrimaryBattery : A primary battery for the system (for example laptop battery)
53
* - MouseBattery : A battery in a mouse
54
* - KeyboardBattery : A battery in a keyboard
55
* - KeyboardMouseBattery : A battery in a combined keyboard and mouse
56
* - CameraBattery : A battery in a camera
57
* - UnknownBattery : A battery in an unknown device
59
enum BatteryType { UnknownBattery, PdaBattery, UpsBattery,
60
PrimaryBattery, MouseBattery, KeyboardBattery,
61
KeyboardMouseBattery, CameraBattery };
64
* This enum type defines the kind of charge level a battery can expose
66
* - MaxLevel : The maximum charge level the battery got designed for
67
* - LastFullLevel : The last charge level the battery got when full
68
* - CurrentLevel : The current charge level
69
* - WarningLevel : The battery is in 'warning' state below this level
70
* - LowLevel : The battery is in 'low' state below this level
72
enum LevelType { MaxLevel, LastFullLevel, CurrentLevel,
73
WarningLevel, LowLevel };
76
* This enum type defines charge state of a battery
78
* - NoCharge : Battery charge is stable, not charging or discharging
79
* - Charging : Battery is charging
80
* - Discharging : Battery is discharging
82
enum ChargeState { NoCharge, Charging, Discharging };
87
* Creates a new Battery object.
88
* You generally won't need this. It's created when necessary using
91
* @param backendObject the capability object provided by the backend
92
* @see Solid::Device::as()
94
explicit Battery( QObject *backendObject );
97
* Destroys a Battery object.
103
* Get the Solid::Capability::Type of the Battery capability.
105
* @return the Battery capability type
106
* @see Solid::Capability::Type
108
static Type capabilityType() { return Capability::Battery; }
111
* Indicates if this battery is plugged.
113
* @return true if the battery is plugged, false otherwise
115
bool isPlugged() const;
118
* Retrieves the type of device holding this battery.
120
* @return the type of device holding this battery
121
* @see Solid::Battery::BatteryType
123
BatteryType type() const;
128
* Retrieves the physical unit used by the charge level values
131
* @return the charge level unit as a string
134
QString chargeLevelUnit() const;
137
* Retrieves one of the charge level of the battery as requested.
138
* By default the current charge level is returned.
140
* The unit of the returned value is determined by chargeLevelUnit()
142
* @return the requested charge level
143
* @see Solid::Battery::LevelType
145
int charge( LevelType type = CurrentLevel ) const;
148
* Retrieves the current charge level of the battery normalised
151
* @return the current charge level normalised to percent
153
int chargePercent() const;
158
* Retrieves the physical unit used by the voltage values
161
* @return the voltage level unit as a string
164
QString voltageUnit() const;
167
* Retrieves the current voltage level of the battery.
169
* The unit of the returned value is determined by voltageUnit()
176
* Indicates if the battery is rechargeable.
178
* @return true if the battery is rechargeable, false otherwise (one time usage)
180
bool isRechargeable() const;
183
* Retrieves the current charge state of the battery. It can be in a stable
184
* state (no charge), charging or discharging.
186
* @return the current battery charge state
187
* @see Solid::Battery::ChargeState
189
ChargeState chargeState() const;
193
* This signal is emitted when the charge percent value of this
194
* battery has changed.
196
* @param value the new charge percent value of the battery
198
void chargePercentChanged( int value );
201
* This signal is emitted when the charge state of this battery
204
* @param newState the new charge state of the battery, it's one of
205
* the type Solid::Battery::ChargeState
206
* @see Solid::Battery::ChargeState
208
void chargeStateChanged( int newState );