X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=f7b8612054ff058997a8cd0f2cd3f75b8310f5a0;hp=02df0ad510e3fb38be0b108daf444804e1fbfcfc;hb=b213ef0991a13af0c74ffe5c54382c5c455c5496;hpb=7dd093df9796d08c9b15d494eeeb0f8cd3570591 diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 02df0ad5..f7b86120 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -39,7 +39,7 @@ #include "devicemanager.h" #include "dialogs/about.h" #include "dialogs/connect.h" -#include "toolbars/contextbar.h" +#include "dialogs/decoder.h" #include "toolbars/samplingbar.h" #include "view/view.h" @@ -97,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); @@ -216,21 +214,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)); @@ -304,7 +296,8 @@ 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)) { + for(; l; l = l->next) + { QAction *const action = parent->addAction(QString( ((srd_decoder*)l->data)->name)); action->setData(qVariantFromValue(l->data)); @@ -375,14 +368,26 @@ 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)action; + assert(action); + srd_decoder *const dec = + (srd_decoder*)((QAction*)action)->data().value(); + assert(dec); + + const std::vector< boost::shared_ptr > &sigs = + _session.get_signals(); + + GHashTable *const options = g_hash_table_new_full(g_str_hash, + g_str_equal, g_free, (GDestroyNotify)g_variant_unref); + + dialogs::Decoder dlg(this, dec, sigs, options); + if(dlg.exec() != QDialog::Accepted) { + g_hash_table_destroy(options); + return; + } + + _session.add_decoder(dec, dlg.get_probes(), options); } void MainWindow::run_stop() @@ -406,13 +411,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