forked from N1coc4colA/DA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdotsslidetabs.h
58 lines (47 loc) · 1.46 KB
/
dotsslidetabs.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
#ifndef DOTSSLIDETABS_H
#define DOTSSLIDETABS_H
#include "libda_global.h"
#include <QWidget>
class QStackedWidget;
LDA_BEGIN_NAMESPACE
/**
* @brief The same as QStackedWidget and it's tab, but user-slidable with dots to represent the pages.
*/
class LIBDA_SHARED_EXPORT DotsSlideTabs : public QWidget
{
Q_OBJECT
public:
DotsSlideTabs(QStackedWidget *source, int dots = 5, QWidget *parent = nullptr);
DotsSlideTabs(QStackedWidget *source, QWidget *parent = nullptr);
public Q_SLOTS:
void setSource(QStackedWidget *source);
void setMaximumVisibleDots(int dots);
void setDotsSize(int size);
void enableAutoDotsSizeUpdate(bool enable = true);
private Q_SLOTS:
void updateStates();
protected:
void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void enterEvent(QEvent *e) override;
void leaveEvent(QEvent *e) override;
bool event(QEvent *e) override;
virtual void updateDotsSize();
private:
void raiseConnections();
void closeConnections();
QStackedWidget *m_source = nullptr;
int max_dots;
int m_visibleDots = 0;
int m_currentDot = 0;
int m_dotSize = 0;
int hoveredDot = -1;
bool clicked = false;
bool hovered = false;
bool m_enableAutoUpdates = true;
};
LDA_END_NAMESPACE
#endif // DOTSSLIDETABS_H