From: Soeren Apel Date: Sat, 11 Jan 2020 21:24:23 +0000 (+0100) Subject: MainWindow: Remove QSignalMapper usage X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f1f3fa718b6ad2640dfb2fef1d7212b2ed450b71;p=pulseview.git MainWindow: Remove QSignalMapper usage --- diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index c5387beb..d7f5c31a 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -71,7 +71,6 @@ MainWindow::MainWindow(DeviceManager &device_manager, QWidget *parent) : QMainWindow(parent), device_manager_(device_manager), session_selector_(this), - session_state_mapper_(this), icon_red_(":/icons/status-red.svg"), icon_green_(":/icons/status-green.svg"), icon_grey_(":/icons/status-grey.svg") @@ -334,9 +333,8 @@ shared_ptr MainWindow::add_session() this, SLOT(on_session_name_changed())); connect(session.get(), SIGNAL(device_changed()), this, SLOT(on_session_device_changed())); - session_state_mapper_.setMapping(session.get(), session.get()); connect(session.get(), SIGNAL(capture_state_changed(int)), - &session_state_mapper_, SLOT(map())); + this, SLOT(on_session_capture_state_changed(int))); sessions_.push_back(session); @@ -552,8 +550,6 @@ void MainWindow::setup_ui() this, SLOT(on_new_session_clicked())); connect(run_stop_button_, SIGNAL(clicked(bool)), this, SLOT(on_run_stop_clicked())); - connect(&session_state_mapper_, SIGNAL(mapped(QObject*)), - this, SLOT(on_capture_state_changed(QObject*))); connect(settings_button_, SIGNAL(clicked(bool)), this, SLOT(on_settings_clicked())); @@ -693,7 +689,7 @@ void MainWindow::on_focused_session_changed(shared_ptr session) setWindowTitle(session->name() + " - " + WindowTitle); // Update the state of the run/stop button, too - on_capture_state_changed(session.get()); + update_acq_button(session.get()); } void MainWindow::on_new_session_clicked() @@ -767,16 +763,19 @@ void MainWindow::on_session_device_changed() update_acq_button(session); } -void MainWindow::on_capture_state_changed(QObject *obj) +void MainWindow::on_session_capture_state_changed(int state) { - Session *caller = qobject_cast(obj); + (void)state; + + Session *session = qobject_cast(QObject::sender()); + assert(session); // Ignore if caller is not the currently focused session // unless there is only one session - if ((sessions_.size() > 1) && (caller != last_focused_session_.get())) + if ((sessions_.size() > 1) && (session != last_focused_session_.get())) return; - update_acq_button(caller); + update_acq_button(session); } void MainWindow::on_new_view(Session *session, int view_type) diff --git a/pv/mainwindow.hpp b/pv/mainwindow.hpp index bf23acfb..522ab1c0 100644 --- a/pv/mainwindow.hpp +++ b/pv/mainwindow.hpp @@ -26,7 +26,6 @@ #include #include -#include #include #include @@ -125,7 +124,7 @@ private Q_SLOTS: void on_session_name_changed(); void on_session_device_changed(); - void on_capture_state_changed(QObject *obj); + void on_session_capture_state_changed(int state); void on_new_view(Session *session, int view_type); void on_view_close_clicked(); @@ -157,7 +156,6 @@ private: QWidget *static_tab_widget_; QToolButton *new_session_button_, *run_stop_button_, *settings_button_; QTabWidget session_selector_; - QSignalMapper session_state_mapper_; QIcon icon_red_; QIcon icon_green_;