more unfinished changes, process tab for dashboard
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

This commit is contained in:
2026-09-25 16:51:28 +02:00
parent a1d96b60f6
commit 9ea1f846ae
103 changed files with 8677 additions and 3131 deletions
+53 -1
View File
@@ -3,6 +3,8 @@
#include <qfile.h>
#include <qregularexpression.h>
#include <unistd.h>
namespace ZShell::services {
Memory::Memory(QObject* parent) : TickingService(parent) {}
@@ -15,6 +17,18 @@ qreal Memory::total() const {
return m_total;
}
qreal Memory::cached() const {
return m_cached;
}
qreal Memory::readTotal() const {
return m_readTotal;
}
qreal Memory::writeTotal() const {
return m_writeTotal;
}
qreal Memory::percentage() const {
return m_total > 0.0 ? m_used / m_total : 0.0;
}
@@ -31,6 +45,8 @@ void Memory::tick() {
QStringLiteral("MemTotal: *(\\d+)"));
static const QRegularExpression reAvail(
QStringLiteral("MemAvailable: *(\\d+)"));
static const QRegularExpression reCached(QStringLiteral(
"Cached: *(\\d+)"));
const QString text = QString::fromLatin1(data);
const auto totalMatch = reTotal.match(text);
@@ -45,14 +61,50 @@ void Memory::tick() {
return;
}
const quint64 usedKib = totalKib > availKib ? totalKib - availKib : 0;
const auto cachedMatch = reCached.match(text);
const quint64 cachedKib =
cachedMatch.hasMatch() ? cachedMatch.captured(1).toULongLong() : 0;
if (totalKib == m_lastTotal && usedKib == m_lastUsed) {
static const QRegularExpression rePgin(QStringLiteral("pgpgin (\\d+)"));
static const QRegularExpression rePgout(QStringLiteral("pgpgout (\\d+)"));
quint64 readKib = 0;
quint64 writeKib = 0;
{
QFile vf(QStringLiteral("/proc/vmstat"));
if (vf.open(QIODevice::ReadOnly | QIODevice::Text)) {
const QString vtext = QString::fromLatin1(vf.readAll());
vf.close();
const double pageKib = getpagesize() / 1024.0;
const auto pgin = rePgin.match(vtext);
const auto pgout = rePgout.match(vtext);
if (pgin.hasMatch()) {
readKib = static_cast<quint64>(static_cast<double>(
pgin.captured(1).toULongLong()) *
pageKib);
}
if (pgout.hasMatch()) {
writeKib = static_cast<quint64>(static_cast<double>(
pgout.captured(1).toULongLong()) *
pageKib);
}
}
}
if (totalKib == m_lastTotal && usedKib == m_lastUsed &&
cachedKib == m_lastCached && readKib == m_lastReadKib &&
writeKib == m_lastWriteKib) {
return;
}
m_lastTotal = totalKib;
m_lastUsed = usedKib;
m_lastCached = cachedKib;
m_lastReadKib = readKib;
m_lastWriteKib = writeKib;
m_total = static_cast<qreal>(totalKib);
m_used = static_cast<qreal>(usedKib);
m_cached = static_cast<qreal>(cachedKib);
m_readTotal = static_cast<qreal>(readKib);
m_writeTotal = static_cast<qreal>(writeKib);
Q_EMIT changed();
}