]> sigrok.org Git - pulseview.git/blobdiff - pv/mainwindow.cpp
Added empty context bar
[pulseview.git] / pv / mainwindow.cpp
index 16147b14ff6df87f0960a7783c8c07c928efe130..6b3398f22d9a40c7bb8266b24a37e29972fe3bef 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"
 
@@ -60,7 +61,8 @@ 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) {
@@ -184,7 +186,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 +205,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));
@@ -268,20 +275,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);
 }