X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=37b7bfcd3854792a40e639e8b5c8ab9a05baa05e;hb=f0d37dab05f9fb055a9af8a05d776d1a5b4b0909;hp=16147b14ff6df87f0960a7783c8c07c928efe130;hpb=107ca6d350b51186d12dac9273f6ed130b3f5dd7;p=pulseview.git diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 16147b1..37b7bfc 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -18,9 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifdef ENABLE_SIGROKDECODE -#include -#endif +#include #include #include @@ -42,7 +40,9 @@ #include "dialogs/about.h" #include "dialogs/connect.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 @@ -52,15 +52,21 @@ #include #include +using namespace boost; using namespace std; namespace pv { +namespace view { +class SelectableItem; +} + MainWindow::MainWindow(DeviceManager &device_manager, const char *open_file_name, QWidget *parent) : QMainWindow(parent), - _device_manager(device_manager) + _device_manager(device_manager), + _session(device_manager) { setup_ui(); if (open_file_name) { @@ -91,6 +97,7 @@ void MainWindow::setup_ui() setCentralWidget(_central_widget); _view = new pv::view::View(_session, this); + _vertical_layout->addWidget(_view); // Setup the menu bar @@ -165,6 +172,19 @@ void MainWindow::setup_ui() "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 pv::widgets::DecoderMenu(_menu_decoders); + _menu_decoders_add->setTitle(QApplication::translate( + "MainWindow", "&Add", 0, QApplication::UnicodeUTF8)); + connect(_menu_decoders_add, SIGNAL(decoder_selected(srd_decoder*)), + this, SLOT(add_decoder(srd_decoder*))); + + _menu_decoders->addMenu(_menu_decoders_add); + // Help Menu _menu_help = new QMenu(_menu_bar); _menu_help->setTitle(QApplication::translate( @@ -178,13 +198,14 @@ void MainWindow::setup_ui() _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); QMetaObject::connectSlotsByName(this); // Setup the toolbar - _toolbar = new QToolBar(this); + _toolbar = new QToolBar(tr("Main Toolbar"), this); _toolbar->addAction(_action_open); _toolbar->addSeparator(); _toolbar->addAction(_action_view_zoom_in); @@ -192,13 +213,11 @@ 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); @@ -268,20 +287,29 @@ void MainWindow::show_session_error( void MainWindow::on_actionOpen_triggered() { + // Enumerate the file formats + QString filters(tr("Sigrok Sessions (*.sr)")); + filters.append(tr(";;All Files (*.*)")); + + // Show the dialog const QString file_name = QFileDialog::getOpenFileName( - this, tr("Open File"), "", - tr("Sigrok Sessions (*.sr)")); + this, tr("Open File"), "", filters); if (!file_name.isEmpty()) load_file(file_name); } void MainWindow::on_actionConnect_triggered() { + // Stop any currently running capture session + _session.stop_capture(); + dialogs::Connect dlg(this, _device_manager); - if (!dlg.exec()) - return; - struct sr_dev_inst *const sdi = dlg.get_selected_device(); + // If the user selected a device, select it in the device list. Select the + // current device otherwise. + struct sr_dev_inst *const sdi = dlg.exec() ? + dlg.get_selected_device() : _session.get_device(); + update_device_list(sdi); } @@ -317,9 +345,10 @@ void MainWindow::on_actionAbout_triggered() dlg.exec(); } -void MainWindow::device_selected() +void MainWindow::add_decoder(srd_decoder *decoder) { - _session.set_device(_sampling_bar->get_selected_device()); + assert(decoder); + _session.add_decoder(decoder); } void MainWindow::run_stop() @@ -331,6 +360,7 @@ void MainWindow::run_stop() QString("Capture failed"), _1)); break; + case SigSession::AwaitingTrigger: case SigSession::Running: _session.stop_capture(); break; @@ -339,7 +369,7 @@ void MainWindow::run_stop() void MainWindow::capture_state_changed(int state) { - _sampling_bar->set_sampling(state != SigSession::Stopped); + _sampling_bar->set_capture_state((pv::SigSession::capture_state)state); } } // namespace pv