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.5 (`QQuickPropertyAnimation` shape we rely on
25// has been stable since 6.5).
26// - Tested: Qt 6.9, 6.10, 6.11 (the segment cap at
27// `kBezierSplineSegments` specifically guards 6.11;
28// older versions don't heap-corrupt on the 11+
29// segment boundary, but the cap is harmless there).
30// - Known-bad: Qt 6.11.0-6.11.x pre-patch — `QQuickPropertyAnimation::
31// setEasing` heap-corrupts on `QEasingCurve::BezierSpline`
32// curves with >=11 segments. Workaround in-library; no
33// fix required at the consumer site.
34//
35// Packaging notes: on Fedora, `qt6-qtdeclarative-devel` pulls the
36// private headers via `-devel`. On Debian/Ubuntu the headers live
37// under `qt6-declarative-private-dev`. Arch ships them in
38// `qt6-declarative`. Distributions that split out private headers
39// into a separate package (some openSUSE layouts) need the explicit
40// `-private-devel` install.
41//
42// When bumping the Qt minimum: re-verify the `setEasing` boundary
43// and update both `kBezierSplineSegments` and this comment if Qt's
44// behaviour changes.
45#include <QtQuick/private/qquickanimation_p.h>
46
47namespace PhosphorAnimation {
48
113class PHOSPHORANIMATION_EXPORT PhosphorMotionAnimation : public QQuickPropertyAnimation
114{
115 Q_OBJECT
116 QML_NAMED_ELEMENT(PhosphorMotionAnimation)
117
118
121 Q_PROPERTY(QVariant profile READ profile WRITE setProfile NOTIFY profileChanged)
122
123
136 Q_PROPERTY(int durationOverride READ durationOverride WRITE setDurationOverride NOTIFY durationOverrideChanged)
137
138public:
153 static constexpr int kBezierSplineSegments = 8;
154
155 explicit PhosphorMotionAnimation(QObject* parent = nullptr);
157
158 QVariant profile() const;
159 void setProfile(const QVariant& p);
160
161 int durationOverride() const;
163
169 const Profile& resolvedProfile() const;
170
171Q_SIGNALS:
174
175private:
176 void resolveFromVariant(const QVariant& p);
177 void rebindToRegistryPath(const QString& path);
178 void disconnectRegistrySignal();
179 void applyResolvedProfile(const Profile& p);
180
187 static bool isAncestorOrSelf(const QString& candidate, const QString& descendant);
188
195 void applyResolvedEasing();
196
197 QVariant m_profile;
198 Profile m_resolvedProfile;
199 QString m_boundPath;
200 int m_durationOverride = 0;
201 QMetaObject::Connection m_registryChangedConnection;
202 QMetaObject::Connection m_registryReloadedConnection;
203};
204
205} // namespace PhosphorAnimation
QQuickPropertyAnimation subclass driving property animation with a phosphor-animation Profile.
Definition PhosphorMotionAnimation.h:114
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:31