From 851e0d1d24132a8d8ef48198f6e2688dcaaabd00 Mon Sep 17 00:00:00 2001 From: ajp_anton Date: Wed, 21 Oct 2026 01:11:05 +0000 Subject: [PATCH] Refine Framework graph legends and history keyboard controls --- .../framework-laptop-tools.spec | 8 +++++- framework-laptop-tools/src/legend.cpp | 2 +- framework-laptop-tools/src/window.cpp | 21 +++++++++++---- framework-laptop-tools/tests/test-window.cpp | 27 ++++++++++++++++--- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/framework-laptop-tools/framework-laptop-tools.spec b/framework-laptop-tools/framework-laptop-tools.spec index 19da9b3..3733d81 100644 --- a/framework-laptop-tools/framework-laptop-tools.spec +++ b/framework-laptop-tools/framework-laptop-tools.spec @@ -1,6 +1,6 @@ Name: framework-laptop-tools Version: 0.1.0 -Release: 29%{?dist} +Release: 31%{?dist} Summary: Hardware controls and monitoring for Framework Laptop 13 Pro License: MIT URL: https://git.ajpanton.se/ajp_anton/fedora-tools @@ -58,6 +58,12 @@ install -Dpm 0644 %{SOURCE1} %{buildroot}%{_licensedir}/%{name}/LICENSE %{_unitdir}/framework-laptop-tools-cpu.service %{_unitdir}/framework-laptop-tools-lighting.service %changelog +* Wed Oct 21 2026 fedora-tools contributors - 0.1.0-31 +- Adjust Monitor history by one minute per arrow-key press + +* Wed Oct 21 2026 fedora-tools contributors - 0.1.0-30 +- Keep graph legend labels together when wrapping to a new row + * Wed Sep 23 2026 fedora-tools contributors - 0.1.0-29 - Save power-button brightness or Auto mode and restore it at boot diff --git a/framework-laptop-tools/src/legend.cpp b/framework-laptop-tools/src/legend.cpp index 617c860..5dc38fb 100644 --- a/framework-laptop-tools/src/legend.cpp +++ b/framework-laptop-tools/src/legend.cpp @@ -39,7 +39,7 @@ void Legend::refresh() const auto text = enabled ? palette().color(QPalette::WindowText) : gray; const auto dot = enabled ? m_chart->color(sensor.id) : gray; links.append(QString("● %5") - .arg(i).arg(text.name(), enabled ? "none" : "line-through", dot.name(), sensor.name.toHtmlEscaped().replace(' ', " "))); + .arg(i).arg(text.name(), enabled ? "none" : "line-through", dot.name(), sensor.name.toHtmlEscaped().replace(' ', " ").replace('-', "‑"))); } if (!m_extraLink.isEmpty()) links.append(QString("%2") .arg(palette().color(QPalette::WindowText).name(), m_extraLink.toHtmlEscaped().replace(' ', " "))); diff --git a/framework-laptop-tools/src/window.cpp b/framework-laptop-tools/src/window.cpp index dcd5281..10f951d 100644 --- a/framework-laptop-tools/src/window.cpp +++ b/framework-laptop-tools/src/window.cpp @@ -151,10 +151,21 @@ QWidget *Window::monitorPage() auto *page = new QWidget; auto *layout = new QVBoxLayout(page); auto *historyRow = new QHBoxLayout; auto *history = new JumpSlider(Qt::Horizontal); history->setObjectName("monitorHistory"); - // Logarithmic spacing, rounded to whole minutes for a readable selection. - history->setRange(0, 1000); + // Enough logarithmic positions to represent every whole minute up to 24 hours. + history->setRange(0, 10000); history->setSingleStep(10); history->setPageStep(100); + const auto historyMinutes = [history] { + return qRound(5 * std::pow(288., double(history->value()) / history->maximum())); + }; + const auto historyPosition = [history](int minutes) { + return qRound(history->maximum() * std::log(minutes / 5.) / std::log(288.)); + }; const auto savedMinutes = std::clamp(m_settings.value("monitor/historyMinutes", 1440).toInt(), 5, 1440); - history->setValue(qRound(1000 * std::log(savedMinutes / 5.) / std::log(288.))); + history->setValue(historyPosition(savedMinutes)); + connect(history, &QSlider::actionTriggered, this, [history, historyMinutes, historyPosition](int action) { + if (action != QSlider::SliderSingleStepAdd && action != QSlider::SliderSingleStepSub) return; + const int step = action == QSlider::SliderSingleStepAdd ? 1 : -1; + history->setSliderPosition(historyPosition(std::clamp(historyMinutes() + step, 5, 1440))); + }); auto *span = new QLabel; span->setMinimumWidth(fontMetrics().horizontalAdvance("24 h 59 min")); auto *stretch = new QCheckBox("Stretch available data"); stretch->setObjectName("monitorStretch"); stretch->setChecked(m_settings.value("monitor/stretch", true).toBool()); @@ -173,8 +184,8 @@ QWidget *Window::monitorPage() {{"battery", "Charge level", {}, "%"}, {"battery-rate", "Charge / discharge rate", {}, "W"}}, false); layout->addWidget(batteryGroup); const QList charts{m_frequencyChart, m_powerChart, m_fanChart, m_temperatureChart, m_batteryChart}; - auto updateHistory = [this, charts, history, stretch, span] { - const int minutes = qRound(5 * std::pow(288., history->value() / 1000.)); + auto updateHistory = [this, charts, historyMinutes, stretch, span] { + const int minutes = historyMinutes(); span->setText(minutes < 60 ? QString("%1 min").arg(minutes) : minutes % 60 ? QString("%1 h %2 min").arg(minutes / 60).arg(minutes % 60) : QString("%1 h").arg(minutes / 60)); diff --git a/framework-laptop-tools/tests/test-window.cpp b/framework-laptop-tools/tests/test-window.cpp index fe3cbf7..8574079 100644 --- a/framework-laptop-tools/tests/test-window.cpp +++ b/framework-laptop-tools/tests/test-window.cpp @@ -544,19 +544,38 @@ private Q_SLOTS: Window window; auto *slider = window.findChild("monitorHistory"); QVERIFY(slider); auto *stretch = window.findChild("monitorStretch"); QVERIFY(stretch); - QCOMPARE(slider->value(), 1000); QVERIFY(stretch->isChecked()); + QCOMPARE(slider->value(), slider->maximum()); QVERIFY(stretch->isChecked()); + QSettings settings("fedora-tools", "framework-laptop-tools"); + QTest::keyClick(slider, Qt::Key_Left); + QCOMPARE(settings.value("monitor/historyMinutes").toInt(), 1439); + QTest::keyClick(slider, Qt::Key_Left); + QCOMPARE(settings.value("monitor/historyMinutes").toInt(), 1438); + QTest::keyClick(slider, Qt::Key_Right); + QCOMPARE(settings.value("monitor/historyMinutes").toInt(), 1439); + QTest::keyClick(slider, Qt::Key_End); + QTest::keyClick(slider, Qt::Key_Right); + QCOMPARE(settings.value("monitor/historyMinutes").toInt(), 1440); slider->setValue(0); stretch->setChecked(false); for (auto *chart : window.findChildren()) QCOMPARE(chart->timeRange().second - chart->timeRange().first, 300000.); - slider->setValue(500); - QSettings settings("fedora-tools", "framework-laptop-tools"); + QTest::keyClick(slider, Qt::Key_Left); + QCOMPARE(settings.value("monitor/historyMinutes").toInt(), 5); + QTest::keyClick(slider, Qt::Key_Right); + QCOMPARE(settings.value("monitor/historyMinutes").toInt(), 6); + slider->setValue(slider->maximum() / 2); const int minutes = settings.value("monitor/historyMinutes").toInt(); QVERIFY(minutes >= 84 && minutes <= 86); // Geometric, not arithmetic, midpoint. + QTest::keyClick(slider, Qt::Key_Right); + QCOMPARE(settings.value("monitor/historyMinutes").toInt(), minutes + 1); + QTest::keyClick(slider, Qt::Key_Left); + QCOMPARE(settings.value("monitor/historyMinutes").toInt(), minutes); } Window restored; - QCOMPARE(restored.findChild("monitorHistory")->value(), 500); QVERIFY(!restored.findChild("monitorStretch")->isChecked()); QSettings settings("fedora-tools", "framework-laptop-tools"); + for (auto *chart : restored.findChildren()) + QCOMPARE(chart->timeRange().second - chart->timeRange().first, + settings.value("monitor/historyMinutes").toInt() * 60000.); settings.setValue("tray/historyMs", 86400000); TrayPage tray(settings, {{"cpu-usage", "CPU usage", {}, "%"}}); QCOMPARE(tray.iconStyle().historyMs, qint64(60000)); // Retired choices use the new default.