diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 25ca37ddf..a2038627a 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -156,9 +156,8 @@ void ViewManager::setupActions() // Ctrl+Shift+D is not used as a shortcut by default because it is too close // to Ctrl+D - which will terminate the session in many cases detachViewAction->setShortcut( QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_H) ); - - multiViewOnlyActions << detachViewAction; - + + connect( this , SIGNAL(splitViewToggle(bool)) , this , SLOT(updateDetachViewState()) ); connect( detachViewAction , SIGNAL(triggered()) , this , SLOT(detachActiveView()) ); // Expand & Shrink Active View @@ -217,6 +216,19 @@ void ViewManager::setupActions() _viewSplitter->addAction(moveViewRightAction); } +void ViewManager::updateDetachViewState() +{ + if (!_actionCollection) + return; + + bool splitView = _viewSplitter->containers().count() >= 2; + bool shouldEnable = splitView || _viewSplitter->activeContainer()->views().count() >= 2; + + QAction* detachAction = _actionCollection->action("detach-view"); + + if ( detachAction && shouldEnable != detachAction->isEnabled() ) + detachAction->setEnabled(shouldEnable); +} void ViewManager::moveActiveViewLeft() { qDebug() << "Moving active view to the left"; @@ -498,6 +510,8 @@ void ViewManager::createView(Session* session) display->setFocus( Qt::OtherFocusReason ); } } + + updateDetachViewState(); } ViewContainer* ViewManager::createContainer(const QString& profileKey) @@ -572,6 +586,7 @@ void ViewManager::viewCloseRequest(QWidget* view) } focusActiveView(); + updateDetachViewState(); } TerminalDisplay* ViewManager::createTerminalDisplay(Session* session) diff --git a/src/ViewManager.h b/src/ViewManager.h index d78bd7ce7..a07b4c6ab 100644 --- a/src/ViewManager.h +++ b/src/ViewManager.h @@ -189,6 +189,8 @@ private slots: // called when the "Detach View" menu item is selected void detachActiveView(); + void updateDetachViewState(); + // called when a session terminates - the view manager will delete any // views associated with the session void sessionFinished();