]> sigrok.org Git - pulseview.git/commitdiff
MainWindow: Allow tabs to be closed
authorSoeren Apel <redacted>
Tue, 4 Oct 2016 17:52:29 +0000 (19:52 +0200)
committerSoeren Apel <redacted>
Sun, 4 Dec 2016 13:37:37 +0000 (14:37 +0100)
pv/mainwindow.cpp
pv/mainwindow.hpp

index 775f9dec90a53d628271f5580a829b60b2027035..31e9f2f9764e8b4603b0264401e065153b597278 100644 (file)
@@ -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<QApplication *>(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<views::ViewBase> viewbase = get_active_view();
index 2448a3570d45b9f10187a480d6ef7a85dcf5a83d..37954fe85ac8e0006c78916737fe8aadbe47ac6d 100644 (file)
@@ -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();