]> sigrok.org Git - pulseview.git/blobdiff - pv/mainwindow.cpp
Added missing virtual destructors
[pulseview.git] / pv / mainwindow.cpp
index 66bed74896ae4f8edf7e3327999dd6b0f6de97bb..bd2f5fea99a112fcfa94e848b39cbe5e12d5a73a 100644 (file)
@@ -152,6 +152,7 @@ void MainWindow::setup_ui()
        _action_view_show_cursors = new QAction(this);
        _action_view_show_cursors->setCheckable(true);
        _action_view_show_cursors->setChecked(_view->cursors_shown());
+       _action_view_show_cursors->setShortcut(QKeySequence(Qt::Key_C));
        _action_view_show_cursors->setObjectName(
                QString::fromUtf8("actionViewShowCursors"));
        _action_view_show_cursors->setText(QApplication::translate(
@@ -176,7 +177,7 @@ void MainWindow::setup_ui()
        setMenuBar(_menu_bar);
        QMetaObject::connectSlotsByName(this);
 
-       // Setup the toolbars
+       // Setup the toolbar
        _toolbar = new QToolBar(this);
        _toolbar->addAction(_action_open);
        _toolbar->addSeparator();
@@ -184,12 +185,24 @@ void MainWindow::setup_ui()
        _toolbar->addAction(_action_view_zoom_out);
        addToolBar(_toolbar);
 
+       // Setup the sampling bar
        _sampling_bar = new toolbars::SamplingBar(this);
+
+       // Populate the device list and select the initially selected device
        scan_devices();
+       if(!_devices.empty()) {
+               struct sr_dev_inst *const initial_sdi = _devices.front();
+               _sampling_bar->set_selected_device(initial_sdi);
+               _session.set_device(initial_sdi);
+       }
+
+       connect(_sampling_bar, SIGNAL(device_selected()), this,
+               SLOT(device_selected()));
        connect(_sampling_bar, SIGNAL(run_stop()), this,
                SLOT(run_stop()));
        addToolBar(_sampling_bar);
 
+       // Set the title
        setWindowTitle(QApplication::translate("MainWindow", "PulseView", 0,
                QApplication::UnicodeUTF8));
 
@@ -250,7 +263,8 @@ void MainWindow::on_actionOpen_triggered()
        const QString file_name = QFileDialog::getOpenFileName(
                this, tr("Open File"), "",
                tr("Sigrok Sessions (*.sr)"));
-       load_file(file_name);
+       if (!file_name.isEmpty())
+               load_file(file_name);
 }
 
 void MainWindow::on_actionConnect_triggered()
@@ -266,6 +280,8 @@ void MainWindow::on_actionConnect_triggered()
                _devices.push_back(sdi);
                _sampling_bar->set_device_list(_devices);
                _sampling_bar->set_selected_device(sdi);
+
+               _session.set_device(sdi);
        }
 }
 
@@ -287,7 +303,12 @@ void MainWindow::on_actionViewZoomOut_triggered()
 void MainWindow::on_actionViewShowCursors_triggered()
 {
        assert(_view);
-       _view->show_cursors(_action_view_show_cursors->isChecked());
+
+       const bool show = !_view->cursors_shown();
+       if(show)
+               _view->centre_cursors();
+
+       _view->show_cursors(show);
 }
 
 void MainWindow::on_actionAbout_triggered()
@@ -296,13 +317,16 @@ void MainWindow::on_actionAbout_triggered()
        dlg.exec();
 }
 
+void MainWindow::device_selected()
+{
+       _session.set_device(_sampling_bar->get_selected_device());
+}
+
 void MainWindow::run_stop()
 {
        switch(_session.get_capture_state()) {
        case SigSession::Stopped:
-               _session.start_capture(
-                       _sampling_bar->get_selected_device(),
-                       _sampling_bar->get_record_length(),
+               _session.start_capture(_sampling_bar->get_record_length(),
                        boost::bind(&MainWindow::session_error, this,
                                QString("Capture failed"), _1));
                break;