| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
#ifndef QBATTERYINFO_H |
| 42 |
#define QBATTERYINFO_H |
| 43 |
|
| 44 |
#include "qsysteminfoglobal.h" |
| 45 |
#include <QtCore/qobject.h> |
| 46 |
|
| 47 |
QT_BEGIN_NAMESPACE |
| 48 |
|
| 49 |
#if !defined(QT_SIMULATOR) |
| 50 |
class QBatteryInfoPrivate; |
| 51 |
#else |
| 52 |
class QBatteryInfoSimulator; |
| 53 |
#endif |
| 54 |
|
| 55 |
class Q_SYSTEMINFO_EXPORT QBatteryInfo : public QObject |
| 56 |
{ |
| 57 |
Q_OBJECT |
| 58 |
|
| 59 |
Q_ENUMS(ChargerType) |
| 60 |
Q_ENUMS(ChargingState) |
| 61 |
Q_ENUMS(LevelStatus) |
| 62 |
Q_ENUMS(Health) |
| 63 |
|
| 64 |
Q_PROPERTY(int batteryCount READ batteryCount NOTIFY batteryCountChanged) |
| 65 |
Q_PROPERTY(int batteryIndex READ batteryIndex WRITE setBatteryIndex NOTIFY batteryIndexChanged) |
| 66 |
Q_PROPERTY(bool valid READ isValid NOTIFY validChanged) |
| 67 |
Q_PROPERTY(int level READ level NOTIFY levelChanged) |
| 68 |
Q_PROPERTY(int currentFlow READ currentFlow NOTIFY currentFlowChanged) |
| 69 |
Q_PROPERTY(int cycleCount READ cycleCount NOTIFY cycleCountChanged) |
| 70 |
Q_PROPERTY(int maximumCapacity READ maximumCapacity) |
| 71 |
Q_PROPERTY(int remainingCapacity READ remainingCapacity NOTIFY remainingCapacityChanged) |
| 72 |
Q_PROPERTY(int remainingChargingTime READ remainingChargingTime NOTIFY remainingChargingTimeChanged) |
| 73 |
Q_PROPERTY(int voltage READ voltage NOTIFY voltageChanged) |
| 74 |
Q_PROPERTY(ChargingState chargingState READ chargingState NOTIFY chargingStateChanged) |
| 75 |
Q_PROPERTY(ChargerType chargerType READ chargerType NOTIFY chargerTypeChanged) |
| 76 |
Q_PROPERTY(LevelStatus levelStatus READ levelStatus NOTIFY levelStatusChanged) |
| 77 |
Q_PROPERTY(Health health READ health NOTIFY healthChanged) |
| 78 |
Q_PROPERTY(float temperature READ temperature NOTIFY temperatureChanged) |
| 79 |
|
| 80 |
public: |
| 81 |
enum ChargerType { |
| 82 |
UnknownCharger = 0, |
| 83 |
WallCharger, |
| 84 |
USBCharger, |
| 85 |
VariableCurrentCharger |
| 86 |
}; |
| 87 |
|
| 88 |
enum ChargingState { |
| 89 |
UnknownChargingState = 0, |
| 90 |
Charging, |
| 91 |
IdleChargingState, |
| 92 |
Discharging |
| 93 |
}; |
| 94 |
|
| 95 |
enum LevelStatus { |
| 96 |
LevelUnknown = 0, |
| 97 |
LevelEmpty, |
| 98 |
LevelLow, |
| 99 |
LevelOk, |
| 100 |
LevelFull |
| 101 |
}; |
| 102 |
|
| 103 |
enum Health { |
| 104 |
HealthUnknown = 0, |
| 105 |
HealthOk, |
| 106 |
HealthBad |
| 107 |
}; |
| 108 |
|
| 109 |
explicit QBatteryInfo(QObject *parent = Q_NULLPTR); |
| 110 |
explicit QBatteryInfo(int batteryIndex, QObject *parent = Q_NULLPTR); |
| 111 |
virtual ~QBatteryInfo(); |
| 112 |
|
| 113 |
int batteryCount() const; |
| 114 |
int batteryIndex() const; |
| 115 |
bool isValid() const; |
| 116 |
int level() const; |
| 117 |
int currentFlow() const; |
| 118 |
int cycleCount() const; |
| 119 |
int maximumCapacity() const; |
| 120 |
int remainingCapacity() const; |
| 121 |
int remainingChargingTime() const; |
| 122 |
int voltage() const; |
| 123 |
QBatteryInfo::ChargingState chargingState() const; |
| 124 |
QBatteryInfo::ChargerType chargerType() const; |
| 125 |
QBatteryInfo::LevelStatus levelStatus() const; |
| 126 |
QBatteryInfo::Health health() const; |
| 127 |
float temperature() const; |
| 128 |
|
| 129 |
void setBatteryIndex(int batteryIndex); |
| 130 |
|
| 131 |
Q_SIGNALS: |
| 132 |
void batteryIndexChanged(int batteryIndex); |
| 133 |
void validChanged(bool isValid); |
| 134 |
void batteryCountChanged(int count); |
| 135 |
void chargerTypeChanged(QBatteryInfo::ChargerType type); |
| 136 |
void chargingStateChanged(QBatteryInfo::ChargingState state); |
| 137 |
void levelChanged(int level); |
| 138 |
void currentFlowChanged(int flow); |
| 139 |
void cycleCountChanged(int cycleCount); |
| 140 |
void remainingCapacityChanged(int capacity); |
| 141 |
void remainingChargingTimeChanged(int seconds); |
| 142 |
void voltageChanged(int voltage); |
| 143 |
void levelStatusChanged(QBatteryInfo::LevelStatus levelStatus); |
| 144 |
void healthChanged(QBatteryInfo::Health health); |
| 145 |
void temperatureChanged(float temperature); |
| 146 |
|
| 147 |
protected: |
| •148 |
void connectNotify(const QMetaMethod &signal) override; |
| 149 |
void disconnectNotify(const QMetaMethod &signal) override; |
| 150 |
|
| 151 |
private: |
| 152 |
Q_DISABLE_COPY(QBatteryInfo) |
| 153 |
#if !defined(QT_SIMULATOR) |
| 154 |
QBatteryInfoPrivate * const d_ptr; |
| 155 |
Q_DECLARE_PRIVATE(QBatteryInfo) |
| 156 |
#else |
| 157 |
QBatteryInfoSimulator * const d_ptr; |
| 158 |
#endif |
| 159 |
}; |
| 160 |
|
| 161 |
QT_END_NAMESPACE |
| 162 |
|
| 163 |
#endif |