perf: improve animation smoothness on Wayland

This commit is contained in:
dela
2026-06-10 16:12:29 +08:00
parent d56e09914f
commit 012d165b81
8 changed files with 338 additions and 102 deletions
+22 -4
View File
@@ -2,11 +2,13 @@
#define SLIDINGSTACKEDWIDGET_H
#include <QStackedWidget>
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include <QEasingCurve>
#include <QElapsedTimer>
#include <QList>
#include <QPoint>
#include <QPointer>
#include <QRect>
#include <QTimer>
class QLabel;
@@ -42,15 +44,31 @@ private Q_SLOTS:
void animationDoneSlot();
private:
QLabel *createSnapshotLabel(QWidget *source, const QRect &geometry);
void clearSnapshotLabels();
void startSlideAnimation(QWidget *widgetNow, const QPoint &nowStart,
const QPoint &nowEnd, QWidget *widgetNext,
const QPoint &nextStart,
const QPoint &nextEnd);
void updateSlideAnimation();
int animationFrameIntervalMs() const;
void flushPendingWidgetDisposals();
int m_speed;
QEasingCurve::Type m_animationType;
QParallelAnimationGroup *m_animGroup;
QTimer m_slideTimer;
QElapsedTimer m_slideClock;
QPointer<QWidget> m_animWidgetNow;
QPointer<QWidget> m_animWidgetNext;
QPoint m_animNowStart;
QPoint m_animNowEnd;
QPoint m_animNextStart;
QPoint m_animNextEnd;
bool m_isAnimating;
int m_nextIndex;
QList<QPointer<QWidget>> m_pendingWidgetDisposals;
QLabel* m_snapshotLabel = nullptr;
QLabel* m_currentSnapshotLabel = nullptr;
QLabel* m_nextSnapshotLabel = nullptr;
};
#endif