perf: smooth UI animations and reduce repaint overhead

Batch of performance and animation work: shared FadeHelper/MotionPrefs
primitives, hover animators, shadow pixmap caching, smooth scrolling,
seek time bubble, and widespread component repaint reductions.
This commit is contained in:
dela
2026-07-08 11:29:38 +08:00
parent 03bc33518c
commit ab1accc821
85 changed files with 2308 additions and 661 deletions
+17 -8
View File
@@ -1,4 +1,6 @@
#include "settingsview.h"
#include "../../tokens/AnimationTokens.h"
#include "../../utils/motionprefs.h"
#include "../../components/slidingstackedwidget.h"
#include "../../managers/thememanager.h"
#include "pageabout.h"
@@ -148,8 +150,8 @@ QScrollArea *SettingsView::wrapInScrollArea(QWidget *page, int row) {
auto *anim =
new QPropertyAnimation(scroll->verticalScrollBar(), "value", this);
anim->setEasingCurve(QEasingCurve::OutCubic);
anim->setDuration(450);
anim->setEasingCurve(AnimationTokens::Curve::enter());
anim->setDuration(AnimationTokens::DurationMs::kSlow);
m_scrollAnims[row] = anim;
m_scrollTargets[row] = 0;
}
@@ -195,10 +197,10 @@ void SettingsView::ensurePageAt(int row) {
QWidget *placeholder = m_stack->widget(row);
const bool wasBlocked = m_stack->blockSignals(true);
m_stack->insertWidget(row, scroll);
m_stack->insertWidget(row, scroll);
m_stack->removeWidget(placeholder);
m_stack->blockSignals(wasBlocked);
placeholder->deleteLater();
m_stack->disposeWidgetWhenSafe(placeholder);
m_pages[row] = scroll;
}
@@ -208,7 +210,10 @@ void SettingsView::setupConnections() {
connect(m_navMenu, &QListWidget::currentRowChanged, this, [this](int row) {
if (row >= 0) {
ensurePageAt(row);
m_stack->setCurrentIndex(row);
// Vertical slide following the nav list's direction of travel.
m_stack->slideInIdx(row, row > m_stack->currentIndex()
? SlidingStackedWidget::BottomToTop
: SlidingStackedWidget::TopToBottom);
}
});
@@ -261,9 +266,13 @@ bool SettingsView::eventFilter(QObject *obj, QEvent *event) {
if (newTarget != vBar->value()) {
m_scrollTargets[i] = newTarget;
anim->stop();
anim->setStartValue(vBar->value());
anim->setEndValue(newTarget);
anim->start();
if (MotionPrefs::reduceMotion()) {
vBar->setValue(newTarget);
} else {
anim->setStartValue(vBar->value());
anim->setEndValue(newTarget);
anim->start();
}
}
}
return true;