]> sigrok.org Git - pulseview.git/commitdiff
Fix #510 by disabling removal of the last decoder from the popup
authorSoeren Apel <redacted>
Mon, 24 Aug 2015 10:32:11 +0000 (12:32 +0200)
committerUwe Hermann <redacted>
Tue, 25 Aug 2015 16:11:16 +0000 (18:11 +0200)
pv/view/decodetrace.cpp
pv/widgets/decodergroupbox.cpp
pv/widgets/decodergroupbox.hpp

index 36e7a10458a0c9467740f5edf770177199268e2f..7bb62b2b288703c69dc9f725fad7cd43e071daf5 100644 (file)
@@ -642,13 +642,17 @@ void DecodeTrace::create_decoder_form(int index,
        const srd_decoder *const decoder = dec->decoder();
        assert(decoder);
 
+       const bool decoder_deletable = index > 0;
+
        pv::widgets::DecoderGroupBox *const group =
                new pv::widgets::DecoderGroupBox(
-                       QString::fromUtf8(decoder->name));
+                       QString::fromUtf8(decoder->name), nullptr, decoder_deletable);
        group->set_decoder_visible(dec->shown());
 
-       delete_mapper_.setMapping(group, index);
-       connect(group, SIGNAL(delete_decoder()), &delete_mapper_, SLOT(map()));
+       if (decoder_deletable) {
+               delete_mapper_.setMapping(group, index);
+               connect(group, SIGNAL(delete_decoder()), &delete_mapper_, SLOT(map()));
+       }
 
        show_hide_mapper_.setMapping(group, index);
        connect(group, SIGNAL(show_hide_decoder()),
index 7127ba1310fadaf01ca97c760b6f3e56fca5a898..81e5e90218cce848366d6021ec32c83c557ba2d0 100644 (file)
@@ -30,7 +30,7 @@
 namespace pv {
 namespace widgets {
 
-DecoderGroupBox::DecoderGroupBox(QString title, QWidget *parent) :
+DecoderGroupBox::DecoderGroupBox(QString title, QWidget *parent, bool isDeletable) :
        QWidget(parent),
        layout_(new QGridLayout),
        show_hide_button_(QIcon(":/icons/decoder-shown.svg"), QString(), this)
@@ -51,13 +51,15 @@ DecoderGroupBox::DecoderGroupBox(QString title, QWidget *parent) :
                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->addWidget(delete_button);
+       if (isDeletable) {
+               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->addWidget(delete_button);
+       }
 }
 
 void DecoderGroupBox::add_layout(QLayout *layout)
index 73bc9971b68bbf90e848569b680422467ce5232f..7554431817fab64efe98532eee591d211e152823 100644 (file)
@@ -34,7 +34,8 @@ class DecoderGroupBox : public QWidget
        Q_OBJECT
 
 public:
-       DecoderGroupBox(QString title, QWidget *parent = nullptr);
+       DecoderGroupBox(QString title, QWidget *parent = nullptr,
+               bool isDeletable = true);
 
        void add_layout(QLayout *layout);