MainWindow: Enable dock nesting
[pulseview.git] / pv / mainwindow.cpp
index bc20898249afd70ee4f90972304289a2db7ab0ba..a99ba35298c39080930e764adcb699e0feb6d707 100644 (file)
@@ -218,6 +218,9 @@ shared_ptr<Session> MainWindow::add_session()
 
        shared_ptr<Session> session = make_shared<Session>(device_manager_, name);
 
+       connect(session.get(), SIGNAL(add_view(const QString&, view::ViewType, Session*)),
+               this, SLOT(on_add_view(const QString&, view::ViewType, Session*)));
+
        sessions_.push_back(session);
 
        shared_ptr<view::View> main_view =
@@ -252,6 +255,8 @@ void MainWindow::setup_ui()
        action_about_->setObjectName(QString::fromUtf8("actionAbout"));
        action_about_->setText(tr("&About..."));
 
+       setDockNestingEnabled(true);
+
        // Set the title
        setWindowTitle(tr("PulseView"));
 }
@@ -273,11 +278,13 @@ void MainWindow::save_ui_settings()
                                dynamic_pointer_cast< devices::HardwareDevice >
                                (session->device());
 
-                       if (device->hardware_device()->driver()->name() == "demo")
+                       if (device &&
+                               device->hardware_device()->driver()->name() == "demo")
                                continue;
                }
 
                settings.beginGroup("Session" + QString::number(id++));
+               settings.remove("");  // Remove all keys in this group
                session->save_settings(settings);
                settings.endGroup();
        }
@@ -332,6 +339,15 @@ bool MainWindow::restoreState(const QByteArray &state, int version)
        return false;
 }
 
+void MainWindow::on_add_view(const QString &title, view::ViewType type,
+       Session *session)
+{
+       // We get a pointer and need a reference
+       for (std::shared_ptr<Session> s : sessions_)
+               if (s.get() == session)
+                       add_view(title, type, *s);
+}
+
 void MainWindow::on_actionViewStickyScrolling_triggered()
 {
        shared_ptr<pv::view::View> view = get_active_view();