Commit 467fb1ed authored by Kurt Hindenburg's avatar Kurt Hindenburg
Browse files

Restore 'Close Tab' on the tab context menu and the close tabbar button.

These 2 options were disabled due to they messed up the menu texts
after the fix for bko 185466.
The close method via dbus has been disabled as it causes menu issues.

Most of patch to fix 'Close Tab' by Albert Astals Cid aacid@kde.org
BUG: 267896
CCBUG: 185466
FIXED-IN: 4.6.3
parent dd9b0833
......@@ -376,7 +376,8 @@ public slots:
* then the terminal connection (the pty) is closed and Konsole waits for the
* process to exit.
*/
Q_SCRIPTABLE void close();
//Q_SCRIPTABLE void close(); // This cause the menu issues bko 185466
void close();
/**
* Changes the session title or other customizable aspects of the terminal
......
......@@ -443,13 +443,11 @@ TabbedViewContainer::TabbedViewContainer(NavigationPosition position , QObject*
_closeTabButton->setIcon(KIcon("tab-close"));
_closeTabButton->adjustSize();
_closeTabButton->setHidden(true);
_closeTabButton->setEnabled(false);
connect( _tabBar , SIGNAL(currentChanged(int)) , this , SLOT(currentTabChanged(int)) );
connect( _tabBar , SIGNAL(tabDoubleClicked(int)) , this , SLOT(tabDoubleClicked(int)) );
connect( _tabBar , SIGNAL(newTabRequest()) , this , SIGNAL(newViewRequest()) );
connect( _tabBar , SIGNAL(wheelDelta(int)) , this , SLOT(wheelScrolled(int)) );
connect( _tabBar , SIGNAL(tabCloseRequested(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&)) );
......@@ -496,9 +494,9 @@ TabbedViewContainer::TabbedViewContainer(NavigationPosition position , QObject*
i18nc("@action:inmenu", "&Rename Tab..."), this,
SLOT(tabContextMenuRenameTab()));
// _contextPopupMenu->addAction(KIcon("tab-close"),
// i18nc("@action:inmenu", "&Close Tab"), this,
// SLOT(tabContextMenuCloseTab()));
_contextPopupMenu->addAction(KIcon("tab-close"),
i18nc("@action:inmenu", "&Close Tab"), this,
SLOT(tabContextMenuCloseTab()));
}
void TabbedViewContainer::setNewViewMenu(QMenu* menu)
......@@ -521,16 +519,10 @@ void TabbedViewContainer::closeCurrentTab()
{
if (_stackWidget->currentIndex() != -1)
{
closeTab(_stackWidget->currentIndex());
emit closeTab(this, _stackWidget->widget(_stackWidget->currentIndex()));
}
}
void TabbedViewContainer::closeTab(int tab)
{
Q_ASSERT(tab >= 0 && tab < _stackWidget->count());
if (viewProperties(_stackWidget->widget(tab))->confirmClose())
removeView(_stackWidget->widget(tab));
}
void TabbedViewContainer::setTabBarVisible(bool visible)
{
_tabBar->setVisible(visible);
......@@ -655,7 +647,8 @@ void TabbedViewContainer::openTabContextMenu(int index, const QPoint& pos)
void TabbedViewContainer::tabContextMenuCloseTab()
{
closeTab(_contextMenuTabIndex);
_tabBar->setCurrentIndex(_contextMenuTabIndex);// Required for this to work
emit closeTab(this, _stackWidget->widget(_contextMenuTabIndex));
}
void TabbedViewContainer::tabContextMenuDetachTab()
......
......@@ -427,7 +427,6 @@ private slots:
void updateIcon(ViewProperties* item);
void updateActivity(ViewProperties* item);
void currentTabChanged(int index);
void closeTab(int index);
void closeCurrentTab();
void wheelScrolled(int delta);
......@@ -440,6 +439,7 @@ private slots:
signals:
void detachTab(ViewContainer * self, QWidget * activeView);
void closeTab(ViewContainer * self, QWidget * activeView);
private:
void dynamicTabBarVisibility();
......
......@@ -639,6 +639,11 @@ ViewContainer* ViewManager::createContainer(const Profile::Ptr info)
this,
SLOT(detachView(ViewContainer*, QWidget*))
);
connect(container,
SIGNAL(closeTab(ViewContainer*, QWidget*)),
this,
SLOT(closeTabFromContainer(ViewContainer*, QWidget*)));
}
break;
case NoNavigation:
......@@ -1090,5 +1095,13 @@ void ViewManager::moveSessionRight()
this->moveActiveViewRight();
}
void ViewManager::closeTabFromContainer(ViewContainer *container, QWidget *tab)
{
SessionController *controller = dynamic_cast<SessionController*>(container->viewProperties(tab));
Q_ASSERT(controller);
if (controller && controller->confirmClose())
controller->session()->close();
}
#include "ViewManager.moc"
......@@ -314,6 +314,8 @@ private slots:
void detachView(ViewContainer* container, QWidget* view);
void closeTabFromContainer(ViewContainer *container, QWidget *view);
private:
void createView(Session* session, ViewContainer* container, int index);
const ColorScheme* colorSchemeForProfile(const Profile::Ptr profile) const;
......
Supports Markdown
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