Renamed C++ headers to .hpp
[pulseview.git] / pv / widgets / decodergroupbox.cpp
index 4cf6a086d73e8aee10a9a6295884e7381699d21a..7127ba1310fadaf01ca97c760b6f3e56fca5a898 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-#include "decodergroupbox.h"
+#include "decodergroupbox.hpp"
 
-#include <QAction>
 #include <QHBoxLayout>
 #include <QLabel>
-#include <QToolBar>
+#include <QPushButton>
 #include <QVBoxLayout>
 
 #include <assert.h>
@@ -33,30 +32,45 @@ namespace widgets {
 
 DecoderGroupBox::DecoderGroupBox(QString title, QWidget *parent) :
        QWidget(parent),
-       _layout(new QGridLayout)
+       layout_(new QGridLayout),
+       show_hide_button_(QIcon(":/icons/decoder-shown.svg"), QString(), this)
 {
-       _layout->setContentsMargins(0, 0, 0, 0);
-       setLayout(_layout);
+       layout_->setContentsMargins(0, 0, 0, 0);
+       setLayout(layout_);
 
-       _layout->addWidget(new QLabel(QString("<h2>%1</h2><hl/>").arg(title)),
+       layout_->addWidget(new QLabel(QString("<h3>%1</h3>").arg(title)),
                0, 0);
-       _layout->setColumnStretch(0, 1);
+       layout_->setColumnStretch(0, 1);
 
-       QToolBar *const toolbar = new QToolBar;
-       toolbar->setIconSize(QSize(16, 16));
-       _layout->addWidget(toolbar, 0, 1);
+       QHBoxLayout *const toolbar = new QHBoxLayout;
+       layout_->addLayout(toolbar, 0, 1);
 
-       QAction *const delete_action = new QAction(
-               QIcon(":/icons/decoder-delete.svg"), tr("Delete"), this);
-       connect(delete_action, SIGNAL(triggered()),
+       show_hide_button_.setFlat(true);
+       show_hide_button_.setIconSize(QSize(16, 16));
+       connect(&show_hide_button_, SIGNAL(clicked()),
+               this, SIGNAL(show_hide_decoder()));
+       toolbar->addWidget(&show_hide_button_);
+
+       QPushButton *const delete_button = new QPushButton(
+               QIcon(":/icons/decoder-delete.svg"), QString(), this);
+       delete_button->setFlat(true);
+       delete_button->setIconSize(QSize(16, 16));
+       connect(delete_button, SIGNAL(clicked()),
                this, SIGNAL(delete_decoder()));
-       toolbar->addAction(delete_action);
+       toolbar->addWidget(delete_button);
 }
 
 void DecoderGroupBox::add_layout(QLayout *layout)
 {
        assert(layout);
-       _layout->addLayout(layout, 1, 0, 1, 2);
+       layout_->addLayout(layout, 1, 0, 1, 2);
+}
+
+void DecoderGroupBox::set_decoder_visible(bool visible)
+{
+       show_hide_button_.setIcon(QIcon(visible ?
+               ":/icons/decoder-shown.svg" :
+               ":/icons/decoder-hidden.svg"));
 }
 
 } // widgets