X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=37b7bfcd3854792a40e639e8b5c8ab9a05baa05e;hp=0397c7f4a6076de6782f364be497ae8f462ad560;hb=613d097c5af2d12ffd68e2dfab309b518edca1a6;hpb=82c7f64018db2a90f44704e55ba469151522762f diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 0397c7f4..37b7bfcd 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -39,10 +39,10 @@ #include "devicemanager.h" #include "dialogs/about.h" #include "dialogs/connect.h" -#include "dialogs/decoder.h" -#include "toolbars/contextbar.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 @@ -66,8 +66,7 @@ MainWindow::MainWindow(DeviceManager &device_manager, QWidget *parent) : QMainWindow(parent), _device_manager(device_manager), - _session(device_manager), - _decoders_add_mapper(this) + _session(device_manager) { setup_ui(); if (open_file_name) { @@ -98,8 +97,6 @@ void MainWindow::setup_ui() setCentralWidget(_central_widget); _view = new pv::view::View(_session, this); - connect(_view, SIGNAL(selection_changed()), this, - SLOT(view_selection_changed())); _vertical_layout->addWidget(_view); @@ -180,14 +177,13 @@ void MainWindow::setup_ui() _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); @@ -217,21 +213,15 @@ void MainWindow::setup_ui() addToolBar(_toolbar); // Setup the sampling bar - _sampling_bar = new toolbars::SamplingBar(this); + _sampling_bar = new toolbars::SamplingBar(_session, this); // Populate the device list and select the initially selected device update_device_list(); - connect(_sampling_bar, SIGNAL(device_selected()), this, - SLOT(device_selected())); connect(_sampling_bar, SIGNAL(run_stop()), this, SLOT(run_stop())); addToolBar(_sampling_bar); - // Setup the context bar - _context_bar = new toolbars::ContextBar(this); - addToolBar(_context_bar); - // Set the title setWindowTitle(QApplication::translate("MainWindow", "PulseView", 0, QApplication::UnicodeUTF8)); @@ -295,27 +285,6 @@ void MainWindow::show_session_error( 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 @@ -376,26 +345,10 @@ void MainWindow::on_actionAbout_triggered() dlg.exec(); } -void MainWindow::device_selected() -{ - _session.set_device(_sampling_bar->get_selected_device()); -} - -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(); - assert(dec); - - const std::vector< boost::shared_ptr > &sigs = - _session.get_signals(); - - dialogs::Decoder dlg(this, dec, sigs); - if(dlg.exec() != QDialog::Accepted) - return; - - _session.add_decoder(dec); + assert(decoder); + _session.add_decoder(decoder); } void MainWindow::run_stop() @@ -419,13 +372,4 @@ void MainWindow::capture_state_changed(int state) _sampling_bar->set_capture_state((pv::SigSession::capture_state)state); } -void MainWindow::view_selection_changed() -{ - assert(_context_bar); - - const list > items( - _view->selected_items()); - _context_bar->set_selected_items(items); -} - } // namespace pv