Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
animated_stacked_widget.h
Go to the documentation of this file.
1#ifndef ANIMATED_STACKED_WIDGET_H
2#define ANIMATED_STACKED_WIDGET_H
3
4#include <QStackedWidget>
5
7class QSoundEffect;
8class QParallelAnimationGroup;
9
19class AnimatedStackedWidget final : public QStackedWidget {
20 Q_OBJECT
22 Q_PROPERTY(int duration READ GetDuration WRITE SetDuration)
23
24public:
34
41 explicit AnimatedStackedWidget(QWidget *parent = nullptr);
42
47 ~AnimatedStackedWidget() override;
48
53 void SetDuration(const int duration) { duration_ = duration; }
54
59 int GetDuration() const { return duration_; }
60
65 void SetAnimationType(const AnimationType type) { animation_type_ = type; }
66
72
77 bool IsAnimating() const { return animation_running_; }
78
79public slots:
86 void SlideToIndex(int index);
87
93 void SlideToWidget(QWidget *widget);
94
99 void SlideToNextIndex();
100
101protected:
106 void AnimateFade(int next_index) const;
107
112 void AnimateSlide(int next_index) const;
113
118 void AnimateSlideAndFade(int next_index) const;
119
124 void AnimatePush(int next_index) const;
125
126private slots:
133
134private:
141 void PrepareAnimation(int next_index) const;
142
147 void CleanupAfterAnimation() const;
148
154 QParallelAnimationGroup *animation_group_;
162 QSoundEffect *swoosh_sound_;
163};
164
165#endif // ANIMATED_STACKED_WIDGET_H
~AnimatedStackedWidget() override
Destructor. Cleans up the animation group and the OpenGL transition widget.
Definition animated_stacked_widget.cpp:38
int target_index_
Stores the index of the target widget during an animation.
Definition animated_stacked_widget.h:158
void SlideToIndex(int index)
Initiates an animated transition to the widget at the specified index. Plays a sound effect and start...
Definition animated_stacked_widget.cpp:43
void AnimateSlideAndFade(int next_index) const
Configures and adds animations to the animation_group_ for a combined slide and fade transition.
Definition animated_stacked_widget.cpp:190
QSoundEffect * swoosh_sound_
Sound effect played during transitions.
Definition animated_stacked_widget.h:162
AnimationType animation_type_
The type of animation currently configured.
Definition animated_stacked_widget.h:152
int duration
Property controlling the duration of the transition animation in milliseconds.
Definition animated_stacked_widget.h:22
void SlideToWidget(QWidget *widget)
Initiates an animated transition to the specified widget. Convenience slot that finds the index of th...
Definition animated_stacked_widget.cpp:65
void AnimateSlide(int next_index) const
Configures and adds animations to the animation_group_ for a slide transition (CPU fallback).
Definition animated_stacked_widget.cpp:163
void SlideToNextIndex()
Initiates an animated transition to the next widget in the stack (wraps around). Useful for creating ...
Definition animated_stacked_widget.cpp:72
AnimationType GetAnimationType() const
Gets the currently configured animation type.
Definition animated_stacked_widget.h:71
bool IsAnimating() const
Checks if a transition animation is currently running.
Definition animated_stacked_widget.h:77
void CleanupAfterAnimation() const
Cleans up graphics effects and resets widget geometries after an animation finishes....
Definition animated_stacked_widget.cpp:119
QParallelAnimationGroup * animation_group_
Parallel animation group managing the individual property animations.
Definition animated_stacked_widget.h:154
void SetDuration(const int duration)
Sets the duration of the transition animation.
Definition animated_stacked_widget.h:53
AnimatedStackedWidget(QWidget *parent=nullptr)
Constructs an AnimatedStackedWidget. Initializes the animation group, sound effect,...
Definition animated_stacked_widget.cpp:10
AnimationType
Enum defining the available types of transition animations.
Definition animated_stacked_widget.h:28
@ Push
Push the current widget partially out while the next slides in.
Definition animated_stacked_widget.h:32
@ Slide
Slide the current widget out and the next widget in (can use OpenGL).
Definition animated_stacked_widget.h:30
@ Fade
Cross-fade between the current and next widget.
Definition animated_stacked_widget.h:29
@ SlideAndFade
Combine sliding and fading effects.
Definition animated_stacked_widget.h:31
void SetAnimationType(const AnimationType type)
Sets the type of animation to use for transitions.
Definition animated_stacked_widget.h:65
void OnGLTransitionFinished()
Slot called when the OpenGL transition animation finishes. Hides the OpenGL widget,...
Definition animated_stacked_widget.cpp:275
GLTransitionWidget * gl_transition_widget_
Optional widget for handling OpenGL-accelerated slide transitions.
Definition animated_stacked_widget.h:160
int GetDuration() const
Gets the current duration of the transition animation.
Definition animated_stacked_widget.h:59
void AnimatePush(int next_index) const
Configures and adds animations to the animation_group_ for a push transition.
Definition animated_stacked_widget.cpp:237
void PrepareAnimation(int next_index) const
Prepares the appropriate animation based on animation_type_. Calls the corresponding Animate* method ...
Definition animated_stacked_widget.cpp:80
int duration_
Duration of the transition animation in milliseconds.
Definition animated_stacked_widget.h:150
void AnimateFade(int next_index) const
Configures and adds animations to the animation_group_ for a fade transition.
Definition animated_stacked_widget.cpp:131
bool animation_running_
Flag indicating if a transition animation is currently running.
Definition animated_stacked_widget.h:156
An OpenGL widget designed to render smooth, animated slide transitions between two other widgets.
Definition gl_transition_widget.h:16