summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-05-20 18:44:41 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-05-20 18:44:41 -0400
commit0088ee963b25495e6cce790005dcf1356a73e7b8 (patch)
tree6fed65fb7e507fb84cda2d2b0f74897010164865 /src
parent513eaaa3556bc08c7ac9d03944ee35deff9d7ceb (diff)
documented ExpanderWidget, removed checkable stuff because the state is kept internally
Diffstat (limited to 'src')
-rw-r--r--src/modinfodialog.cpp5
-rw-r--r--src/modinfodialog.h22
2 files changed, 23 insertions, 4 deletions
diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp
index ca09aaa0..cff1387c 100644
--- a/src/modinfodialog.cpp
+++ b/src/modinfodialog.cpp
@@ -282,10 +282,9 @@ void ExpanderWidget::set(QToolButton* button, QWidget* content, bool o)
m_content = content;
m_button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
- m_button->setCheckable(true);
+ QObject::connect(m_button, &QToolButton::clicked, [&]{ toggle(); });
toggle(o);
- QObject::connect(m_button, &QToolButton::clicked, [&]{ toggle(); });
}
void ExpanderWidget::toggle()
@@ -302,11 +301,9 @@ void ExpanderWidget::toggle(bool b)
{
if (b) {
m_button->setArrowType(Qt::DownArrow);
- m_button->setChecked(false);
m_content->show();
} else {
m_button->setArrowType(Qt::RightArrow);
- m_button->setChecked(false);
m_content->hide();
}
diff --git a/src/modinfodialog.h b/src/modinfodialog.h
index 3ce76740..dc04deb3 100644
--- a/src/modinfodialog.h
+++ b/src/modinfodialog.h
@@ -183,16 +183,38 @@ private:
};
+/* 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: