#include "mainwindow.hpp"
+#include "application.hpp"
#include "devicemanager.hpp"
#include "devices/hardwaredevice.hpp"
#include "dialogs/settings.hpp"
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")
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);
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()));
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;
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()
setWindowTitle(session->name() + " - " + WindowTitle);
}
-void MainWindow::on_capture_state_changed(QObject *obj)
+void MainWindow::on_session_device_changed()
{
- Session *caller = qobject_cast<Session*>(obj);
+ Session *session = qobject_cast<Session*>(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<Session*>(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)