-
Notifications
You must be signed in to change notification settings - Fork 4
/
SlidingStackedWidget.h
87 lines (68 loc) · 2.5 KB
/
SlidingStackedWidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef SLIDINGSTACKEDWIDGET_H
#define SLIDINGSTACKEDWIDGET_H
#include <QStackedWidget>
#if (QT_VERSION >= 0x050000)
#include <QtWidgets>
#else
#endif // (QT_VERSION >= 0x050000)
#include <QtGui>
#include <QWidget>
#include <QDebug>
#include <QEasingCurve>
class ImageWidget;
/*!
Description
SlidingStackedWidget is a class that is derived from QtStackedWidget
and allows smooth side shifting of widgets, in addition
to the original hard switching from one to another as offered by
QStackedWidget itself.
*/
class SlidingStackedWidget : public QStackedWidget
{
Q_OBJECT
public:
//! This enumeration is used to define the animation direction
enum t_direction {
LEFT2RIGHT,
RIGHT2LEFT,
TOP2BOTTOM,
BOTTOM2TOP,
AUTOMATIC
};
//! The Constructor and Destructor
SlidingStackedWidget(QWidget *parent);
~SlidingStackedWidget(void);
public slots:
//! Some basic settings API
void setSpeed(int speed); //animation duration in milliseconds
void setAnimation(enum QEasingCurve::Type animationtype); //check out the QEasingCurve documentation for different styles
void setVerticalMode(bool vertical=true);
void setWrap(bool wrap); //wrapping is related to slideInNext/Prev;it defines the behaviour when reaching last/first page
//! The Animation / Page Change API
void slideInNext();
void slideInPrev();
void slideInIdx(int idx, bool withanimation=true, enum t_direction direction=AUTOMATIC);
signals:
//! this is used for internal purposes in the class engine
void animationFinished(void);
protected slots:
//! this is used for internal purposes in the class engine
void animationDoneSlot(void);
protected:
//! this is used for internal purposes in the class engine
void slideInWgt(QWidget * nextWidget, enum t_direction direction);
void resizeEvent( QResizeEvent *event);
QWidget *m_mainwindow;
int m_speed;
enum QEasingCurve::Type m_animationtype;
bool m_vertical;
int m_now;
int m_next;
bool m_wrap;
QPoint m_pnow;
bool m_active;
ImageWidget *mBeginWidget, *mEndWidget;
QPixmap mBeginPixmap, mEndPixmap;
QColor mBackgroundColor;
};
#endif // SLIDINGSTACKEDWIDGET_H