Refine Framework graph legends and history keyboard controls
This commit is contained in:
1 parent
535ac5b480
commit
851e0d1d24
4 files changed
+47
-11
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
Name: framework-laptop-tools
|
Name: framework-laptop-tools
|
||||||
Version: 0.1.0
|
Version: 0.1.0
|
||||||
Release: 29%{?dist}
|
Release: 31%{?dist}
|
||||||
Summary: Hardware controls and monitoring for Framework Laptop 13 Pro
|
Summary: Hardware controls and monitoring for Framework Laptop 13 Pro
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: https://git.ajpanton.se/ajp_anton/fedora-tools
|
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-cpu.service
|
||||||
%{_unitdir}/framework-laptop-tools-lighting.service
|
%{_unitdir}/framework-laptop-tools-lighting.service
|
||||||
%changelog
|
%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
|
* Wed Sep 23 2026 fedora-tools contributors - 0.1.0-29
|
||||||
- Save power-button brightness or Auto mode and restore it at boot
|
- Save power-button brightness or Auto mode and restore it at boot
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ void Legend::refresh()
|
|||||||
const auto text = enabled ? palette().color(QPalette::WindowText) : gray;
|
const auto text = enabled ? palette().color(QPalette::WindowText) : gray;
|
||||||
const auto dot = enabled ? m_chart->color(sensor.id) : gray;
|
const auto dot = enabled ? m_chart->color(sensor.id) : gray;
|
||||||
links.append(QString("<a href=\"%1\" style=\"color:%2;text-decoration:none\"><span style=\"color:%4\">●</span> <span style=\"text-decoration:%3\">%5</span></a>")
|
links.append(QString("<a href=\"%1\" style=\"color:%2;text-decoration:none\"><span style=\"color:%4\">●</span> <span style=\"text-decoration:%3\">%5</span></a>")
|
||||||
.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("<a href=\"extra\" style=\"color:%1;text-decoration:none\">%2</a>")
|
if (!m_extraLink.isEmpty()) links.append(QString("<a href=\"extra\" style=\"color:%1;text-decoration:none\">%2</a>")
|
||||||
.arg(palette().color(QPalette::WindowText).name(), m_extraLink.toHtmlEscaped().replace(' ', " ")));
|
.arg(palette().color(QPalette::WindowText).name(), m_extraLink.toHtmlEscaped().replace(' ', " ")));
|
||||||
|
|||||||
@@ -151,10 +151,21 @@ QWidget *Window::monitorPage()
|
|||||||
auto *page = new QWidget; auto *layout = new QVBoxLayout(page);
|
auto *page = new QWidget; auto *layout = new QVBoxLayout(page);
|
||||||
auto *historyRow = new QHBoxLayout;
|
auto *historyRow = new QHBoxLayout;
|
||||||
auto *history = new JumpSlider(Qt::Horizontal); history->setObjectName("monitorHistory");
|
auto *history = new JumpSlider(Qt::Horizontal); history->setObjectName("monitorHistory");
|
||||||
// Logarithmic spacing, rounded to whole minutes for a readable selection.
|
// Enough logarithmic positions to represent every whole minute up to 24 hours.
|
||||||
history->setRange(0, 1000);
|
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);
|
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 *span = new QLabel; span->setMinimumWidth(fontMetrics().horizontalAdvance("24 h 59 min"));
|
||||||
auto *stretch = new QCheckBox("Stretch available data"); stretch->setObjectName("monitorStretch");
|
auto *stretch = new QCheckBox("Stretch available data"); stretch->setObjectName("monitorStretch");
|
||||||
stretch->setChecked(m_settings.value("monitor/stretch", true).toBool());
|
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);
|
{{"battery", "Charge level", {}, "%"}, {"battery-rate", "Charge / discharge rate", {}, "W"}}, false);
|
||||||
layout->addWidget(batteryGroup);
|
layout->addWidget(batteryGroup);
|
||||||
const QList<Chart *> charts{m_frequencyChart, m_powerChart, m_fanChart, m_temperatureChart, m_batteryChart};
|
const QList<Chart *> charts{m_frequencyChart, m_powerChart, m_fanChart, m_temperatureChart, m_batteryChart};
|
||||||
auto updateHistory = [this, charts, history, stretch, span] {
|
auto updateHistory = [this, charts, historyMinutes, stretch, span] {
|
||||||
const int minutes = qRound(5 * std::pow(288., history->value() / 1000.));
|
const int minutes = historyMinutes();
|
||||||
span->setText(minutes < 60 ? QString("%1 min").arg(minutes)
|
span->setText(minutes < 60 ? QString("%1 min").arg(minutes)
|
||||||
: minutes % 60 ? QString("%1 h %2 min").arg(minutes / 60).arg(minutes % 60)
|
: minutes % 60 ? QString("%1 h %2 min").arg(minutes / 60).arg(minutes % 60)
|
||||||
: QString("%1 h").arg(minutes / 60));
|
: QString("%1 h").arg(minutes / 60));
|
||||||
|
|||||||
@@ -544,19 +544,38 @@ private Q_SLOTS:
|
|||||||
Window window;
|
Window window;
|
||||||
auto *slider = window.findChild<QSlider *>("monitorHistory"); QVERIFY(slider);
|
auto *slider = window.findChild<QSlider *>("monitorHistory"); QVERIFY(slider);
|
||||||
auto *stretch = window.findChild<QCheckBox *>("monitorStretch"); QVERIFY(stretch);
|
auto *stretch = window.findChild<QCheckBox *>("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);
|
slider->setValue(0); stretch->setChecked(false);
|
||||||
for (auto *chart : window.findChildren<Chart *>())
|
for (auto *chart : window.findChildren<Chart *>())
|
||||||
QCOMPARE(chart->timeRange().second - chart->timeRange().first, 300000.);
|
QCOMPARE(chart->timeRange().second - chart->timeRange().first, 300000.);
|
||||||
slider->setValue(500);
|
QTest::keyClick(slider, Qt::Key_Left);
|
||||||
QSettings settings("fedora-tools", "framework-laptop-tools");
|
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();
|
const int minutes = settings.value("monitor/historyMinutes").toInt();
|
||||||
QVERIFY(minutes >= 84 && minutes <= 86); // Geometric, not arithmetic, midpoint.
|
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;
|
Window restored;
|
||||||
QCOMPARE(restored.findChild<QSlider *>("monitorHistory")->value(), 500);
|
|
||||||
QVERIFY(!restored.findChild<QCheckBox *>("monitorStretch")->isChecked());
|
QVERIFY(!restored.findChild<QCheckBox *>("monitorStretch")->isChecked());
|
||||||
QSettings settings("fedora-tools", "framework-laptop-tools");
|
QSettings settings("fedora-tools", "framework-laptop-tools");
|
||||||
|
for (auto *chart : restored.findChildren<Chart *>())
|
||||||
|
QCOMPARE(chart->timeRange().second - chart->timeRange().first,
|
||||||
|
settings.value("monitor/historyMinutes").toInt() * 60000.);
|
||||||
settings.setValue("tray/historyMs", 86400000);
|
settings.setValue("tray/historyMs", 86400000);
|
||||||
TrayPage tray(settings, {{"cpu-usage", "CPU usage", {}, "%"}});
|
TrayPage tray(settings, {{"cpu-usage", "CPU usage", {}, "%"}});
|
||||||
QCOMPARE(tray.iconStyle().historyMs, qint64(60000)); // Retired choices use the new default.
|
QCOMPARE(tray.iconStyle().historyMs, qint64(60000)); // Retired choices use the new default.
|
||||||
|
|||||||
Reference in new issue
Block a user