forked from 4lex4/scantailor-advanced
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCollapsibleGroupBox.h
83 lines (53 loc) · 1.76 KB
/
CollapsibleGroupBox.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
#ifndef SCANTAILOR_COLLAPSIBLEGROUPBOX_H
#define SCANTAILOR_COLLAPSIBLEGROUPBOX_H
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QToolButton>
#include <unordered_set>
class CollapsibleGroupBox : public QGroupBox {
Q_OBJECT
/**
* The collapsed state of this group box. If it is set to true, all content is hidden
* if it is set to false all content is shown.
*/
Q_PROPERTY(bool collapsed READ isCollapsed WRITE setCollapsed USER true)
public:
explicit CollapsibleGroupBox(QWidget* parent = nullptr);
explicit CollapsibleGroupBox(const QString& title, QWidget* parent = nullptr);
~CollapsibleGroupBox() override;
/**
* Returns the current collapsed state of this group box.
*/
bool isCollapsed() const;
/**
* Collapse or expand this group box.
*
* \param collapse Will collapse on true and expand on false
*/
void setCollapsed(bool collapse);
signals:
/** Signal emitted when the group box collapsed/expanded state is changed, and when first shown */
void collapsedStateChanged(bool collapsed);
public slots:
void checkToggled(bool);
void checkClicked(bool checked);
void toggleCollapsed();
protected:
void updateWidgets();
void showEvent(QShowEvent* event) override;
void changeEvent(QEvent* event) override;
void childEvent(QChildEvent* event) override;
bool eventFilter(QObject* watched, QEvent* event) override;
void initialize();
void loadState();
void saveState();
QString getSettingsKey() const;
private:
bool m_collapsed = false;
bool m_shown = false;
QToolButton* m_collapseButton = nullptr;
QIcon m_collapseIcon;
QIcon m_expandIcon;
int m_ignoreVisibilityEvents = 0;
std::unordered_set<QWidget*> m_collapsedWidgets;
};
#endif // SCANTAILOR_COLLAPSIBLEGROUPBOX_H