From 822c48c22583d085e9f7b3f33751bb283b218e0d Mon Sep 17 00:00:00 2001 From: Nathan Sprangers Date: Thu, 9 Sep 2021 17:14:27 -0400 Subject: [PATCH] Enable/Disable "detach-view" correctly after DnD Enables detach-view in the target window if dropping creates the first split. Disables in the original window if one view is left after DnD. --- src/ViewManager.cpp | 5 +++++ src/widgets/ViewSplitter.cpp | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 16e95875..ad087828 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -642,6 +642,11 @@ SessionController *ViewManager::createController(Session *session, TerminalDispl connect(session, &Konsole::Session::selectionChanged, controller, &Konsole::SessionController::selectionChanged); connect(view, &Konsole::TerminalDisplay::destroyed, controller, &Konsole::SessionController::deleteLater); + // The controller is destroyed when the (split) view is drag-dropped to a different window + connect(controller, &QObject::destroyed, this, [this] { + toggleActionsBasedOnState(); + }); + // if this is the first controller created then set it as the active controller if (_pluggedController.isNull()) { controllerChanged(controller); diff --git a/src/widgets/ViewSplitter.cpp b/src/widgets/ViewSplitter.cpp index 01cfc5ac..8778553f 100644 --- a/src/widgets/ViewSplitter.cpp +++ b/src/widgets/ViewSplitter.cpp @@ -378,10 +378,12 @@ void Konsole::ViewSplitter::dropEvent(QDropEvent *ev) Qt::Orientation orientation = droppedEdge == Qt::LeftEdge || droppedEdge == Qt::RightEdge ? Qt::Horizontal : Qt::Vertical; + // Add the display so it can be counted correctly by ViewManager + addTerminalDisplay(source, orientation, behavior); + // topLevel is the splitter that's connected with the ViewManager // that in turn can call the SessionController. Q_EMIT getToplevelSplitter()->terminalDisplayDropped(source); - addTerminalDisplay(source, orientation, behavior); source->setVisible(true); currentDragTarget = nullptr; }