summaryrefslogtreecommitdiff
path: root/plugin/src/Caelestia/Managers/circularindicatormanager.hpp
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-13 15:50:04 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-13 15:50:04 +1000
commit98a709af78b4d3e7a41f40526d9ac0f99608e36f (patch)
treebb2a2b29784fd104e9ff731467b9ea33a834166a /plugin/src/Caelestia/Managers/circularindicatormanager.hpp
parentplugin: refactor into modules (diff)
downloadcaelestia-shell-98a709af78b4d3e7a41f40526d9ac0f99608e36f.tar.gz
caelestia-shell-98a709af78b4d3e7a41f40526d9ac0f99608e36f.tar.bz2
caelestia-shell-98a709af78b4d3e7a41f40526d9ac0f99608e36f.zip
plugin/managers: add CircularIndicatorManager
Basically move StyledBusyIndicator -> CircularIndicator + logic for it from js -> c++
Diffstat (limited to 'plugin/src/Caelestia/Managers/circularindicatormanager.hpp')
-rw-r--r--plugin/src/Caelestia/Managers/circularindicatormanager.hpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/plugin/src/Caelestia/Managers/circularindicatormanager.hpp b/plugin/src/Caelestia/Managers/circularindicatormanager.hpp
new file mode 100644
index 0000000..71da93d
--- /dev/null
+++ b/plugin/src/Caelestia/Managers/circularindicatormanager.hpp
@@ -0,0 +1,72 @@
+#pragma once
+
+#include <qeasingcurve.h>
+#include <qobject.h>
+#include <qqmlintegration.h>
+
+namespace caelestia {
+
+class CircularIndicatorManager : public QObject {
+ Q_OBJECT
+ QML_ELEMENT
+
+ Q_PROPERTY(qreal startFraction READ startFraction NOTIFY startFractionChanged)
+ Q_PROPERTY(qreal endFraction READ endFraction NOTIFY endFractionChanged)
+ Q_PROPERTY(qreal rotation READ rotation NOTIFY rotationChanged)
+ Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged)
+ Q_PROPERTY(qreal completeEndProgress READ completeEndProgress WRITE setCompleteEndProgress NOTIFY
+ completeEndProgressChanged)
+ Q_PROPERTY(qreal duration READ duration NOTIFY indeterminateAnimationTypeChanged)
+ Q_PROPERTY(qreal completeEndDuration READ completeEndDuration NOTIFY indeterminateAnimationTypeChanged)
+ Q_PROPERTY(IndeterminateAnimationType indeterminateAnimationType READ indeterminateAnimationType WRITE
+ setIndeterminateAnimationType NOTIFY indeterminateAnimationTypeChanged)
+
+public:
+ explicit CircularIndicatorManager(QObject* parent = nullptr);
+
+ enum IndeterminateAnimationType {
+ Advance = 0,
+ Retreat
+ };
+ Q_ENUM(IndeterminateAnimationType)
+
+ [[nodiscard]] qreal startFraction() const;
+ [[nodiscard]] qreal endFraction() const;
+ [[nodiscard]] qreal rotation() const;
+
+ [[nodiscard]] qreal progress() const;
+ void setProgress(qreal progress);
+
+ [[nodiscard]] qreal completeEndProgress() const;
+ void setCompleteEndProgress(qreal progress);
+
+ [[nodiscard]] qreal duration() const;
+ [[nodiscard]] qreal completeEndDuration() const;
+
+ [[nodiscard]] IndeterminateAnimationType indeterminateAnimationType() const;
+ void setIndeterminateAnimationType(IndeterminateAnimationType t);
+
+signals:
+ void startFractionChanged();
+ void endFractionChanged();
+ void rotationChanged();
+ void progressChanged();
+ void completeEndProgressChanged();
+ void indeterminateAnimationTypeChanged();
+
+private:
+ IndeterminateAnimationType m_type;
+ QEasingCurve m_curve;
+
+ qreal m_progress;
+ qreal m_startFraction;
+ qreal m_endFraction;
+ qreal m_rotation;
+ qreal m_completeEndProgress;
+
+ void update(qreal progress);
+ void updateAdvance(qreal progress);
+ void updateRetreat(qreal progress);
+};
+
+} // namespace caelestia