From: Joel Holdsworth Date: Sat, 22 Nov 2014 16:01:47 +0000 (+0000) Subject: SamplingBar: Added reference to MainWindow for run_stop X-Git-Tag: pulseview-0.3.0~432 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4e7f5ba834f5bafd9fb5c7a6edb30748b2f93c59;p=pulseview.git SamplingBar: Added reference to MainWindow for run_stop --- diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 142eb3f1..97717b5a 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -95,6 +95,21 @@ MainWindow::MainWindow(DeviceManager &device_manager, } } +void MainWindow::run_stop() +{ + switch(session_.get_capture_state()) { + case SigSession::Stopped: + session_.start_capture([&](QString message) { + session_error("Capture failed", message); }); + break; + + case SigSession::AwaitingTrigger: + case SigSession::Running: + session_.stop_capture(); + break; + } +} + void MainWindow::setup_ui() { setObjectName(QString::fromUtf8("MainWindow")); @@ -255,13 +270,11 @@ void MainWindow::setup_ui() addToolBar(toolbar); // Setup the sampling bar - sampling_bar_ = new toolbars::SamplingBar(session_, this); + sampling_bar_ = new toolbars::SamplingBar(session_, *this); // Populate the device list and select the initially selected device update_device_list(); - connect(sampling_bar_, SIGNAL(run_stop()), this, - SLOT(run_stop())); addToolBar(sampling_bar_); // Set the title @@ -541,21 +554,6 @@ void MainWindow::add_decoder(srd_decoder *decoder) #endif } -void MainWindow::run_stop() -{ - switch(session_.get_capture_state()) { - case SigSession::Stopped: - session_.start_capture([&](QString message) { - session_error("Capture failed", message); }); - break; - - case SigSession::AwaitingTrigger: - case SigSession::Running: - session_.stop_capture(); - break; - } -} - void MainWindow::capture_state_changed(int state) { sampling_bar_->set_capture_state((pv::SigSession::capture_state)state); diff --git a/pv/mainwindow.hpp b/pv/mainwindow.hpp index 333eda2a..eee1d855 100644 --- a/pv/mainwindow.hpp +++ b/pv/mainwindow.hpp @@ -58,6 +58,8 @@ public: const char *open_file_name = NULL, QWidget *parent = 0); + void run_stop(); + private: void setup_ui(); @@ -100,8 +102,6 @@ private Q_SLOTS: void add_decoder(srd_decoder *decoder); - void run_stop(); - void capture_state_changed(int state); void device_selected(); diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index ddca7b59..2002dd23 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -30,6 +30,7 @@ #include "samplingbar.hpp" #include +#include #include #include #include @@ -55,9 +56,10 @@ const uint64_t SamplingBar::MinSampleCount = 100ULL; const uint64_t SamplingBar::MaxSampleCount = 1000000000000ULL; const uint64_t SamplingBar::DefaultSampleCount = 1000000; -SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : - QToolBar("Sampling Bar", parent), +SamplingBar::SamplingBar(SigSession &session, MainWindow &main_window) : + QToolBar("Sampling Bar", &main_window), session_(session), + main_window_(main_window), device_selector_(this), updating_device_selector_(false), configure_button_(this), @@ -449,7 +451,7 @@ void SamplingBar::on_run_stop() { commit_sample_count(); commit_sample_rate(); - run_stop(); + main_window_.run_stop(); } void SamplingBar::on_config_changed() diff --git a/pv/toolbars/samplingbar.hpp b/pv/toolbars/samplingbar.hpp index d027d60e..af274311 100644 --- a/pv/toolbars/samplingbar.hpp +++ b/pv/toolbars/samplingbar.hpp @@ -45,6 +45,7 @@ class QAction; namespace pv { +class MainWindow; class SigSession; namespace toolbars { @@ -59,7 +60,7 @@ private: static const uint64_t DefaultSampleCount; public: - SamplingBar(SigSession &session, QWidget *parent); + SamplingBar(SigSession &session, pv::MainWindow &main_window); void set_device_list( const std::list< std::pair, std::string> > &devices, @@ -93,6 +94,7 @@ protected: private: SigSession &session_; + MainWindow &main_window_; QComboBox device_selector_; bool updating_device_selector_;