QWidget *parent) :
QMainWindow(parent),
_device_manager(device_manager),
- _session(device_manager)
+ _session(device_manager),
+ _decoders_add_mapper(this)
{
setup_ui();
if (open_file_name) {
"MainWindow", "Show &Cursors", 0, QApplication::UnicodeUTF8));
_menu_view->addAction(_action_view_show_cursors);
+ // Decoders Menu
+ _menu_decoders = new QMenu(_menu_bar);
+ _menu_decoders->setTitle(QApplication::translate(
+ "MainWindow", "&Decoders", 0, QApplication::UnicodeUTF8));
+
+ _menu_decoders_add = new QMenu(_menu_decoders);
+ _menu_decoders_add->setTitle(QApplication::translate(
+ "MainWindow", "&Add", 0, QApplication::UnicodeUTF8));
+ setup_add_decoders(_menu_decoders_add);
+
+ _menu_decoders->addMenu(_menu_decoders_add);
+ connect(&_decoders_add_mapper, SIGNAL(mapped(QObject*)),
+ this, SLOT(add_decoder(QObject*)));
+
// Help Menu
_menu_help = new QMenu(_menu_bar);
_menu_help->setTitle(QApplication::translate(
_menu_bar->addAction(_menu_file->menuAction());
_menu_bar->addAction(_menu_view->menuAction());
+ _menu_bar->addAction(_menu_decoders->menuAction());
_menu_bar->addAction(_menu_help->menuAction());
setMenuBar(_menu_bar);
msg.exec();
}
+gint MainWindow::decoder_name_cmp(gconstpointer a, gconstpointer b)
+{
+ return strcmp(((const srd_decoder*)a)->name,
+ ((const srd_decoder*)b)->name);
+}
+
+void MainWindow::setup_add_decoders(QMenu *parent)
+{
+ GSList *l = g_slist_sort(g_slist_copy(
+ (GSList*)srd_decoder_list()), decoder_name_cmp);
+ while ((l = l->next)) {
+ QAction *const action = parent->addAction(QString(
+ ((srd_decoder*)l->data)->name));
+ action->setData(qVariantFromValue(l->data));
+ _decoders_add_mapper.setMapping(action, action);
+ connect(action, SIGNAL(triggered()),
+ &_decoders_add_mapper, SLOT(map()));
+ }
+ g_slist_free(l);
+}
+
void MainWindow::on_actionOpen_triggered()
{
// Enumerate the file formats
_session.set_device(_sampling_bar->get_selected_device());
}
+void MainWindow::add_decoder(QObject *action)
+{
+ (void)action;
+}
+
void MainWindow::run_stop()
{
switch(_session.get_capture_state()) {
#include <boost/weak_ptr.hpp>
#include <QMainWindow>
+#include <QSignalMapper>
#include "sigsession.h"
void update_device_list(
struct sr_dev_inst *selected_device = NULL);
+ static gint decoder_name_cmp(gconstpointer a, gconstpointer b);
+ void setup_add_decoders(QMenu *parent);
+
private slots:
void load_file(QString file_name);
void device_selected();
+ void add_decoder(QObject *action);
+
void run_stop();
void capture_state_changed(int state);
QAction *_action_view_zoom_out;
QAction *_action_view_show_cursors;
+ QMenu *_menu_decoders;
+ QMenu *_menu_decoders_add;
+ QSignalMapper _decoders_add_mapper;
+
QMenu *_menu_help;
QAction *_action_about;