[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bkonsole/KDE/4=2E6=5D_src=3A_Restore_=27Close_Tab=27?=
From:       Kurt Hindenburg <kurt.hindenburg () gmail ! com>
Date:       2011-04-09 20:12:51
Message-ID: 20110409201251.EC2E6A609B () git ! kde ! org
[Download RAW message or body]

Git commit 05367a7e7463435e7b0a50827875f6dd6ee1940c by Kurt Hindenburg.
Committed on 09/04/2011 at 22:10.
Pushed by hindenburg into branch 'KDE/4.6'.

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)

M  +2    -1    src/Session.h     
M  +6    -13   src/ViewContainer.cpp     
M  +1    -1    src/ViewContainer.h     
M  +13   -0    src/ViewManager.cpp     
M  +2    -0    src/ViewManager.h     

http://commits.kde.org/konsole/05367a7e7463435e7b0a50827875f6dd6ee1940c

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;

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic