Files
z-bar-qt/Plugins/ZShell/Services/memory.hpp
T
zach 9ea1f846ae
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 11s
JS/TS / fmt (pull_request) Successful in 9s
JS/TS / lint (pull_request) Successful in 10s
Python / static (pull_request) Successful in 34s
Rust / build (pull_request) Successful in 59s
Python / verify (pull_request) Successful in 1m48s
Rust / fmt (pull_request) Successful in 47s
Rust / clippy (pull_request) Successful in 1m6s
more unfinished changes, process tab for dashboard
2026-09-25 16:51:28 +02:00

52 lines
1.2 KiB
C++

#pragma once
#include "tickingservice.hpp"
#include <qqmlintegration.h>
#include <qvariant.h>
namespace ZShell::services {
class Memory : public TickingService {
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
Q_PROPERTY(qreal used READ used NOTIFY changed)
Q_PROPERTY(qreal total READ total NOTIFY changed)
Q_PROPERTY(qreal cached READ cached NOTIFY changed)
Q_PROPERTY(qreal percentage READ percentage NOTIFY changed)
Q_PROPERTY(qreal readTotal READ readTotal NOTIFY changed)
Q_PROPERTY(qreal writeTotal READ writeTotal NOTIFY changed)
public:
explicit Memory(QObject* parent = nullptr);
[[nodiscard]] qreal used() const;
[[nodiscard]] qreal total() const;
[[nodiscard]] qreal cached() const;
[[nodiscard]] qreal percentage() const;
[[nodiscard]] qreal readTotal() const;
[[nodiscard]] qreal writeTotal() const;
signals:
void changed();
protected:
void tick() override;
private:
qreal m_used = 0.0;
qreal m_total = 1.0;
qreal m_cached = 0.0;
qreal m_readTotal = 0.0;
qreal m_writeTotal = 0.0;
quint64 m_lastUsed = 0;
quint64 m_lastTotal = 0;
quint64 m_lastCached = 0;
quint64 m_lastReadKib = 0;
quint64 m_lastWriteKib = 0;
};
} // namespace ZShell::services