From: Joel Holdsworth Date: Tue, 4 Mar 2014 19:10:21 +0000 (+0000) Subject: Only show first-level decoders in the menu X-Git-Tag: pulseview-0.2.0~28 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=f69ec72d3cead13847045ca9cdf15d503f69e370 Only show first-level decoders in the menu --- diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index c75b3a9e..fcc929e9 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -220,7 +220,7 @@ void MainWindow::setup_ui() "MainWindow", "&Decoders", 0, QApplication::UnicodeUTF8)); pv::widgets::DecoderMenu *const menu_decoders_add = - new pv::widgets::DecoderMenu(menu_decoders); + new pv::widgets::DecoderMenu(menu_decoders, true); menu_decoders_add->setTitle(QApplication::translate( "MainWindow", "&Add", 0, QApplication::UnicodeUTF8)); connect(menu_decoders_add, SIGNAL(decoder_selected(srd_decoder*)), diff --git a/pv/widgets/decodermenu.cpp b/pv/widgets/decodermenu.cpp index 3273123e..23c74a0a 100644 --- a/pv/widgets/decodermenu.cpp +++ b/pv/widgets/decodermenu.cpp @@ -25,7 +25,7 @@ namespace pv { namespace widgets { -DecoderMenu::DecoderMenu(QWidget *parent) : +DecoderMenu::DecoderMenu(QWidget *parent, bool first_level_decoder) : QMenu(parent), _mapper(this) { @@ -33,12 +33,17 @@ DecoderMenu::DecoderMenu(QWidget *parent) : (GSList*)srd_decoder_list()), decoder_name_cmp); for(; l; l = l->next) { - QAction *const action = addAction(QString::fromUtf8( - ((srd_decoder*)l->data)->name)); - action->setData(qVariantFromValue(l->data)); - _mapper.setMapping(action, action); - connect(action, SIGNAL(triggered()), - &_mapper, SLOT(map())); + const srd_decoder *const d = (srd_decoder*)l->data; + assert(d); + + if (!first_level_decoder || d->probes || d->opt_probes) { + QAction *const action = + addAction(QString::fromUtf8(d->name)); + action->setData(qVariantFromValue(l->data)); + _mapper.setMapping(action, action); + connect(action, SIGNAL(triggered()), + &_mapper, SLOT(map())); + } } g_slist_free(l); diff --git a/pv/widgets/decodermenu.h b/pv/widgets/decodermenu.h index 88dcfaa4..20dd4120 100644 --- a/pv/widgets/decodermenu.h +++ b/pv/widgets/decodermenu.h @@ -34,7 +34,7 @@ class DecoderMenu : public QMenu Q_OBJECT; public: - DecoderMenu(QWidget *parent); + DecoderMenu(QWidget *parent, bool first_level_decoder = false); private: static int decoder_name_cmp(const void *a, const void *b);