Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorMotionAnimation.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
8#include <PhosphorAnimation/phosphoranimation_export.h>
10
11#include <QtCore/QMetaObject>
12#include <QtCore/QPointer>
13#include <QtCore/QVariant>
14#include <QtQml/qqmlregistration.h>
15// Private Qt header — DELIBERATE dependency, not incidental. The
16// `QQuickPropertyAnimation` base class lives under `QtQuick/private/*`
17// upstream; no public alias exists. This is the same header every
18// `Behavior`-wired property-animation subclass in Qt Quick uses
19// internally, so its shape is far more stable than a typical private
20// header — but Qt does not guarantee source-compat across MINOR Qt
21// versions.
22//
23// Supported Qt range for this library:
24// - Minimum: Qt 6.10, matching the `find_package(Qt6 6.10 REQUIRED)`
25// in libs/phosphor-animation/CMakeLists.txt. (The
26// `QQuickPropertyAnimation` shape we rely on has been
27// stable since 6.5, but the build does not configure
28// below 6.10.)
29// - Tested: Qt 6.10, 6.11 (the segment cap at
30// `kBezierSplineSegments` specifically guards 6.11;
31// older versions don't heap-corrupt on the 11+
32// segment boundary, but the cap is harmless there).
33// - Known-bad: Qt 6.11.0-6.11.x pre-patch — `QQuickPropertyAnimation::
34// setEasing` heap-corrupts on `QEasingCurve::BezierSpline`
35// curves with >=11 segments. Workaround in-library; no
36// fix required at the consumer site.
37//
38// Packaging notes: on Fedora, `qt6-qtdeclarative-devel` pulls the
39// private headers via `-devel`. On Debian/Ubuntu the headers live
40// under `qt6-declarative-private-dev`. Arch ships them in
41// `qt6-declarative`. Distributions that split out private headers
42// into a separate package (some openSUSE layouts) need the explicit
43// `-private-devel` install.
44//
45// When bumping the Qt minimum: re-verify the `setEasing` boundary
46// and update both `kBezierSplineSegments` and this comment if Qt's
47// behaviour changes.
48#include <QtQuick/private/qquickanimation_p.h>
49
50namespace PhosphorAnimation {
51
116class PHOSPHORANIMATION_EXPORT PhosphorMotionAnimation : public QQuickPropertyAnimation
117{
118 Q_OBJECT
119 QML_NAMED_ELEMENT(PhosphorMotionAnimation)
120
121
124 Q_PROPERTY(QVariant profile READ profile WRITE setProfile NOTIFY profileChanged)
125
126
146 Q_PROPERTY(int durationOverride READ durationOverride WRITE setDurationOverride NOTIFY durationOverrideChanged)
147
148public:
163 static constexpr int kBezierSplineSegments = 8;
164
165 explicit PhosphorMotionAnimation(QObject* parent = nullptr);
167
168 QVariant profile() const;
169 void setProfile(const QVariant& p);
170
171 int durationOverride() const;
173
179 const Profile& resolvedProfile() const;
180
181Q_SIGNALS:
184
185private:
201 int effectiveDurationMs() const;
202
203 void resolveFromVariant(const QVariant& p);
204 void rebindToRegistryPath(const QString& path);
205 void disconnectRegistrySignal();
206 void applyResolvedProfile(const Profile& p);
207
214 static bool isAncestorOrSelf(const QString& candidate, const QString& descendant);
215
222 void applyResolvedEasing();
223
224 QVariant m_profile;
225 Profile m_resolvedProfile;
226 QString m_boundPath;
227 int m_durationOverride = -1;
228 QMetaObject::Connection m_registryChangedConnection;
229 QMetaObject::Connection m_registryReloadedConnection;
230};
231
232} // namespace PhosphorAnimation
QQuickPropertyAnimation subclass driving property animation with a phosphor-animation Profile.
Definition PhosphorMotionAnimation.h:117
const Profile & resolvedProfile() const
Current effective profile (with library defaults filled in for unset fields).
PhosphorMotionAnimation(QObject *parent=nullptr)
Configuration for a single animation event.
Definition Profile.h:33
Definition AnimatedValue.h:32