Solid

frontend/battery.h
1 /*
2  SPDX-FileCopyrightText: 2006-2007 Kevin Ottens <[email protected]>
3  SPDX-FileCopyrightText: 2012 Lukas Tinkl <[email protected]>
4  SPDX-FileCopyrightText: 2014 Kai Uwe Broulik <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8 
9 #ifndef SOLID_BATTERY_H
10 #define SOLID_BATTERY_H
11 
12 #include <solid/solid_export.h>
13 
14 #include <solid/deviceinterface.h>
15 
16 namespace Solid
17 {
18 class BatteryPrivate;
19 class Device;
20 
24 class SOLID_EXPORT Battery : public DeviceInterface
25 {
26  Q_OBJECT
27  Q_PROPERTY(bool present READ isPresent NOTIFY presentStateChanged)
28  Q_PROPERTY(BatteryType type READ type CONSTANT)
29  Q_PROPERTY(int chargePercent READ chargePercent NOTIFY chargePercentChanged)
30  Q_PROPERTY(int capacity READ capacity NOTIFY capacityChanged)
31  Q_PROPERTY(bool rechargeable READ isRechargeable CONSTANT)
32  Q_PROPERTY(bool powerSupply READ isPowerSupply NOTIFY powerSupplyStateChanged)
33  Q_PROPERTY(ChargeState chargeState READ chargeState NOTIFY chargeStateChanged)
34  Q_PROPERTY(qlonglong timeToEmpty READ timeToEmpty NOTIFY timeToEmptyChanged)
35  Q_PROPERTY(qlonglong timeToFull READ timeToFull NOTIFY timeToFullChanged)
36  Q_PROPERTY(double energy READ energy NOTIFY energyChanged)
37  Q_PROPERTY(double energyFull READ energyFull NOTIFY energyFullChanged)
38  Q_PROPERTY(double energyFullDesign READ energyFullDesign NOTIFY energyFullDesignChanged)
39  Q_PROPERTY(double energyRate READ energyRate NOTIFY energyRateChanged)
40  Q_PROPERTY(double voltage READ voltage NOTIFY voltageChanged)
41  Q_PROPERTY(double temperature READ temperature NOTIFY temperatureChanged)
42  Q_PROPERTY(Technology technology READ technology CONSTANT)
43  Q_PROPERTY(bool recalled READ isRecalled)
44  Q_PROPERTY(QString recallVendor READ recallVendor)
45  Q_PROPERTY(QString recallUrl READ recallUrl)
46  Q_PROPERTY(QString serial READ serial CONSTANT)
47  Q_PROPERTY(qlonglong remainingTime READ remainingTime NOTIFY remainingTimeChanged)
48  Q_DECLARE_PRIVATE(Battery)
49  friend class Device;
50 
51 public:
69  enum BatteryType { UnknownBattery, PdaBattery, UpsBattery,
70  PrimaryBattery, MouseBattery, KeyboardBattery,
71  KeyboardMouseBattery, CameraBattery,
72  PhoneBattery, MonitorBattery, GamingInputBattery,
73  BluetoothBattery
74  };
75  Q_ENUM(BatteryType)
76 
77 
87  enum ChargeState { NoCharge, Charging, Discharging, FullyCharged };
88  Q_ENUM(ChargeState)
89 
90 
101  enum Technology { UnknownTechnology = 0, LithiumIon, LithiumPolymer, LithiumIronPhosphate,
102  LeadAcid, NickelCadmium, NickelMetalHydride
103  };
104  Q_ENUM(Technology)
105 
106 private:
115  explicit Battery(QObject *backendObject);
116 
117 public:
121  virtual ~Battery();
122 
130  {
131  return DeviceInterface::Battery;
132  }
133 
139  bool isPresent() const;
140 
141 #if SOLID_ENABLE_DEPRECATED_SINCE(5, 0)
142 
147  SOLID_DEPRECATED_VERSION(5, 0, "Use Battery::isPresent()")
148  bool isPlugged() const { return isPresent(); }
149 #endif
150 
157  Solid::Battery::BatteryType type() const;
158 
165  int chargePercent() const;
166 
176  int capacity() const;
177 
183  bool isRechargeable() const;
184 
190  bool isPowerSupply() const;
191 
199  Solid::Battery::ChargeState chargeState() const;
200 
207  qlonglong timeToEmpty() const;
208 
215  qlonglong timeToFull() const;
216 
223  Solid::Battery::Technology technology() const;
224 
230  double energy() const;
231 
238  double energyFull() const;
239 
246  double energyFullDesign() const;
247 
255  double energyRate() const;
256 
262  double voltage() const;
263 
270  double temperature() const;
271 
278  bool isRecalled() const;
279 
286  QString recallVendor() const;
287 
294  QString recallUrl() const;
295 
302  QString serial() const;
303 
310  qlonglong remainingTime() const;
311 
312 Q_SIGNALS:
320  void presentStateChanged(bool newState, const QString &udi);
321 
329  void chargePercentChanged(int value, const QString &udi);
330 
338  void capacityChanged(int value, const QString &udi);
339 
348  void powerSupplyStateChanged(bool newState, const QString &udi);
349 
359  void chargeStateChanged(int newState, const QString &udi = QString());
360 
369  void timeToEmptyChanged(qlonglong time, const QString &udi);
370 
379  void timeToFullChanged(qlonglong time, const QString &udi);
380 
388  void energyChanged(double energy, const QString &udi);
389 
397  void energyFullChanged(double energy, const QString &udi);
398 
406  void energyFullDesignChanged(double energy, const QString &udi);
407 
417  void energyRateChanged(double energyRate, const QString &udi);
418 
426  void voltageChanged(double voltage, const QString &udi);
427 
435  void temperatureChanged(double temperature, const QString &udi);
436 
444  void remainingTimeChanged(qlonglong time, const QString &udi);
445 };
446 }
447 
448 #endif
This class allows applications to deal with devices available in the underlying system.
Base class of all the device interfaces.
Type
This enum type defines the type of device interface that a Device can have.
static Type deviceInterfaceType()
Get the Solid::DeviceInterface::Type of the Battery device interface.
This device interface is available on batteries.
Technology
Technology used in the battery.
ChargeState
This enum type defines charge state of a battery.
The single responsibility of this class is to create arguments valid for logind Inhibit call...
BatteryType
This enum type defines the type of the device holding the battery.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Jan 14 2021 22:51:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.