Olive
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
collapsiblewidget.h
Go to the documentation of this file.
1 /***
2 
3  Olive - Non-Linear Video Editor
4  Copyright (C) 2019 Olive Team
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 ***/
20 
21 #ifndef COLLAPSIBLEWIDGET_H
22 #define COLLAPSIBLEWIDGET_H
23 
24 #include <QWidget>
25 #include <QLabel>
26 #include <QCheckBox>
27 #include <QHBoxLayout>
28 #include <QVBoxLayout>
29 #include <QPushButton>
30 #include <QFrame>
31 #include <QIcon>
32 
33 class CollapsibleWidgetHeader : public QWidget {
34  Q_OBJECT
35 public:
36  CollapsibleWidgetHeader(QWidget* parent = nullptr);
37  bool selected;
38 protected:
39  void mousePressEvent(QMouseEvent* event);
40  void paintEvent(QPaintEvent *event);
41 signals:
42  void select(bool, bool);
43 };
44 
45 class CollapsibleWidget : public QWidget
46 {
47  Q_OBJECT
48 public:
49  CollapsibleWidget(QWidget* parent = nullptr);
50  void SetContents(QWidget* c);
51  QString Title();
52  void SetTitle(const QString &);
53  bool IsFocused();
54  bool IsExpanded();
55  void SetExpanded(bool s);
56  bool IsSelected();
57 protected:
58  QCheckBox* enabled_check;
60  QWidget* contents;
61 private:
62  bool selected;
63  QLabel* header;
64  QVBoxLayout* layout;
65  QPushButton* collapse_button;
66  QFrame* line;
67  QHBoxLayout* title_bar_layout;
68  void set_button_icon(bool open);
69 
70 signals:
71  void deselect_others(QWidget*);
72  void visibleChanged(bool);
73 
74 private slots:
75  void on_visible_change();
76 
77 public slots:
78  void header_click(bool s, bool deselect);
79 };
80 
81 #endif // COLLAPSIBLEWIDGET_H
QPushButton * collapse_button
Definition: collapsiblewidget.h:65
Definition: collapsiblewidget.h:33
bool IsSelected()
Definition: collapsiblewidget.cpp:97
QHBoxLayout * title_bar_layout
Definition: collapsiblewidget.h:67
CollapsibleWidget(QWidget *parent=nullptr)
Definition: collapsiblewidget.cpp:36
bool selected
Definition: collapsiblewidget.h:62
void select(bool, bool)
void set_button_icon(bool open)
Definition: collapsiblewidget.cpp:102
Definition: collapsiblewidget.h:45
CollapsibleWidgetHeader * title_bar
Definition: collapsiblewidget.h:59
QString Title()
Definition: collapsiblewidget.cpp:116
void paintEvent(QPaintEvent *event)
Definition: collapsiblewidget.cpp:145
QFrame * line
Definition: collapsiblewidget.h:66
void on_visible_change()
Definition: collapsiblewidget.cpp:125
void SetContents(QWidget *c)
Definition: collapsiblewidget.cpp:106
void SetTitle(const QString &)
Definition: collapsiblewidget.cpp:121
void visibleChanged(bool)
void header_click(bool s, bool deselect)
Definition: collapsiblewidget.cpp:68
QWidget * contents
Definition: collapsiblewidget.h:60
void SetExpanded(bool s)
Definition: collapsiblewidget.cpp:90
bool IsExpanded()
Definition: collapsiblewidget.cpp:86
QLabel * header
Definition: collapsiblewidget.h:63
bool selected
Definition: collapsiblewidget.h:37
CollapsibleWidgetHeader(QWidget *parent=nullptr)
Definition: collapsiblewidget.cpp:129
QVBoxLayout * layout
Definition: collapsiblewidget.h:64
QCheckBox * enabled_check
Definition: collapsiblewidget.h:58
bool IsFocused()
Definition: collapsiblewidget.cpp:81
void mousePressEvent(QMouseEvent *event)
Definition: collapsiblewidget.cpp:133
void deselect_others(QWidget *)