Measure uasync CPU load and display it in desktop and Android GUIs
Sample thread CPU usage without waking idle loops, expose a one-second moving average, and refresh compact GUI indicators at 3 Hz while visible on Android. Add load and bridge regression coverage, streaming notes, and task list cleanup.
This commit is contained in:
1 parent
bcfe7ca4c1
commit
71d19013c0
25 files changed
+692
-587
No files matched your search
@@ -24,6 +24,38 @@ extern "C" {
|
||||
#include "dm/dm_core.h"
|
||||
}
|
||||
|
||||
/* Секундное среднее CPU: фиксированный градиент, заполнение по проценту. */
|
||||
class CpuLoadIndicator : public QWidget {
|
||||
public:
|
||||
explicit CpuLoadIndicator(QWidget* parent) : QWidget(parent) {
|
||||
setObjectName(QStringLiteral("cpuLoadIndicator"));
|
||||
setFixedSize(60, 24);
|
||||
setAccessibleName(QStringLiteral("CPU"));
|
||||
}
|
||||
void setValue(int percent) {
|
||||
percent = qBound(0, percent, 100);
|
||||
if (m_percent == percent) return;
|
||||
m_percent = percent; update();
|
||||
}
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*) override {
|
||||
QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing);
|
||||
QPainterPath path; path.addRoundedRect(QRectF(rect()), 5, 5);
|
||||
painter.setClipPath(path);
|
||||
painter.fillRect(rect(), QColor("#E4E9E6"));
|
||||
QLinearGradient gradient(0, 0, width(), 0);
|
||||
gradient.setColorAt(0, QColor("#66BB6A"));
|
||||
gradient.setColorAt(0.5, QColor("#FFCA28"));
|
||||
gradient.setColorAt(1, QColor("#EF5350"));
|
||||
painter.fillRect(QRectF(0, 0, width() * m_percent / 100.0, height()), gradient);
|
||||
painter.setPen(QColor("#172019"));
|
||||
QFont f = font(); f.setBold(true); painter.setFont(f);
|
||||
painter.drawText(rect(), Qt::AlignCenter, QString::number(m_percent) + '%');
|
||||
}
|
||||
private:
|
||||
int m_percent = 0;
|
||||
};
|
||||
|
||||
/* Пустое место и заголовки секций не сбрасывают выбор канала. */
|
||||
class ChannelListView : public QListView {
|
||||
public:
|
||||
@@ -106,7 +138,12 @@ ChannelList::ChannelList(DbManager* db, QWidget *parent)
|
||||
auto *header = new QLabel(QCoreApplication::translate("ChatGui", "Channels"), this);
|
||||
header->setAlignment(Qt::AlignCenter);
|
||||
header->setStyleSheet("font-weight: bold; padding: 8px; background: palette(window);");
|
||||
layout->addWidget(header);
|
||||
auto* headerRow = new QHBoxLayout;
|
||||
headerRow->setContentsMargins(0, 0, 8, 0);
|
||||
headerRow->addWidget(header, 1);
|
||||
m_cpuLoad = new CpuLoadIndicator(this);
|
||||
headerRow->addWidget(m_cpuLoad);
|
||||
layout->addLayout(headerRow);
|
||||
|
||||
m_listView->setModel(m_model);
|
||||
m_listView->setItemDelegate(new ChannelDelegate(this));
|
||||
@@ -266,6 +303,8 @@ void ChannelList::onDmCallRoute(const uint8_t* data, int len) {
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelList::setCpuLoad(int percent) { m_cpuLoad->setValue(percent); }
|
||||
|
||||
void ChannelList::loadChannels() {
|
||||
refreshDmPresence();
|
||||
QString selectedCid;
|
||||
|
||||
Reference in new issue
Block a user