From: Joel Holdsworth Date: Wed, 24 Apr 2013 19:09:15 +0000 (+0100) Subject: Update the SigSession device, when it is selected by the user X-Git-Tag: pulseview-0.1.0~18 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=5ac961e325a9d2cbafdd8fae3a6704d7348cf19a;p=pulseview.git Update the SigSession device, when it is selected by the user --- diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index f95cd451..bd2f5fea 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -177,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(); @@ -185,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)); @@ -268,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); } } @@ -303,11 +317,15 @@ 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.set_device(_sampling_bar->get_selected_device()); _session.start_capture(_sampling_bar->get_record_length(), boost::bind(&MainWindow::session_error, this, QString("Capture failed"), _1)); diff --git a/pv/mainwindow.h b/pv/mainwindow.h index 47d3e66d..81290203 100644 --- a/pv/mainwindow.h +++ b/pv/mainwindow.h @@ -79,6 +79,8 @@ private slots: void on_actionAbout_triggered(); + void device_selected(); + void run_stop(); void capture_state_changed(int state); diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 131f057d..354082c7 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -59,11 +59,6 @@ SigSession::~SigSession() _session = NULL; } -struct sr_dev_inst* SigSession::get_device() const -{ - return _sdi; -} - void SigSession::set_device(struct sr_dev_inst *sdi) { _sdi = sdi; diff --git a/pv/sigsession.h b/pv/sigsession.h index fa2c7af4..19782934 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -62,11 +62,6 @@ public: ~SigSession(); - /** - * Gets device instance that will be used in the next capture session. - */ - struct sr_dev_inst* get_device() const; - /** * Sets device instance that will be used in the next capture session. */ diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index 401652cb..7e052f81 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -283,6 +283,7 @@ void SamplingBar::commit_sample_rate() void SamplingBar::on_device_selected() { update_sample_rate_selector(); + device_selected(); } void SamplingBar::on_sample_rate_changed() diff --git a/pv/toolbars/samplingbar.h b/pv/toolbars/samplingbar.h index a61a949e..d24534be 100644 --- a/pv/toolbars/samplingbar.h +++ b/pv/toolbars/samplingbar.h @@ -57,6 +57,8 @@ public: void set_sampling(bool sampling); signals: + void device_selected(); + void run_stop(); private: