fix: graph jitter on load + format

This commit is contained in:
2026-11-09 20:20:27 +01:00
parent d69a6bcafd
commit e49ecabf62
13 changed files with 181 additions and 320 deletions
+25 -3
View File
@@ -2,6 +2,8 @@
#include "sparklinecontent.hpp"
#include <qquickwindow.h>
namespace ZShell::components {
SparklineItem::SparklineItem(QQuickItem* parent) : QQuickItem(parent) {
@@ -18,6 +20,29 @@ void SparklineItem::geometryChange(
updateContentOffset();
}
void SparklineItem::itemChange(ItemChange change, const ItemChangeData& value) {
QQuickItem::itemChange(change, value);
if (change != ItemSceneChange) return;
if (m_syncConnection) QObject::disconnect(m_syncConnection);
if (value.window) {
m_syncConnection = connect(
value.window,
&QQuickWindow::beforeFrameBegin,
this,
&SparklineItem::syncSlidePhase);
}
}
void SparklineItem::syncSlidePhase() {
if (m_slideInterval <= 0.0) return;
updateContentOffset();
if (isVisible() && m_content->slideActive() && window()) window()->update();
}
void SparklineItem::updateContentOffset() {
m_content->setSlideProgress(m_slideProgress);
}
@@ -111,9 +136,6 @@ qreal SparklineItem::slideProgress() const {
}
void SparklineItem::setSlideProgress(qreal progress) {
// Always forwarded: with a slide interval set the phase comes from the sample
// clock, so the offset can move even when the animation value repeats. An
// unchanged position is a no-op in QQuickItem.
m_slideProgress = progress;
updateContentOffset();
emit slideProgressChanged();