pv/view/decode/annotation.cpp
pv/widgets/colourbutton.cpp
pv/widgets/colourpopup.cpp
+ pv/widgets/decodermenu.cpp
pv/widgets/popup.cpp
pv/widgets/popuptoolbutton.cpp
pv/widgets/wellarray.cpp
pv/view/viewport.h
pv/widgets/colourbutton.h
pv/widgets/colourpopup.h
+ pv/widgets/decodermenu.h
pv/widgets/popuptoolbutton.h
pv/widgets/wellarray.h
)
#include "toolbars/samplingbar.h"
#include "view/logicsignal.h"
#include "view/view.h"
+#include "widgets/decodermenu.h"
/* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */
#define __STDC_FORMAT_MACROS
QWidget *parent) :
QMainWindow(parent),
_device_manager(device_manager),
- _session(device_manager),
- _decoders_add_mapper(this)
+ _session(device_manager)
{
setup_ui();
if (open_file_name) {
_menu_decoders->setTitle(QApplication::translate(
"MainWindow", "&Decoders", 0, QApplication::UnicodeUTF8));
- _menu_decoders_add = new QMenu(_menu_decoders);
+ _menu_decoders_add = new pv::widgets::DecoderMenu(_menu_decoders);
_menu_decoders_add->setTitle(QApplication::translate(
"MainWindow", "&Add", 0, QApplication::UnicodeUTF8));
- setup_add_decoders(_menu_decoders_add);
+ connect(_menu_decoders_add, SIGNAL(decoder_selected(srd_decoder*)),
+ this, SLOT(add_decoder(srd_decoder*)));
_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);
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);
- for(; l; 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
dlg.exec();
}
-void MainWindow::add_decoder(QObject *action)
+void MainWindow::add_decoder(srd_decoder *decoder)
{
- assert(action);
- srd_decoder *const dec =
- (srd_decoder*)((QAction*)action)->data().value<void*>();
- assert(dec);
-
- _session.add_decoder(dec);
+ assert(decoder);
+ _session.add_decoder(decoder);
}
void MainWindow::run_stop()
#include <boost/weak_ptr.hpp>
#include <QMainWindow>
-#include <QSignalMapper>
#include "sigsession.h"
class View;
}
+namespace widgets {
+class DecoderMenu;
+}
+
class MainWindow : public QMainWindow
{
Q_OBJECT
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 on_actionAbout_triggered();
- void add_decoder(QObject *action);
+ void add_decoder(srd_decoder *decoder);
void run_stop();
QAction *_action_view_show_cursors;
QMenu *_menu_decoders;
- QMenu *_menu_decoders_add;
- QSignalMapper _decoders_add_mapper;
+ pv::widgets::DecoderMenu *_menu_decoders_add;
QMenu *_menu_help;
QAction *_action_about;
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <libsigrokdecode/libsigrokdecode.h>
+
+#include "decodermenu.h"
+
+namespace pv {
+namespace widgets {
+
+DecoderMenu::DecoderMenu(QWidget *parent) :
+ QMenu(parent),
+ _mapper(this)
+{
+ GSList *l = g_slist_sort(g_slist_copy(
+ (GSList*)srd_decoder_list()), decoder_name_cmp);
+ for(; l; l = l->next)
+ {
+ QAction *const action = addAction(QString(
+ ((srd_decoder*)l->data)->name));
+ action->setData(qVariantFromValue(l->data));
+ _mapper.setMapping(action, action);
+ connect(action, SIGNAL(triggered()),
+ &_mapper, SLOT(map()));
+ }
+ g_slist_free(l);
+
+ 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);
+}
+
+void DecoderMenu::on_action(QObject *action)
+{
+ assert(action);
+ srd_decoder *const dec =
+ (srd_decoder*)((QAction*)action)->data().value<void*>();
+ assert(dec);
+
+ decoder_selected(dec);
+}
+
+} // widgets
+} // pv
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PULSEVIEW_PV_WIDGETS_DECODERMENU_H
+#define PULSEVIEW_PV_WIDGETS_DECODERMENU_H
+
+#include <QMenu>
+#include <QSignalMapper>
+
+struct srd_decoder;
+
+namespace pv {
+namespace widgets {
+
+class DecoderMenu : public QMenu
+{
+ Q_OBJECT;
+
+public:
+ DecoderMenu(QWidget *parent);
+
+private:
+ static int decoder_name_cmp(const void *a, const void *b);
+
+
+private slots:
+ void on_action(QObject *action);
+
+signals:
+ void decoder_selected(srd_decoder *decoder);
+
+private:
+ QSignalMapper _mapper;
+};
+
+} // widgets
+} // pv
+
+#endif // PULSEVIEW_PV_WIDGETS_DECODERMENU_H
${PROJECT_SOURCE_DIR}/pv/view/decode/annotation.cpp
${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.cpp
${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.cpp
+ ${PROJECT_SOURCE_DIR}/pv/widgets/decodermenu.cpp
${PROJECT_SOURCE_DIR}/pv/widgets/popup.cpp
${PROJECT_SOURCE_DIR}/pv/widgets/wellarray.cpp
data/analogsnapshot.cpp
${PROJECT_SOURCE_DIR}/pv/view/viewport.h
${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.h
${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.h
+ ${PROJECT_SOURCE_DIR}/pv/widgets/decodermenu.h
${PROJECT_SOURCE_DIR}/pv/widgets/wellarray.h
)