]> sigrok.org Git - pulseview.git/blobdiff - pv/mainwindow.cpp
Initial working context bar
[pulseview.git] / pv / mainwindow.cpp
index dcbaf1812ab268765e626d69f5c280042c6ff65e..e70ca9891c565ca81891ef30e2f1b2246aa661d8 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #ifdef ENABLE_SIGROKDECODE
-#include <sigrokdecode.h>
+#include <libsigrokdecode/libsigrokdecode.h>
 #endif
 
 #include <boost/bind.hpp>
@@ -41,6 +41,7 @@
 #include "devicemanager.h"
 #include "dialogs/about.h"
 #include "dialogs/connect.h"
+#include "toolbars/contextbar.h"
 #include "toolbars/samplingbar.h"
 #include "view/view.h"
 
 #include <glib.h>
 #include <libsigrok/libsigrok.h>
 
+using namespace boost;
 using namespace std;
 
 namespace pv {
 
+namespace view {
+class SelectableItem;
+}
+
 MainWindow::MainWindow(DeviceManager &device_manager,
        const char *open_file_name,
        QWidget *parent) :
@@ -92,6 +98,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
@@ -204,6 +213,11 @@ void MainWindow::setup_ui()
                SLOT(run_stop()));
        addToolBar(_sampling_bar);
 
+       // Setup the context bar
+       _context_bar = new toolbars::ContextBar(this);
+       addToolBar(_context_bar);
+       insertToolBarBreak(_context_bar);
+
        // Set the title
        setWindowTitle(QApplication::translate("MainWindow", "PulseView", 0,
                QApplication::UnicodeUTF8));
@@ -269,15 +283,22 @@ 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 the user selected a device, select it in the device list. Select the
@@ -345,4 +366,13 @@ void MainWindow::capture_state_changed(int state)
        _sampling_bar->set_sampling(state != SigSession::Stopped);
 }
 
+void MainWindow::view_selection_changed()
+{
+       assert(_context_bar);
+
+       const list<weak_ptr<pv::view::SelectableItem> > items(
+               _view->selected_items());
+       _context_bar->set_selected_items(items);
+}
+
 } // namespace pv