From: Soeren Apel Date: Thu, 7 Nov 2019 21:49:11 +0000 (+0100) Subject: Fix #1412 more by allowing the PD stack menu to be scrolled X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=15784350767c05f3afb2f9af0c4b212a89493e30;p=pulseview.git Fix #1412 more by allowing the PD stack menu to be scrolled --- diff --git a/pv/views/trace/decodetrace.cpp b/pv/views/trace/decodetrace.cpp index f7f60a28..f76e43a8 100644 --- a/pv/views/trace/decodetrace.cpp +++ b/pv/views/trace/decodetrace.cpp @@ -288,6 +288,8 @@ void DecodeTrace::update_stack_button() connect(decoder_menu, SIGNAL(decoder_selected(srd_decoder*)), this, SLOT(on_stack_decoder(srd_decoder*))); + decoder_menu->setStyleSheet("QMenu { menu-scrollable: 1; }"); + stack_button_->setMenu(decoder_menu); stack_button_->show(); return; diff --git a/pv/widgets/decodermenu.cpp b/pv/widgets/decodermenu.cpp index 9fcc0cf0..505a1f67 100644 --- a/pv/widgets/decodermenu.cpp +++ b/pv/widgets/decodermenu.cpp @@ -30,8 +30,8 @@ DecoderMenu::DecoderMenu(QWidget *parent, const char* input, bool first_level_de QMenu(parent), mapper_(this) { - GSList *li = g_slist_sort(g_slist_copy( - (GSList*)srd_decoder_list()), decoder_name_cmp); + GSList *li = g_slist_sort(g_slist_copy((GSList*)srd_decoder_list()), decoder_name_cmp); + for (GSList *l = li; l; l = l->next) { const srd_decoder *const d = (srd_decoder*)l->data; assert(d); @@ -50,30 +50,26 @@ DecoderMenu::DecoderMenu(QWidget *parent, const char* input, bool first_level_de continue; } - QAction *const action = - addAction(QString::fromUtf8(d->name)); + QAction *const action = addAction(QString::fromUtf8(d->name)); action->setData(qVariantFromValue(l->data)); mapper_.setMapping(action, action); - connect(action, SIGNAL(triggered()), - &mapper_, SLOT(map())); + connect(action, SIGNAL(triggered()), &mapper_, SLOT(map())); } g_slist_free(li); - connect(&mapper_, SIGNAL(mapped(QObject*)), - this, SLOT(on_action(QObject*))); + connect(&mapper_, SIGNAL(mapped(QObject*)), this, SLOT(on_action(QObject*))); } int DecoderMenu::decoder_name_cmp(const void *a, const void *b) { - return strcmp(((const srd_decoder*)a)->name, - ((const srd_decoder*)b)->name); + return strcmp(((const srd_decoder*)a)->name, ((const srd_decoder*)b)->name); } void DecoderMenu::on_action(QObject *action) { assert(action); - srd_decoder *const dec = - (srd_decoder*)((QAction*)action)->data().value(); + + srd_decoder *const dec = (srd_decoder*)((QAction*)action)->data().value(); assert(dec); decoder_selected(dec);