X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=1fb46e13ec483c9fc7da5fb83e544d669baf9046;hb=0466001be51e779b23aaebec1cc9361305c07be9;hp=799f10d4b7c3bb7d3f8ccabd70e319df988ec990;hpb=feda6c6bbde575242cf01c769c0ecd3e89f9f7a0;p=pulseview.git diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 799f10d4..1fb46e13 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -40,6 +40,7 @@ #include "mainwindow.hpp" +#include "application.hpp" #include "devicemanager.hpp" #include "devices/hardwaredevice.hpp" #include "dialogs/settings.hpp" @@ -71,7 +72,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") @@ -332,9 +332,10 @@ shared_ptr MainWindow::add_session() this, SLOT(on_add_view(views::ViewType, Session*))); connect(session.get(), SIGNAL(name_changed()), this, SLOT(on_session_name_changed())); - session_state_mapper_.setMapping(session.get(), session.get()); + connect(session.get(), SIGNAL(device_changed()), + this, SLOT(on_session_device_changed())); 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); @@ -550,8 +551,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())); @@ -566,6 +565,19 @@ void MainWindow::setup_ui() this, SLOT(on_focus_changed())); } +void MainWindow::update_acq_button(Session *session) +{ + int state = session->get_capture_state(); + + const QString run_caption = + session->using_file_device() ? tr("Reload") : tr("Run"); + + const QIcon *icons[] = {&icon_grey_, &icon_red_, &icon_green_}; + run_stop_button_->setIcon(*icons[state]); + run_stop_button_->setText((state == pv::Session::Stopped) ? + run_caption : tr("Stop")); +} + void MainWindow::save_ui_settings() { QSettings settings; @@ -678,7 +690,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() @@ -739,21 +751,32 @@ void MainWindow::on_session_name_changed() setWindowTitle(session->name() + " - " + WindowTitle); } -void MainWindow::on_capture_state_changed(QObject *obj) +void MainWindow::on_session_device_changed() { - Session *caller = qobject_cast(obj); + 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; - int state = caller->get_capture_state(); + update_acq_button(session); +} - const QIcon *icons[] = {&icon_grey_, &icon_red_, &icon_green_}; - run_stop_button_->setIcon(*icons[state]); - run_stop_button_->setText((state == pv::Session::Stopped) ? - tr("Run") : tr("Stop")); +void MainWindow::on_session_capture_state_changed(int state) +{ + (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) && (session != last_focused_session_.get())) + return; + + update_acq_button(session); } void MainWindow::on_new_view(Session *session, int view_type)