diff --git a/src/ViewContainer.h b/src/ViewContainer.h --- a/src/ViewContainer.h +++ b/src/ViewContainer.h @@ -159,9 +159,8 @@ * to append it. This index should be passed to addView() when the new view * has been created. * @param id The identifier of the view. - * @param sourceContainer Initial move event Tabbed view container. */ - void moveViewRequest(int index, int id, TabbedViewContainer *sourceContainer); + void moveViewRequest(int index, int sessionControllerId); /** Emitted when the active view changes */ void activeViewChanged(QWidget *view); diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp --- a/src/ViewContainer.cpp +++ b/src/ViewContainer.cpp @@ -161,7 +161,7 @@ const auto currentPos = QCursor::pos(); for(const auto dropWidget : widgets) { if (dropWidget->rect().contains(dropWidget->mapFromGlobal(currentPos))) { - emit dropWidget->moveViewRequest(-1, id, this); + emit dropWidget->moveViewRequest(-1, id); removeView(widget(index)); } } diff --git a/src/ViewManager.h b/src/ViewManager.h --- a/src/ViewManager.h +++ b/src/ViewManager.h @@ -375,8 +375,7 @@ // called when a ViewContainer requests a view be // moved - void containerMoveViewRequest(int index, int id, - TabbedViewContainer *sourceTabbedContainer); + void containerMoveViewRequest(int index, int sessionControllerId); void detachView(TabbedViewContainer *container, QWidget *view); diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -465,20 +465,17 @@ { TabbedViewContainer *container = createContainer(); - // iterate over each session which has a view in the current active - // container and create a new view for that session in a new container - for(int i = 0, end = _viewSplitter->activeContainer()->count(); i < end; i++) { - auto view = _viewSplitter->activeContainer()->widget(i); - Session *session = _sessionMap[qobject_cast(view)]; - TerminalDisplay *display = createTerminalDisplay(session); - const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); - applyProfileToView(display, profile); - ViewProperties *properties = createController(session, display); - - _sessionMap[display] = session; - - container->addView(display, properties); - session->addView(display); + if (_viewSplitter->activeContainer()->count()) { + // get the currently applied profile and use it to create the new tab. + auto *activeContainer= _viewSplitter->activeContainer(); + auto *currentDisplay = qobject_cast(activeContainer->currentWidget()); + auto profile = SessionManager::instance()->sessionProfile(_sessionMap[currentDisplay]); + + // Create a new session with the selected profile. + auto *session = SessionManager::instance()->createSession(profile); + session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(managerId())); + + createView(session, container, 0); } _viewSplitter->addContainer(container, orientation); @@ -638,12 +635,7 @@ index = _viewSplitter->activeContainer()->currentIndex() + 1; } - // iterate over the view containers owned by this view manager - // and create a new terminal display for the session in each of them, along with - // a controller for the session/display pair - foreach (TabbedViewContainer *container, _viewSplitter->containers()) { - createView(session, container, index); - } + createView(session, _viewSplitter->activeContainer(), index); } TabbedViewContainer *ViewManager::createContainer() @@ -682,31 +674,12 @@ return container; } -void ViewManager::containerMoveViewRequest(int index, int id, - TabbedViewContainer *sourceTabbedContainer) +void ViewManager::containerMoveViewRequest(int index, int id) { auto *container = qobject_cast(sender()); auto *controller = qobject_cast(ViewProperties::propertiesById(id)); - - if (controller == nullptr) { - return; - } - - // do not move the last tab in a split view. - if (sourceTabbedContainer != nullptr) { - QPointer sourceContainer = qobject_cast(sourceTabbedContainer); - - if (_viewSplitter->containers().contains(sourceContainer)) { - return; - } else { - ViewManager *sourceViewManager = sourceTabbedContainer->connectedViewManager(); - - // do not remove the last tab on the window - if (qobject_cast(sourceViewManager->widget())->containers().size() > 1) { - return; - } - } - } + Q_ASSERT(container); + Q_ASSERT(controller); createView(controller->session(), container, index); controller->session()->refresh();