Commit 4c440f9d authored by Kurt Hindenburg's avatar Kurt Hindenburg

Implement 'Rename Tab...' and 'Close Tab' in tab context menu.

Original patch by Shlomi Fish.  I did some hacking on it and removed 'Detach Tab' option for this commit.

CCBUG: 153376

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=1115877
parent ed3aee70
......@@ -424,6 +424,7 @@ QPixmap ViewContainerTabBar::dragDropPixmap(int tab)
}
TabbedViewContainer::TabbedViewContainer(NavigationPosition position , QObject* parent)
: ViewContainer(position,parent)
, _contextMenuTabIndex(0)
{
_containerWidget = new QWidget;
_stackWidget = new QStackedWidget();
......@@ -450,6 +451,8 @@ TabbedViewContainer::TabbedViewContainer(NavigationPosition position , QObject*
connect( _tabBar , SIGNAL(wheelDelta(int)) , this , SLOT(wheelScrolled(int)) );
connect( _tabBar , SIGNAL(closeRequest(int)) , this , SLOT(closeTab(int)) );
connect( _tabBar , SIGNAL(initiateDrag(int)) , this , SLOT(startTabDrag(int)) );
connect( _tabBar, SIGNAL(contextMenu(int, const QPoint&)), this,
SLOT(openTabContextMenu(int, const QPoint&)) );
connect( _newTabButton , SIGNAL(clicked()) , this , SIGNAL(newViewRequest()) );
connect( _closeTabButton , SIGNAL(clicked()) , this , SLOT(closeCurrentTab()) );
......@@ -482,6 +485,17 @@ TabbedViewContainer::TabbedViewContainer(NavigationPosition position , QObject*
Q_ASSERT(false); // position not supported
_containerWidget->setLayout(_layout);
_contextPopupMenu = new KMenu(_tabBar);
_contextPopupMenu->addAction(KIcon(),
i18nc("@action:inmenu", "&Rename Tab..."), this,
SLOT(tabContextMenuRenameTab()));
_contextPopupMenu->addAction(KIcon("tab-close"),
i18nc("@action:inmenu", "&Close Tab"), this,
SLOT(tabContextMenuCloseTab()));
}
void TabbedViewContainer::setNewViewMenu(QMenu* menu)
{
......@@ -610,10 +624,34 @@ void TabbedViewContainer::startTabDrag(int tab)
removeView(view);
}
}
void TabbedViewContainer::tabDoubleClicked(int tab)
void TabbedViewContainer::tabDoubleClicked(int index)
{
renameTab(index);
}
void TabbedViewContainer::renameTab(int index)
{
viewProperties(views()[index])->rename();
}
void TabbedViewContainer::openTabContextMenu(int index, const QPoint& pos)
{
_contextMenuTabIndex = index;
_contextPopupMenu->exec(pos);
}
void TabbedViewContainer::tabContextMenuCloseTab()
{
viewProperties( views()[tab] )->rename();
closeTab(_contextMenuTabIndex);
}
void TabbedViewContainer::tabContextMenuRenameTab()
{
renameTab(_contextMenuTabIndex);
}
void TabbedViewContainer::moveViewWidget( int fromIndex , int toIndex )
{
QString text = _tabBar->tabText(fromIndex);
......
......@@ -440,12 +440,15 @@ private slots:
void wheelScrolled(int delta);
void tabDoubleClicked(int index);
void openTabContextMenu(int index, const QPoint& point);
void tabContextMenuCloseTab();
void tabContextMenuRenameTab();
void startTabDrag(int index);
private:
void dynamicTabBarVisibility();
void setTabBarVisible(bool visible);
void setTabActivity(int index,bool activity);
void renameTab(int index);
ViewContainerTabBar* _tabBar;
QPointer<QStackedWidget> _stackWidget;
......@@ -454,6 +457,8 @@ private:
QHBoxLayout* _tabBarLayout;
QToolButton* _newTabButton;
QToolButton* _closeTabButton;
int _contextMenuTabIndex;
KMenu* _contextPopupMenu;
};
......
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