32 lines
559 B
C++
32 lines
559 B
C++
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QTimer>
|
|
#include <QString>
|
|
|
|
class SystemInfo : public QObject
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(int batteryPercent
|
|
READ batteryPercent
|
|
NOTIFY batteryPercentChanged)
|
|
|
|
public:
|
|
explicit SystemInfo(QObject *parent = nullptr);
|
|
|
|
int batteryPercent() const;
|
|
|
|
signals:
|
|
void batteryPercentChanged();
|
|
|
|
private slots:
|
|
void updateBattery();
|
|
|
|
private:
|
|
QString findBatteryCapacityPath() const;
|
|
|
|
int m_batteryPercent = -1;
|
|
QString m_capacityPath;
|
|
QTimer m_batteryTimer;
|
|
};
|