X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=5fe4ccb6cfb63cce767ef5bbb142d99216503528;hb=0de8fb27ab376153db50bed98e643767e4eac1a4;hp=16147b14ff6df87f0960a7783c8c07c928efe130;hpb=107ca6d350b51186d12dac9273f6ed130b3f5dd7;p=pulseview.git diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 16147b1..5fe4ccb 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 @@ -41,6 +39,7 @@ #include "devicemanager.h" #include "dialogs/about.h" #include "dialogs/connect.h" +#include "toolbars/contextbar.h" #include "toolbars/samplingbar.h" #include "view/view.h" @@ -52,15 +51,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 +96,9 @@ 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); // Setup the menu bar @@ -184,7 +192,7 @@ void MainWindow::setup_ui() 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); @@ -203,6 +211,10 @@ void MainWindow::setup_ui() 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)); @@ -268,20 +280,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); } @@ -331,6 +352,7 @@ void MainWindow::run_stop() QString("Capture failed"), _1)); break; + case SigSession::AwaitingTrigger: case SigSession::Running: _session.stop_capture(); break; @@ -339,7 +361,16 @@ 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); +} + +void MainWindow::view_selection_changed() +{ + assert(_context_bar); + + const list > items( + _view->selected_items()); + _context_bar->set_selected_items(items); } } // namespace pv