1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd and/or its subsidiary(-ies).
4** Copyright (C) 2014 BlackBerry Limited. All rights reserved.
5** Contact: http://www.qt-project.org/legal
6**
7** This file is part of the QtSystems module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL21$
10** Commercial License Usage
11** Licensees holding valid commercial Qt licenses may use this file in
12** accordance with the commercial license agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and The Qt Company. For licensing terms
15** and conditions see http://www.qt.io/terms-conditions. For further
16** information use the contact form at http://www.qt.io/contact-us.
17**
18** GNU Lesser General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU Lesser
20** General Public License version 2.1 or version 3 as published by the Free
21** Software Foundation and appearing in the file LICENSE.LGPLv21 and
22** LICENSE.LGPLv3 included in the packaging of this file. Please review the
23** following information to ensure the GNU Lesser General Public License
24** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
25** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
26**
27** As a special exception, The Qt Company gives you certain additional
28** rights. These rights are described in The Qt Company LGPL Exception
29** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
30**
31** $QT_END_LICENSE$
32**
33****************************************************************************/
34
35#ifndef QBATTERYINFO_H
36#define QBATTERYINFO_H
37
38#include <QtSystemInfo/qsysteminfoglobal.h>
39#include <QtCore/qobject.h>
40
41QT_BEGIN_NAMESPACE
42
43#if !defined(QT_SIMULATOR)
44class QBatteryInfoPrivate;
45#else
46class QBatteryInfoSimulator;
47#endif // QT_SIMULATOR
48
49class Q_SYSTEMINFO_EXPORT QBatteryInfo : public QObject
50{
51 Q_OBJECT
52
53 Q_ENUMS(ChargerType)
54 Q_ENUMS(ChargingState)
55 Q_ENUMS(LevelStatus)
56 Q_ENUMS(Health)
57
58 Q_PROPERTY(int batteryCount READ batteryCount NOTIFY batteryCountChanged)
59 Q_PROPERTY(int batteryIndex READ batteryIndex WRITE setBatteryIndex NOTIFY batteryIndexChanged)
60 Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
61 Q_PROPERTY(int level READ level NOTIFY levelChanged)
62 Q_PROPERTY(int currentFlow READ currentFlow NOTIFY currentFlowChanged)
63 Q_PROPERTY(int cycleCount READ cycleCount NOTIFY cycleCountChanged)
64 Q_PROPERTY(int maximumCapacity READ maximumCapacity)
65 Q_PROPERTY(int remainingCapacity READ remainingCapacity NOTIFY remainingCapacityChanged)
66 Q_PROPERTY(int remainingChargingTime READ remainingChargingTime NOTIFY remainingChargingTimeChanged)
67 Q_PROPERTY(int voltage READ voltage NOTIFY voltageChanged)
68 Q_PROPERTY(ChargingState chargingState READ chargingState NOTIFY chargingStateChanged)
69 Q_PROPERTY(ChargerType chargerType READ chargerType NOTIFY chargerTypeChanged)
70 Q_PROPERTY(LevelStatus levelStatus READ levelStatus NOTIFY levelStatusChanged)
71 Q_PROPERTY(Health health READ health NOTIFY healthChanged)
72 Q_PROPERTY(float temperature READ temperature NOTIFY temperatureChanged)
73
74public:
75 enum ChargerType {
76 UnknownCharger = 0,
77 WallCharger,
78 USBCharger,
79 VariableCurrentCharger
80 };
81
82 enum ChargingState {
83 UnknownChargingState = 0,
84 Charging,
85 IdleChargingState,
86 Discharging
87 };
88
89 enum LevelStatus {
90 LevelUnknown = 0,
91 LevelEmpty,
92 LevelLow,
93 LevelOk,
94 LevelFull
95 };
96
97 enum Health {
98 HealthUnknown = 0,
99 HealthOk,
100 HealthBad
101 };
102
103 explicit QBatteryInfo(QObject *parent = Q_NULLPTR);
104 explicit QBatteryInfo(int batteryIndex, QObject *parent = Q_NULLPTR);
105 virtual ~QBatteryInfo();
106
107 int batteryCount() const;
108 int batteryIndex() const;
109 bool isValid() const;
110 int level() const;
111 int currentFlow() const;
112 int cycleCount() const;
113 int maximumCapacity() const;
114 int remainingCapacity() const;
115 int remainingChargingTime() const;
116 int voltage() const;
117 QBatteryInfo::ChargingState chargingState() const;
118 QBatteryInfo::ChargerType chargerType() const;
119 QBatteryInfo::LevelStatus levelStatus() const;
120 QBatteryInfo::Health health() const;
121 float temperature() const;
122
123 void setBatteryIndex(int batteryIndex);
124
125Q_SIGNALS:
126 void batteryIndexChanged(int batteryIndex);
127 void validChanged(bool isValid);
128 void batteryCountChanged(int count);
129 void chargerTypeChanged(QBatteryInfo::ChargerType type);
130 void chargingStateChanged(QBatteryInfo::ChargingState state);
131 void levelChanged(int level);
132 void currentFlowChanged(int flow);
133 void cycleCountChanged(int cycleCount);
134 void remainingCapacityChanged(int capacity);
135 void remainingChargingTimeChanged(int seconds);
136 void voltageChanged(int voltage);
137 void levelStatusChanged(QBatteryInfo::LevelStatus levelStatus);
138 void healthChanged(QBatteryInfo::Health health);
139 void temperatureChanged(float temperature);
140
141protected:
142 void connectNotify(const QMetaMethod &signal);
143 void disconnectNotify(const QMetaMethod &signal);
144
145private:
146 Q_DISABLE_COPY(QBatteryInfo)
147#if !defined(QT_SIMULATOR)
148 QBatteryInfoPrivate * const d_ptr;
149 Q_DECLARE_PRIVATE(QBatteryInfo)
150#else
151 QBatteryInfoSimulator * const d_ptr;
152#endif // QT_SIMULATOR
153};
154
155QT_END_NAMESPACE
156
157#endif // QBATTERYINFO_H
158

source code of qtsystems/src/systeminfo/qbatteryinfo.h