From: Joel Holdsworth Date: Sat, 22 Nov 2014 10:15:56 +0000 (+0000) Subject: MainWindow: Include device/file name in window title X-Git-Tag: pulseview-0.3.0~437 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=20f81a58a9778fa7bc0dc4367f913437ed27c5e8;p=pulseview.git MainWindow: Include device/file name in window title This fixes bug #244 --- diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index a43b575a..142eb3f1 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -270,6 +270,8 @@ void MainWindow::setup_ui() // Setup session_ events connect(&session_, SIGNAL(capture_state_changed(int)), this, SLOT(capture_state_changed(int))); + connect(&session_, SIGNAL(device_selected()), this, + SLOT(device_selected())); } void MainWindow::save_ui_settings() @@ -559,4 +561,15 @@ void MainWindow::capture_state_changed(int state) sampling_bar_->set_capture_state((pv::SigSession::capture_state)state); } +void MainWindow::device_selected() +{ + // Set the title to include the device/file name + const shared_ptr device = session_.device(); + if (!device) + return; + + const string display_name = device_manager_.get_display_name(device); + setWindowTitle(tr("%1 - PulseView").arg(display_name.c_str())); +} + } // namespace pv diff --git a/pv/mainwindow.hpp b/pv/mainwindow.hpp index 9a000c2a..333eda2a 100644 --- a/pv/mainwindow.hpp +++ b/pv/mainwindow.hpp @@ -103,6 +103,7 @@ private Q_SLOTS: void run_stop(); void capture_state_changed(int state); + void device_selected(); private: /** diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index f3eb1946..fb457f6d 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -153,6 +153,8 @@ void SigSession::set_device(shared_ptr device) }); update_signals(device); } + + device_selected(); } void SigSession::set_file(const string &name) @@ -166,6 +168,7 @@ void SigSession::set_file(const string &name) }); device_manager_.update_display_name(device_); update_signals(device_); + device_selected(); } void SigSession::set_default_device() diff --git a/pv/sigsession.hpp b/pv/sigsession.hpp index 513177be..5f613bf9 100644 --- a/pv/sigsession.hpp +++ b/pv/sigsession.hpp @@ -174,6 +174,7 @@ private: Q_SIGNALS: void capture_state_changed(int state); + void device_selected(); void signals_changed();