2 * This file is part of the PulseView project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include <libsigrokdecode/libsigrokdecode.h>
31 #include <QApplication>
32 #include <QCloseEvent>
33 #include <QDockWidget>
34 #include <QHBoxLayout>
35 #include <QMessageBox>
40 #include "mainwindow.hpp"
42 #include "devicemanager.hpp"
43 #include "devices/hardwaredevice.hpp"
44 #include "dialogs/settings.hpp"
45 #include "globalsettings.hpp"
46 #include "toolbars/mainbar.hpp"
48 #include "view/view.hpp"
49 #include "views/trace/standardbar.hpp"
51 #include <libsigrokcxx/libsigrokcxx.hpp>
54 using std::dynamic_pointer_cast;
55 using std::make_shared;
57 using std::placeholders::_1;
58 using std::shared_ptr;
67 using toolbars::MainBar;
69 const QString MainWindow::WindowTitle = tr("PulseView");
71 MainWindow::MainWindow(DeviceManager &device_manager, QWidget *parent) :
73 device_manager_(device_manager),
74 session_selector_(this),
75 session_state_mapper_(this),
76 icon_red_(":/icons/status-red.svg"),
77 icon_green_(":/icons/status-green.svg"),
78 icon_grey_(":/icons/status-grey.svg")
80 qRegisterMetaType<util::Timestamp>("util::Timestamp");
81 qRegisterMetaType<uint64_t>("uint64_t");
83 GlobalSettings::register_change_handler(GlobalSettings::Key_View_ColouredBG,
84 bind(&MainWindow::on_settingViewColouredBg_changed, this, _1));
86 GlobalSettings::register_change_handler(GlobalSettings::Key_View_ShowSamplingPoints,
87 bind(&MainWindow::on_settingViewShowSamplingPoints_changed, this, _1));
89 GlobalSettings::register_change_handler(GlobalSettings::Key_View_ShowAnalogMinorGrid,
90 bind(&MainWindow::on_settingViewShowAnalogMinorGrid_changed, this, _1));
93 restore_ui_settings();
96 MainWindow::~MainWindow()
98 while (!sessions_.empty())
99 remove_session(sessions_.front());
102 shared_ptr<views::ViewBase> MainWindow::get_active_view() const
104 // If there's only one view, use it...
105 if (view_docks_.size() == 1)
106 return view_docks_.begin()->second;
108 // ...otherwise find the dock widget the widget with focus is contained in
109 QObject *w = QApplication::focusWidget();
110 QDockWidget *dock = nullptr;
113 dock = qobject_cast<QDockWidget*>(w);
119 // Get the view contained in the dock widget
120 for (auto entry : view_docks_)
121 if (entry.first == dock)
127 shared_ptr<views::ViewBase> MainWindow::add_view(const QString &title,
128 views::ViewType type, Session &session)
130 GlobalSettings settings;
131 shared_ptr<views::ViewBase> v;
133 QMainWindow *main_window = nullptr;
134 for (auto entry : session_windows_)
135 if (entry.first.get() == &session)
136 main_window = entry.second;
140 shared_ptr<MainBar> main_bar = session.main_bar();
142 QDockWidget* dock = new QDockWidget(title, main_window);
143 dock->setObjectName(title);
144 main_window->addDockWidget(Qt::TopDockWidgetArea, dock);
146 // Insert a QMainWindow into the dock widget to allow for a tool bar
147 QMainWindow *dock_main = new QMainWindow(dock);
148 dock_main->setWindowFlags(Qt::Widget); // Remove Qt::Window flag
150 if (type == views::ViewTypeTrace)
151 // This view will be the main view if there's no main bar yet
152 v = make_shared<views::TraceView::View>(session,
153 (main_bar ? false : true), dock_main);
158 view_docks_[dock] = v;
159 session.register_view(v);
161 dock_main->setCentralWidget(v.get());
162 dock->setWidget(dock_main);
164 dock->setContextMenuPolicy(Qt::PreventContextMenu);
165 dock->setFeatures(QDockWidget::DockWidgetMovable |
166 QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetClosable);
168 QAbstractButton *close_btn =
169 dock->findChildren<QAbstractButton*>
170 ("qt_dockwidget_closebutton").front();
172 connect(close_btn, SIGNAL(clicked(bool)),
173 this, SLOT(on_view_close_clicked()));
175 connect(&session, SIGNAL(trigger_event(util::Timestamp)),
176 qobject_cast<views::ViewBase*>(v.get()),
177 SLOT(trigger_event(util::Timestamp)));
179 if (type == views::ViewTypeTrace) {
180 views::TraceView::View *tv =
181 qobject_cast<views::TraceView::View*>(v.get());
183 tv->enable_coloured_bg(settings.value(GlobalSettings::Key_View_ColouredBG).toBool());
184 tv->enable_show_sampling_points(settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool());
185 tv->enable_show_analog_minor_grid(settings.value(GlobalSettings::Key_View_ShowAnalogMinorGrid).toBool());
188 /* Initial view, create the main bar */
189 main_bar = make_shared<MainBar>(session, this, tv);
190 dock_main->addToolBar(main_bar.get());
191 session.set_main_bar(main_bar);
193 connect(main_bar.get(), SIGNAL(new_view(Session*)),
194 this, SLOT(on_new_view(Session*)));
196 main_bar->action_view_show_cursors()->setChecked(tv->cursors_shown());
198 /* For the main view we need to prevent the dock widget from
199 * closing itself when its close button is clicked. This is
200 * so we can confirm with the user first. Regular views don't
202 close_btn->disconnect(SIGNAL(clicked()), dock, SLOT(close()));
204 /* Additional view, create a standard bar */
205 pv::views::trace::StandardBar *standard_bar =
206 new pv::views::trace::StandardBar(session, this, tv);
207 dock_main->addToolBar(standard_bar);
209 standard_bar->action_view_show_cursors()->setChecked(tv->cursors_shown());
216 void MainWindow::remove_view(shared_ptr<views::ViewBase> view)
218 for (shared_ptr<Session> session : sessions_) {
219 if (!session->has_view(view))
222 // Find the dock the view is contained in and remove it
223 for (auto entry : view_docks_)
224 if (entry.second == view) {
225 // Remove the view from the session
226 session->deregister_view(view);
228 // Remove the view from its parent; otherwise, Qt will
229 // call deleteLater() on it, which causes a double free
230 // since the shared_ptr in view_docks_ doesn't know
231 // that Qt keeps a pointer to the view around
232 view->setParent(nullptr);
234 // Delete the view's dock widget and all widgets inside it
235 entry.first->deleteLater();
237 // Remove the dock widget from the list and stop iterating
238 view_docks_.erase(entry.first);
244 shared_ptr<Session> MainWindow::add_session()
246 static int last_session_id = 1;
247 QString name = tr("Session %1").arg(last_session_id++);
249 shared_ptr<Session> session = make_shared<Session>(device_manager_, name);
251 connect(session.get(), SIGNAL(add_view(const QString&, views::ViewType, Session*)),
252 this, SLOT(on_add_view(const QString&, views::ViewType, Session*)));
253 connect(session.get(), SIGNAL(name_changed()),
254 this, SLOT(on_session_name_changed()));
255 session_state_mapper_.setMapping(session.get(), session.get());
256 connect(session.get(), SIGNAL(capture_state_changed(int)),
257 &session_state_mapper_, SLOT(map()));
259 sessions_.push_back(session);
261 QMainWindow *window = new QMainWindow();
262 window->setWindowFlags(Qt::Widget); // Remove Qt::Window flag
263 session_windows_[session] = window;
265 int index = session_selector_.addTab(window, name);
266 session_selector_.setCurrentIndex(index);
267 last_focused_session_ = session;
269 window->setDockNestingEnabled(true);
271 shared_ptr<views::ViewBase> main_view =
272 add_view(name, views::ViewTypeTrace, *session);
277 void MainWindow::remove_session(shared_ptr<Session> session)
279 // Determine the height of the button before it collapses
280 int h = new_session_button_->height();
282 // Stop capture while the session still exists so that the UI can be
283 // updated in case we're currently running. If so, this will schedule a
284 // call to our on_capture_state_changed() slot for the next run of the
285 // event loop. We need to have this executed immediately or else it will
286 // be dismissed since the session object will be deleted by the time we
287 // leave this method and the event loop gets a chance to run again.
288 session->stop_capture();
289 QApplication::processEvents();
291 for (shared_ptr<views::ViewBase> view : session->views())
294 QMainWindow *window = session_windows_.at(session);
295 session_selector_.removeTab(session_selector_.indexOf(window));
297 session_windows_.erase(session);
299 if (last_focused_session_ == session)
300 last_focused_session_.reset();
302 // Remove the session from our list of sessions (which also destroys it)
303 sessions_.remove_if([&](shared_ptr<Session> s) {
304 return s == session; });
306 if (sessions_.empty()) {
307 // When there are no more tabs, the height of the QTabWidget
308 // drops to zero. We must prevent this to keep the static
310 for (QWidget *w : static_tab_widget_->findChildren<QWidget*>())
311 w->setMinimumHeight(h);
313 int margin = static_tab_widget_->layout()->contentsMargins().bottom();
314 static_tab_widget_->setMinimumHeight(h + 2 * margin);
315 session_selector_.setMinimumHeight(h + 2 * margin);
317 // Update the window title if there is no view left to
318 // generate focus change events
319 setWindowTitle(WindowTitle);
323 void MainWindow::add_session_with_file(string open_file_name,
324 string open_file_format)
326 shared_ptr<Session> session = add_session();
327 session->load_init_file(open_file_name, open_file_format);
330 void MainWindow::add_default_session()
332 // Only add the default session if there would be no session otherwise
333 if (sessions_.size() > 0)
336 shared_ptr<Session> session = add_session();
338 map<string, string> dev_info;
339 shared_ptr<devices::HardwareDevice> other_device, demo_device;
341 // Use any available device that's not demo
342 for (shared_ptr<devices::HardwareDevice> dev : device_manager_.devices()) {
343 if (dev->hardware_device()->driver()->name() == "demo") {
350 // ...and if there isn't any, just use demo then
351 session->select_device(other_device ? other_device : demo_device);
354 void MainWindow::save_sessions()
359 for (shared_ptr<Session> session : sessions_) {
360 // Ignore sessions using the demo device or no device at all
361 if (session->device()) {
362 shared_ptr<devices::HardwareDevice> device =
363 dynamic_pointer_cast< devices::HardwareDevice >
367 device->hardware_device()->driver()->name() == "demo")
370 settings.beginGroup("Session" + QString::number(id++));
371 settings.remove(""); // Remove all keys in this group
372 session->save_settings(settings);
377 settings.setValue("sessions", id);
380 void MainWindow::restore_sessions()
383 int i, session_count;
385 session_count = settings.value("sessions", 0).toInt();
387 for (i = 0; i < session_count; i++) {
388 settings.beginGroup("Session" + QString::number(i));
389 shared_ptr<Session> session = add_session();
390 session->restore_settings(settings);
395 void MainWindow::setup_ui()
397 setObjectName(QString::fromUtf8("MainWindow"));
399 setCentralWidget(&session_selector_);
401 // Set the window icon
403 icon.addFile(QString(":/icons/sigrok-logo-notext.png"));
406 view_sticky_scrolling_shortcut_ = new QShortcut(QKeySequence(Qt::Key_S), this, SLOT(on_view_sticky_scrolling_shortcut()));
407 view_sticky_scrolling_shortcut_->setAutoRepeat(false);
409 view_show_sampling_points_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Period), this, SLOT(on_view_show_sampling_points_shortcut()));
410 view_show_sampling_points_shortcut_->setAutoRepeat(false);
412 view_show_analog_minor_grid_shortcut_ = new QShortcut(QKeySequence(Qt::Key_G), this, SLOT(on_view_show_analog_minor_grid_shortcut()));
413 view_show_analog_minor_grid_shortcut_->setAutoRepeat(false);
415 view_coloured_bg_shortcut_ = new QShortcut(QKeySequence(Qt::Key_B), this, SLOT(on_view_coloured_bg_shortcut()));
416 view_coloured_bg_shortcut_->setAutoRepeat(false);
418 // Set up the tab area
419 new_session_button_ = new QToolButton();
420 new_session_button_->setIcon(QIcon::fromTheme("document-new",
421 QIcon(":/icons/document-new.png")));
422 new_session_button_->setToolTip(tr("Create New Session"));
423 new_session_button_->setAutoRaise(true);
425 run_stop_button_ = new QToolButton();
426 run_stop_button_->setAutoRaise(true);
427 run_stop_button_->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
428 run_stop_button_->setToolTip(tr("Start/Stop Acquisition"));
430 run_stop_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Space), run_stop_button_, SLOT(click()));
431 run_stop_shortcut_->setAutoRepeat(false);
433 settings_button_ = new QToolButton();
434 settings_button_->setIcon(QIcon::fromTheme("preferences-system",
435 QIcon(":/icons/preferences-system.png")));
436 settings_button_->setToolTip(tr("Settings"));
437 settings_button_->setAutoRaise(true);
439 QFrame *separator1 = new QFrame();
440 separator1->setFrameStyle(QFrame::VLine | QFrame::Raised);
441 QFrame *separator2 = new QFrame();
442 separator2->setFrameStyle(QFrame::VLine | QFrame::Raised);
444 QHBoxLayout* layout = new QHBoxLayout();
445 layout->setContentsMargins(2, 2, 2, 2);
446 layout->addWidget(new_session_button_);
447 layout->addWidget(separator1);
448 layout->addWidget(run_stop_button_);
449 layout->addWidget(separator2);
450 layout->addWidget(settings_button_);
452 static_tab_widget_ = new QWidget();
453 static_tab_widget_->setLayout(layout);
455 session_selector_.setCornerWidget(static_tab_widget_, Qt::TopLeftCorner);
456 session_selector_.setTabsClosable(true);
458 close_application_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this, SLOT(close()));
459 close_application_shortcut_->setAutoRepeat(false);
461 close_current_tab_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this, SLOT(on_close_current_tab()));
463 connect(new_session_button_, SIGNAL(clicked(bool)),
464 this, SLOT(on_new_session_clicked()));
465 connect(run_stop_button_, SIGNAL(clicked(bool)),
466 this, SLOT(on_run_stop_clicked()));
467 connect(&session_state_mapper_, SIGNAL(mapped(QObject*)),
468 this, SLOT(on_capture_state_changed(QObject*)));
469 connect(settings_button_, SIGNAL(clicked(bool)),
470 this, SLOT(on_settings_clicked()));
472 connect(&session_selector_, SIGNAL(tabCloseRequested(int)),
473 this, SLOT(on_tab_close_requested(int)));
474 connect(&session_selector_, SIGNAL(currentChanged(int)),
475 this, SLOT(on_tab_changed(int)));
478 connect(static_cast<QApplication *>(QCoreApplication::instance()),
479 SIGNAL(focusChanged(QWidget*, QWidget*)),
480 this, SLOT(on_focus_changed()));
483 void MainWindow::save_ui_settings()
487 settings.beginGroup("MainWindow");
488 settings.setValue("state", saveState());
489 settings.setValue("geometry", saveGeometry());
493 void MainWindow::restore_ui_settings()
497 settings.beginGroup("MainWindow");
499 if (settings.contains("geometry")) {
500 restoreGeometry(settings.value("geometry").toByteArray());
501 restoreState(settings.value("state").toByteArray());
508 shared_ptr<Session> MainWindow::get_tab_session(int index) const
510 // Find the session that belongs to the tab's main window
511 for (auto entry : session_windows_)
512 if (entry.second == session_selector_.widget(index))
518 void MainWindow::closeEvent(QCloseEvent *event)
520 bool data_saved = true;
522 for (auto entry : session_windows_)
523 if (!entry.first->data_saved())
526 if (!data_saved && (QMessageBox::question(this, tr("Confirmation"),
527 tr("There is unsaved data. Close anyway?"),
528 QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)) {
537 QMenu* MainWindow::createPopupMenu()
542 bool MainWindow::restoreState(const QByteArray &state, int version)
547 // Do nothing. We don't want Qt to handle this, or else it
548 // will try to restore all the dock widgets and create havoc.
553 void MainWindow::session_error(const QString text, const QString info_text)
555 QMetaObject::invokeMethod(this, "show_session_error",
556 Qt::QueuedConnection, Q_ARG(QString, text),
557 Q_ARG(QString, info_text));
560 void MainWindow::show_session_error(const QString text, const QString info_text)
562 QMessageBox msg(this);
564 msg.setInformativeText(info_text);
565 msg.setStandardButtons(QMessageBox::Ok);
566 msg.setIcon(QMessageBox::Warning);
570 void MainWindow::on_add_view(const QString &title, views::ViewType type,
573 // We get a pointer and need a reference
574 for (shared_ptr<Session> s : sessions_)
575 if (s.get() == session)
576 add_view(title, type, *s);
579 void MainWindow::on_focus_changed()
581 shared_ptr<views::ViewBase> view = get_active_view();
584 for (shared_ptr<Session> session : sessions_) {
585 if (session->has_view(view)) {
586 if (session != last_focused_session_) {
587 // Activate correct tab if necessary
588 shared_ptr<Session> tab_session = get_tab_session(
589 session_selector_.currentIndex());
590 if (tab_session != session)
591 session_selector_.setCurrentWidget(
592 session_windows_.at(session));
594 on_focused_session_changed(session);
602 if (sessions_.empty())
603 setWindowTitle(WindowTitle);
606 void MainWindow::on_focused_session_changed(shared_ptr<Session> session)
608 last_focused_session_ = session;
610 setWindowTitle(session->name() + " - " + WindowTitle);
612 // Update the state of the run/stop button, too
613 on_capture_state_changed(session.get());
616 void MainWindow::on_new_session_clicked()
621 void MainWindow::on_run_stop_clicked()
623 shared_ptr<Session> session = last_focused_session_;
628 switch (session->get_capture_state()) {
629 case Session::Stopped:
630 session->start_capture([&](QString message) {
631 session_error("Capture failed", message); });
633 case Session::AwaitingTrigger:
634 case Session::Running:
635 session->stop_capture();
640 void MainWindow::on_settings_clicked()
642 dialogs::Settings dlg(device_manager_);
646 void MainWindow::on_session_name_changed()
648 // Update the corresponding dock widget's name(s)
649 Session *session = qobject_cast<Session*>(QObject::sender());
652 for (shared_ptr<views::ViewBase> view : session->views()) {
653 // Get the dock that contains the view
654 for (auto entry : view_docks_)
655 if (entry.second == view) {
656 entry.first->setObjectName(session->name());
657 entry.first->setWindowTitle(session->name());
661 // Update the tab widget by finding the main window and the tab from that
662 for (auto entry : session_windows_)
663 if (entry.first.get() == session) {
664 QMainWindow *window = entry.second;
665 const int index = session_selector_.indexOf(window);
666 session_selector_.setTabText(index, session->name());
669 // Refresh window title if the affected session has focus
670 if (session == last_focused_session_.get())
671 setWindowTitle(session->name() + " - " + WindowTitle);
674 void MainWindow::on_capture_state_changed(QObject *obj)
676 Session *caller = qobject_cast<Session*>(obj);
678 // Ignore if caller is not the currently focused session
679 // unless there is only one session
680 if ((sessions_.size() > 1) && (caller != last_focused_session_.get()))
683 int state = caller->get_capture_state();
685 const QIcon *icons[] = {&icon_grey_, &icon_red_, &icon_green_};
686 run_stop_button_->setIcon(*icons[state]);
687 run_stop_button_->setText((state == pv::Session::Stopped) ?
688 tr("Run") : tr("Stop"));
691 void MainWindow::on_new_view(Session *session)
693 // We get a pointer and need a reference
694 for (shared_ptr<Session> s : sessions_)
695 if (s.get() == session)
696 add_view(session->name(), views::ViewTypeTrace, *s);
699 void MainWindow::on_view_close_clicked()
701 // Find the dock widget that contains the close button that was clicked
702 QObject *w = QObject::sender();
703 QDockWidget *dock = nullptr;
706 dock = qobject_cast<QDockWidget*>(w);
712 // Get the view contained in the dock widget
713 shared_ptr<views::ViewBase> view;
715 for (auto entry : view_docks_)
716 if (entry.first == dock)
719 // Deregister the view
720 for (shared_ptr<Session> session : sessions_) {
721 if (!session->has_view(view))
724 // Also destroy the entire session if its main view is closing...
725 if (view == session->main_view()) {
726 // ...but only if data is saved or the user confirms closing
727 if (session->data_saved() || (QMessageBox::question(this, tr("Confirmation"),
728 tr("This session contains unsaved data. Close it anyway?"),
729 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes))
730 remove_session(session);
733 // All other views can be closed at any time as no data will be lost
738 void MainWindow::on_tab_changed(int index)
740 shared_ptr<Session> session = get_tab_session(index);
743 on_focused_session_changed(session);
746 void MainWindow::on_tab_close_requested(int index)
748 shared_ptr<Session> session = get_tab_session(index);
753 if (session->data_saved() || (QMessageBox::question(this, tr("Confirmation"),
754 tr("This session contains unsaved data. Close it anyway?"),
755 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes))
756 remove_session(session);
759 void MainWindow::on_view_coloured_bg_shortcut()
761 GlobalSettings settings;
763 bool state = settings.value(GlobalSettings::Key_View_ColouredBG).toBool();
764 settings.setValue(GlobalSettings::Key_View_ColouredBG, !state);
767 void MainWindow::on_view_sticky_scrolling_shortcut()
769 GlobalSettings settings;
771 bool state = settings.value(GlobalSettings::Key_View_StickyScrolling).toBool();
772 settings.setValue(GlobalSettings::Key_View_StickyScrolling, !state);
775 void MainWindow::on_view_show_sampling_points_shortcut()
777 GlobalSettings settings;
779 bool state = settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool();
780 settings.setValue(GlobalSettings::Key_View_ShowSamplingPoints, !state);
783 void MainWindow::on_view_show_analog_minor_grid_shortcut()
785 GlobalSettings settings;
787 bool state = settings.value(GlobalSettings::Key_View_ShowAnalogMinorGrid).toBool();
788 settings.setValue(GlobalSettings::Key_View_ShowAnalogMinorGrid, !state);
791 void MainWindow::on_settingViewColouredBg_changed(const QVariant new_value)
793 bool state = new_value.toBool();
795 for (auto entry : view_docks_) {
796 shared_ptr<views::ViewBase> viewbase = entry.second;
798 // Only trace views have this setting
799 views::TraceView::View* view =
800 qobject_cast<views::TraceView::View*>(viewbase.get());
802 view->enable_coloured_bg(state);
806 void MainWindow::on_settingViewShowSamplingPoints_changed(const QVariant new_value)
808 bool state = new_value.toBool();
810 for (auto entry : view_docks_) {
811 shared_ptr<views::ViewBase> viewbase = entry.second;
813 // Only trace views have this setting
814 views::TraceView::View* view =
815 qobject_cast<views::TraceView::View*>(viewbase.get());
817 view->enable_show_sampling_points(state);
821 void MainWindow::on_settingViewShowAnalogMinorGrid_changed(const QVariant new_value)
823 bool state = new_value.toBool();
825 for (auto entry : view_docks_) {
826 shared_ptr<views::ViewBase> viewbase = entry.second;
828 // Only trace views have this setting
829 views::TraceView::View* view =
830 qobject_cast<views::TraceView::View*>(viewbase.get());
832 view->enable_show_analog_minor_grid(state);
836 void MainWindow::on_close_current_tab()
838 int tab = session_selector_.currentIndex();
840 on_tab_close_requested(tab);