54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <qobject.h>
|
|
#include <qqmlintegration.h>
|
|
|
|
namespace ZShell::services {
|
|
|
|
class DiskInfo : public QObject {
|
|
Q_OBJECT
|
|
QML_ELEMENT
|
|
QML_UNCREATABLE("DiskInfo is created by DiskUsage")
|
|
|
|
Q_PROPERTY(QString mount READ mount CONSTANT)
|
|
Q_PROPERTY(QString name READ name CONSTANT)
|
|
Q_PROPERTY(qreal used READ used NOTIFY usedChanged)
|
|
Q_PROPERTY(qreal total READ total NOTIFY totalChanged)
|
|
Q_PROPERTY(qreal free READ free NOTIFY freeChanged)
|
|
Q_PROPERTY(qreal perc READ perc NOTIFY percChanged)
|
|
Q_PROPERTY(bool hasRoot READ hasRoot NOTIFY hasRootChanged)
|
|
|
|
public:
|
|
DiskInfo(
|
|
QString mount,
|
|
quint64 usedBytes,
|
|
quint64 totalBytes,
|
|
bool hasRoot,
|
|
QObject* parent = nullptr);
|
|
|
|
[[nodiscard]] QString mount() const;
|
|
[[nodiscard]] QString name() const;
|
|
[[nodiscard]] qreal used() const;
|
|
[[nodiscard]] qreal total() const;
|
|
[[nodiscard]] qreal free() const;
|
|
[[nodiscard]] qreal perc() const;
|
|
[[nodiscard]] bool hasRoot() const;
|
|
|
|
void update(quint64 usedBytes, quint64 totalBytes, bool hasRoot);
|
|
|
|
signals:
|
|
void usedChanged();
|
|
void totalChanged();
|
|
void freeChanged();
|
|
void percChanged();
|
|
void hasRootChanged();
|
|
|
|
private:
|
|
QString m_mount;
|
|
quint64 m_usedBytes;
|
|
quint64 m_totalBytes;
|
|
bool m_hasRoot;
|
|
};
|
|
|
|
} // namespace ZShell::services
|