forked from N1coc4colA/DA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstackedslidewidget.cpp
47 lines (38 loc) · 1.22 KB
/
stackedslidewidget.cpp
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
#include "stackedslidewidget.h"
#include "swipinggesture.h"
LDA_BEGIN_NAMESPACE
StackedSlideWidget::StackedSlideWidget(QWidget *parent) : QStackedWidget(parent), TouchInterfacing(this, ((TouchInterfacing *)this)) {}
StackedSlideWidget::~StackedSlideWidget()
{
this->TouchInterfacing::~TouchInterfacing();
this->QStackedWidget::~QStackedWidget();
}
bool StackedSlideWidget::handleOtherEvents(QEvent *e)
{
return this->event(e);
}
void StackedSlideWidget::paintEvent(QPaintEvent *) {}
bool StackedSlideWidget::handleSwipeGesture(SwipingGesture *gesture)
{
int index = this->currentIndex();
if (gesture->state() == Qt::GestureState::GestureFinished) {
if (gesture->horizontalDirection() == QSwipeGesture::SwipeDirection::Right) {
if ((index-1) > -1) {
index--;
} else {
index = count()-1;
}
} else if (gesture->horizontalDirection() == QSwipeGesture::SwipeDirection::Left) {
if ((index+1) < this->count()) {
index++;
} else {
index = 0;
}
}
this->setCurrentIndex(index);
return true;
} else {
return false;
}
}
LDA_END_NAMESPACE