Commit 9292af91 authored by Kurt Hindenburg's avatar Kurt Hindenburg

Add 'Detach Tab' to the tab context menu.

Original patch by Shlomi Fish.  I did some hacking on it.

BUG: 153376

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=1118851
parent 8f573b66
......@@ -509,6 +509,10 @@ TabbedViewContainer::TabbedViewContainer(NavigationPosition position , QObject*
_contextPopupMenu = new KMenu(_tabBar);
_contextPopupMenu->addAction(KIcon("tab-detach"),
i18nc("@action:inmenu", "&Detach Tab"), this,
SLOT(tabContextMenuDetachTab()));
_contextPopupMenu->addAction(KIcon(),
i18nc("@action:inmenu", "&Rename Tab..."), this,
SLOT(tabContextMenuRenameTab()));
......@@ -668,6 +672,11 @@ void TabbedViewContainer::tabContextMenuCloseTab()
closeTab(_contextMenuTabIndex);
}
void TabbedViewContainer::tabContextMenuDetachTab()
{
emit detachTab(this, _stackWidget->widget(_contextMenuTabIndex));
}
void TabbedViewContainer::tabContextMenuRenameTab()
{
renameTab(_contextMenuTabIndex);
......
......@@ -443,7 +443,12 @@ private slots:
void openTabContextMenu(int index, const QPoint& point);
void tabContextMenuCloseTab();
void tabContextMenuRenameTab();
void tabContextMenuDetachTab();
void startTabDrag(int index);
signals:
void detachTab(ViewContainer * self, QWidget * activeView);
private:
void dynamicTabBarVisibility();
void setTabBarVisible(bool visible);
......
......@@ -314,22 +314,30 @@ void ViewManager::previousView()
container->activatePreviousView();
}
void ViewManager::detachActiveView()
{
// find the currently active view and remove it from its container
ViewContainer* container = _viewSplitter->activeContainer();
TerminalDisplay* activeView = dynamic_cast<TerminalDisplay*>(container->activeView());
if (!activeView)
detachView(container, container->activeView());
}
void ViewManager::detachView(ViewContainer* container, QWidget* widgetView)
{
TerminalDisplay * viewToDetach =
dynamic_cast<TerminalDisplay*>(widgetView);
if (!viewToDetach)
return;
emit viewDetached(_sessionMap[activeView]);
emit viewDetached(_sessionMap[viewToDetach]);
_sessionMap.remove(activeView);
_sessionMap.remove(viewToDetach);
// remove the view from this window
container->removeView(activeView);
activeView->deleteLater();
container->removeView(viewToDetach);
viewToDetach->deleteLater();
// if the container from which the view was removed is now empty then it can be deleted,
// unless it is the only container in the window, in which case it is left empty
......@@ -614,7 +622,16 @@ ViewContainer* ViewManager::createContainer(const Profile::Ptr info)
switch ( _navigationMethod )
{
case TabbedNavigation:
container = new TabbedViewContainer(position,_viewSplitter);
{
container =
new TabbedViewContainer(position,_viewSplitter);
connect(container,
SIGNAL(detachTab(ViewContainer*, QWidget*)),
this,
SLOT(detachView(ViewContainer*, QWidget*))
);
}
break;
case NoNavigation:
default:
......
......@@ -303,6 +303,8 @@ private slots:
// moved
void containerMoveViewRequest(int index, int id, bool& success);
void detachView(ViewContainer* container, QWidget* view);
private:
void createView(Session* session, ViewContainer* container, int index);
const ColorScheme* colorSchemeForProfile(const Profile::Ptr profile) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment