From: Soeren Apel Date: Tue, 4 Oct 2016 17:52:29 +0000 (+0200) Subject: MainWindow: Allow tabs to be closed X-Git-Tag: pulseview-0.4.0~236 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=4a4e20f5e5e3601b99c763dafe1cbfb8c7d6a387 MainWindow: Allow tabs to be closed --- diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 775f9dec..31e9f2f9 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -307,6 +307,11 @@ void MainWindow::setup_ui() action_about_->setObjectName(QString::fromUtf8("actionAbout")); action_about_->setText(tr("&About...")); + session_selector_.setTabsClosable(true); + + connect(&session_selector_, SIGNAL(tabCloseRequested(int)), + this, SLOT(on_tab_close_requested(int))); + setDockNestingEnabled(true); connect(static_cast(QCoreApplication::instance()), @@ -486,6 +491,18 @@ void MainWindow::on_view_close_clicked() } } +void MainWindow::on_tab_close_requested(int index) +{ + // TODO Ask user if this is intended in case data is unsaved + + // Find the session that belongs to this main window and remove it + for (auto entry : session_windows_) + if (entry.second == session_selector_.widget(index)) { + remove_session(entry.first); + break; + } +} + void MainWindow::on_actionViewStickyScrolling_triggered() { shared_ptr viewbase = get_active_view(); diff --git a/pv/mainwindow.hpp b/pv/mainwindow.hpp index 2448a357..37954fe8 100644 --- a/pv/mainwindow.hpp +++ b/pv/mainwindow.hpp @@ -107,6 +107,8 @@ private Q_SLOTS: void on_new_view(Session *session); void on_view_close_clicked(); + void on_tab_close_requested(int index); + void on_actionViewStickyScrolling_triggered(); void on_actionViewColouredBg_triggered();