summaryrefslogtreecommitdiff
path: root/src/expanderwidget.h
diff options
context:
space:
mode:
authorSilarn <jrim@rimpo.org>2019-07-22 01:00:42 -0500
committerSilarn <jrim@rimpo.org>2019-07-22 01:00:42 -0500
commitdcd6d624672019727d7effd17aac86f72bff438b (patch)
tree1e8d3856f657d898c5992631599cf272d785f973 /src/expanderwidget.h
parent179a73857125ee604f42b0d5c2d765183c86d2c7 (diff)
parente73c309f08eff98f0dbd2590f594a83b67431eac (diff)
Merge branch 'Develop'
Diffstat (limited to 'src/expanderwidget.h')
-rw-r--r--src/expanderwidget.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/expanderwidget.h b/src/expanderwidget.h
new file mode 100644
index 00000000..da3eb9d6
--- /dev/null
+++ b/src/expanderwidget.h
@@ -0,0 +1,46 @@
+#ifndef EXPANDERWIDGET_H
+#define EXPANDERWIDGET_H
+
+#include <QToolButton>
+
+/* Takes a QToolButton and a widget and creates an expandable widget.
+**/
+class ExpanderWidget
+{
+public:
+ /** empty expander, use set()
+ **/
+ ExpanderWidget();
+
+ /** see set()
+ **/
+ ExpanderWidget(QToolButton* button, QWidget* content);
+
+ /** @brief sets the button and content widgets to use
+ * the button will be given an arrow icon, clicking it will toggle the
+ * visibility of the given widget
+ * @param button the button that toggles the content
+ * @param content the widget that will be shown or hidden
+ * @param opened initial state, defaults to closed
+ **/
+ void set(QToolButton* button, QWidget* content, bool opened=false);
+
+ /** either opens or closes the expander depending on the current state
+ **/
+ void toggle();
+
+ /** sets the current state of the expander
+ **/
+ void toggle(bool b);
+
+ /** returns whether the expander is currently opened
+ **/
+ bool opened() const;
+
+private:
+ QToolButton* m_button;
+ QWidget* m_content;
+ bool opened_;
+};
+
+#endif // EXPANDERWIDGET_H