]> sigrok.org Git - pulseview.git/commitdiff
SamplingBar: Added reference to MainWindow for run_stop
authorJoel Holdsworth <redacted>
Sat, 22 Nov 2014 16:01:47 +0000 (16:01 +0000)
committerJoel Holdsworth <redacted>
Sat, 22 Nov 2014 16:01:47 +0000 (16:01 +0000)
pv/mainwindow.cpp
pv/mainwindow.hpp
pv/toolbars/samplingbar.cpp
pv/toolbars/samplingbar.hpp

index 142eb3f1c08960a8db7be4cbfe964574c5aa8d1c..97717b5abe3493fd16ec2f285cd11955c5ce18a3 100644 (file)
@@ -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);
index 333eda2a0a75dfbc02f9c534444d389d42498efa..eee1d855d072c561e123c935aca1301bb0168c56 100644 (file)
@@ -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();
 
index ddca7b5961a8145155c2a64ab0f9f6df0e1fea33..2002dd237b4f88ce3dd5edb012ae6a1ee81b6c01 100644 (file)
@@ -30,6 +30,7 @@
 #include "samplingbar.hpp"
 
 #include <pv/devicemanager.hpp>
+#include <pv/mainwindow.hpp>
 #include <pv/popups/deviceoptions.hpp>
 #include <pv/popups/channels.hpp>
 #include <pv/util.hpp>
@@ -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()
index d027d60e6b3b303802e3c87164d6dba3622e1319..af2743118ad7441d1140869b5989632bb46e8762 100644 (file)
@@ -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::shared_ptr<sigrok::Device>, std::string> > &devices,
@@ -93,6 +94,7 @@ protected:
 
 private:
        SigSession &session_;
+       MainWindow &main_window_;
 
        QComboBox device_selector_;
        bool updating_device_selector_;