]> sigrok.org Git - pulseview.git/blobdiff - pv/mainwindow.cpp
Add "save selection range as..." to the export menu on the toolbar
[pulseview.git] / pv / mainwindow.cpp
index 195c460a1de90f3aea20b3fb4af9745a6a34103b..c3f8fdb8bad914e19fd010a153fb1294c6b67df0 100644 (file)
@@ -134,6 +134,11 @@ QAction* MainWindow::action_save_as() const
        return action_save_as_;
 }
 
+QAction* MainWindow::action_save_selection_as() const
+{
+       return action_save_selection_as_;
+}
+
 QAction* MainWindow::action_connect() const
 {
        return action_connect_;
@@ -666,20 +671,6 @@ void MainWindow::save_selection_to_file()
        // Stop any currently running capture session
        session_.stop_capture();
 
-       // Get sample rate
-       double samplerate = 0.0;
-
-       for (const shared_ptr<pv::data::SignalData> d : session_.get_data()) {
-               assert(d);
-               const vector< shared_ptr<pv::data::Segment> > segments =
-                       d->segments();
-               for (const shared_ptr<pv::data::Segment> &s : segments)
-                       samplerate = std::max(samplerate, s->samplerate());
-       }
-
-       if (samplerate == 0.0)
-               samplerate = 1;
-
        // Verify that the cursors are active and fetch their values
        if (!view_->cursors()->enabled()) {
                show_session_error(tr("Missing Cursors"), tr("You need to set the " \
@@ -688,6 +679,8 @@ void MainWindow::save_selection_to_file()
                return;
        }
 
+       const double samplerate = session_.get_samplerate();
+
        const pv::util::Timestamp& start_time = view_->cursors()->first()->time();
        const pv::util::Timestamp& end_time = view_->cursors()->second()->time();