]> sigrok.org Git - pulseview.git/commitdiff
Keep Run/Stop button state updated
authorJoel Holdsworth <redacted>
Mon, 3 Dec 2012 23:25:59 +0000 (23:25 +0000)
committerJoel Holdsworth <redacted>
Tue, 11 Dec 2012 20:05:19 +0000 (20:05 +0000)
pv/mainwindow.cpp
pv/mainwindow.h
pv/samplingbar.cpp
pv/samplingbar.h
pv/sigsession.cpp
pv/sigsession.h

index f1493667b766787100f9e8e07a3b9f1107fcb613..3f338a12a09e1124cec927350878656c15828a8f 100644 (file)
@@ -150,6 +150,11 @@ void MainWindow::setup_ui()
        _menu_file->setTitle(QApplication::translate("MainWindow", "&File", 0, QApplication::UnicodeUTF8));
        _menu_view->setTitle(QApplication::translate("MainWindow", "&View", 0, QApplication::UnicodeUTF8));
        _menu_help->setTitle(QApplication::translate("MainWindow", "&Help", 0, QApplication::UnicodeUTF8));
+
+       // Setup _session events
+       connect(&_session, SIGNAL(capture_state_changed(int)), this,
+               SLOT(capture_state_changed(int)));
+
 }
 
 void MainWindow::on_actionOpen_triggered()
@@ -198,4 +203,9 @@ void MainWindow::run_stop()
        }
 }
 
+void MainWindow::capture_state_changed(int state)
+{
+       _sampling_bar->set_sampling(state != SigSession::Stopped);
+}
+
 } // namespace pv
index df7d86f5f3151b0a399a0c45bdf7eba1a7965799..07a54a0f38929f161529c61cf637dc145dca562f 100644 (file)
@@ -87,6 +87,8 @@ private slots:
        void on_actionAbout_triggered();
 
        void run_stop();
+
+       void capture_state_changed(int state);
 };
 
 } // namespace pv
index 31047439c6354886c58c060412032a6034aa0d08..02e4e71d00693cb2070133608f918abde72d5767 100644 (file)
@@ -68,7 +68,7 @@ SamplingBar::SamplingBar(QWidget *parent) :
                g_free(text);
        }
 
-       _run_stop_button.setText("Run");
+       set_sampling(false);
 
        addWidget(&_device_selector);
        addWidget(&_record_length_selector);
@@ -118,6 +118,11 @@ uint64_t SamplingBar::get_sample_rate() const
        return 0;
 }
 
+void SamplingBar::set_sampling(bool sampling)
+{
+       _run_stop_button.setText(sampling ? "Stop" : "Run");
+}
+
 void SamplingBar::update_device_selector()
 {
        GSList *devices = NULL;
index e6204dfa5a67c65d13e398728eae2c414b24e062..8c6511a8f33d639b008ee1a291d09f9c5dc80505 100644 (file)
@@ -46,6 +46,8 @@ public:
        uint64_t get_record_length() const;
        uint64_t get_sample_rate() const;
 
+       void set_sampling(bool sampling);
+
 signals:
        void run_stop();
 
index 580b6796c680f8a76c679dfad20d7ea11640aaa4..e4a58a6190af8bc023c31297751cfd7ccf430596 100644 (file)
@@ -94,8 +94,6 @@ void SigSession::stop_capture()
        if(_sampling_thread.get())
                _sampling_thread->join();
        _sampling_thread.reset();
-
-       _capture_state = Stopped;
 }
 
 vector< shared_ptr<view::Signal> > SigSession::get_signals()
@@ -109,6 +107,13 @@ boost::shared_ptr<LogicData> SigSession::get_data()
        return _logic_data;
 }
 
+void SigSession::set_capture_state(capture_state state)
+{
+       lock_guard<mutex> lock(_state_mutex);
+       _capture_state = state;
+       capture_state_changed(state);
+}
+
 void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
        uint64_t record_length, uint64_t sample_rate)
 {
@@ -140,13 +145,12 @@ void SigSession::sample_thread_proc(struct sr_dev_inst *sdi,
                return;
        }
 
-       {
-               lock_guard<mutex> lock(_state_mutex);
-               _capture_state = Running;
-       }
+       set_capture_state(Running);
 
        sr_session_run();
        sr_session_destroy();
+
+       set_capture_state(Stopped);
 }
 
 void SigSession::data_feed_in(const struct sr_dev_inst *sdi,
index 8da89d09b3fd6d0cde07fea0fde589d90e779902..b4f07db4394397579e8d429bf9d9ca3d763e88b5 100644 (file)
@@ -72,6 +72,9 @@ public:
 
        boost::shared_ptr<LogicData> get_data();
 
+private:
+       void set_capture_state(capture_state state);
+
 private:
        void sample_thread_proc(struct sr_dev_inst *sdi,
                uint64_t record_length, uint64_t sample_rate);
@@ -96,6 +99,8 @@ private:
        std::auto_ptr<boost::thread> _sampling_thread;
 
 signals:
+       void capture_state_changed(int state);
+
        void signals_changed();
 
        void data_updated();