forked from anatolyk82/ShaderTransitionView
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshadertransitionview.h
70 lines (54 loc) · 1.68 KB
/
shadertransitionview.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
#ifndef SHADERTRANSITIONVIEW_H
#define SHADERTRANSITIONVIEW_H
#include <QQuickItem>
#include <QStack>
#include <QDebug>
#include <QQmlComponent>
class ShaderTransitionView : public QQuickItem
{
Q_OBJECT
Q_DISABLE_COPY(ShaderTransitionView)
Q_PROPERTY(QString transition READ transition WRITE setTransition NOTIFY transitionChanged)
public:
ShaderTransitionView(QQuickItem *parent = 0);
~ShaderTransitionView();
QString transition() const { return m_transition; }
Q_INVOKABLE void pushQQuickItem( QQmlComponent* item ) { m_insideStack.push(item); }
Q_INVOKABLE QQmlComponent* popQQuickItem() {
if( m_insideStack.length() > 0 ) {
return m_insideStack.pop();
} else {
return NULL;
}
}
Q_INVOKABLE int lengthQQuickStack() { return m_insideStack.length(); }
Q_INVOKABLE QQmlComponent* topQQuickItem() {
if( m_insideStack.length() > 0 ) {
return m_insideStack.top();
} else {
return NULL;
}
}
Q_INVOKABLE void clearQQuickStack() { m_insideStack.clear(); }
Q_INVOKABLE QQmlComponent* getQQuickItem( int index ) {
if( (index > 0) && (index < m_insideStack.length() ) ) {
return m_insideStack.takeAt( index );
} else {
return NULL;
}
}
public slots:
void setTransition(QString transition)
{
if (m_transition == transition)
return;
m_transition = transition;
emit transitionChanged(transition);
}
signals:
void transitionChanged(QString transition);
private:
QString m_transition;
QStack<QQmlComponent*> m_insideStack;
};
#endif // SHADERTRANSITIONVIEW_H