summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Hindenburg <kurt.hindenburg@gmail.com>2011-04-09 20:10:17 (GMT)
committerKurt Hindenburg <kurt.hindenburg@gmail.com>2011-04-09 20:10:17 (GMT)
commit05367a7e7463435e7b0a50827875f6dd6ee1940c (patch)
treedc3d864d2d3056e4a0ec8507aa992e2f884dc6e9
parent3b9294da1ed571ea045c8753f0729a875f5e2a35 (diff)
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 CCBUG: 267896 CCBUG: 185466 FIXED-IN: 4.6.3 CCMAIL: aacid@kde.org (cherry picked from commit 467fb1edcbc53081de348251cef490ed5002fa3b)
-rw-r--r--src/Session.h3
-rw-r--r--src/ViewContainer.cpp19
-rw-r--r--src/ViewContainer.h2
-rw-r--r--src/ViewManager.cpp13
-rw-r--r--src/ViewManager.h2
5 files changed, 24 insertions, 15 deletions
diff --git a/src/Session.h b/src/Session.h
index def9f92..6f16fe9 100644
--- a/src/Session.h
+++ b/src/Session.h
@@ -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
diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp
index 5ec9e49..72ba5fd 100644
--- a/src/ViewContainer.cpp
+++ b/src/ViewContainer.cpp
@@ -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&)) );
@@ -495,11 +493,11 @@ TabbedViewContainer::TabbedViewContainer(NavigationPosition position , QObject*
_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)
{
@@ -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()
diff --git a/src/ViewContainer.h b/src/ViewContainer.h
index da7d598..aa512f8 100644
--- a/src/ViewContainer.h
+++ b/src/ViewContainer.h
@@ -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();
diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp
index a846a38..8c16027 100644
--- a/src/ViewManager.cpp
+++ b/src/ViewManager.cpp
@@ -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:
@@ -1084,5 +1089,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"
diff --git a/src/ViewManager.h b/src/ViewManager.h
index bf17b4d..ac3d56c 100644
--- a/src/ViewManager.h
+++ b/src/ViewManager.h
@@ -313,6 +313,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;