paint_hover_marker(p);
}
+void DecodeTrace::update_stack_button()
+{
+ const vector< shared_ptr<data::decode::Decoder> > &stack = decode_signal_->decoder_stack();
+
+ // Only show decoders in the menu that can be stacked onto the last one in the stack
+ if (!stack.empty()) {
+ const srd_decoder* d = stack.back()->decoder();
+
+ if (d->outputs) {
+ pv::widgets::DecoderMenu *const decoder_menu =
+ new pv::widgets::DecoderMenu(stack_button_, (const char*)(d->outputs->data));
+ connect(decoder_menu, SIGNAL(decoder_selected(srd_decoder*)),
+ this, SLOT(on_stack_decoder(srd_decoder*)));
+
+ stack_button_->setMenu(decoder_menu);
+ stack_button_->show();
+ return;
+ }
+ }
+
+ // No decoders available for stacking
+ stack_button_->setMenu(nullptr);
+ stack_button_->hide();
+}
+
void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form)
{
using pv::data::decode::Decoder;
}
// Add stacking button
- pv::widgets::DecoderMenu *const decoder_menu =
- new pv::widgets::DecoderMenu(parent);
- connect(decoder_menu, SIGNAL(decoder_selected(srd_decoder*)),
- this, SLOT(on_stack_decoder(srd_decoder*)));
-
- QPushButton *const stack_button =
- new QPushButton(tr("Stack Decoder"), parent);
- stack_button->setMenu(decoder_menu);
- stack_button->setToolTip(tr("Stack a higher-level decoder on top of this one"));
+ stack_button_ = new QPushButton(tr("Stack Decoder"), parent);
+ stack_button_->setToolTip(tr("Stack a higher-level decoder on top of this one"));
+ update_stack_button();
QHBoxLayout *stack_button_box = new QHBoxLayout;
- stack_button_box->addWidget(stack_button, 0, Qt::AlignRight);
+ stack_button_box->addWidget(stack_button_, 0, Qt::AlignRight);
form->addRow(stack_button_box);
}
#include <QColor>
#include <QComboBox>
+#include <QPushButton>
#include <QSignalMapper>
#include <QTimer>
const QString get_annotation_at_point(const QPoint &point);
+ void update_stack_button();
+
void create_decoder_form(int index,
shared_ptr<pv::data::decode::Decoder> &dec,
QWidget *parent, QFormLayout *form);
pair<uint64_t, uint64_t> selected_sample_range_;
vector<pv::widgets::DecoderGroupBox*> decoder_forms_;
+ QPushButton* stack_button_;
map<data::decode::Row, int> row_title_widths_;
int row_height_, max_visible_rows_;
namespace pv {
namespace widgets {
-DecoderMenu::DecoderMenu(QWidget *parent, bool first_level_decoder) :
+DecoderMenu::DecoderMenu(QWidget *parent, const char* input, bool first_level_decoder) :
QMenu(parent),
mapper_(this)
{
assert(d);
const bool have_channels = (d->channels || d->opt_channels) != 0;
- if (first_level_decoder == have_channels) {
- QAction *const action =
- addAction(QString::fromUtf8(d->name));
- action->setData(qVariantFromValue(l->data));
- mapper_.setMapping(action, action);
- connect(action, SIGNAL(triggered()),
- &mapper_, SLOT(map()));
+ if (first_level_decoder != have_channels)
+ continue;
+
+ if (!first_level_decoder) {
+ // Dismiss all non-stacked decoders unless we're looking for first-level decoders
+ if (!d->inputs)
+ continue;
+
+ // TODO For now we ignore that d->inputs is actually a list
+ if (strncmp((char*)(d->inputs->data), input, 1024) != 0)
+ continue;
}
+
+ 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(li);
Q_OBJECT;
public:
- DecoderMenu(QWidget *parent, bool first_level_decoder = false);
+ DecoderMenu(QWidget *parent, const char* input, bool first_level_decoder = false);
private:
static int decoder_name_cmp(const void *a, const void *b);