Bug 233937 - Close tab keyboard shortcut does not work correctly
Summary: Close tab keyboard shortcut does not work correctly
Status: RESOLVED FIXED
Alias: None
Product: rekonq
Classification: Applications
Component: general (show other bugs)
Version: latest git snapshot
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Andrea Diamantini
URL:
Keywords:
Depends on:
Blocks: 237890
  Show dependency treegraph
 
Reported: 2010-04-10 12:20 UTC by Boris Bigott
Modified: 2010-09-04 10:01 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Bigott 2010-04-10 12:20:49 UTC
Version:           0.4.0 (using KDE 4.4.2)
Compiler:          gcc version 4.4.3 
OS:                Linux
Installed from:    Gentoo Packages

I assigned a keyboard shortcut (Ctrl+W) to close tab. Whenever I trigger this shortcut, the first tab is closed but not the active tab. This basically renders the shortcut useless.
Comment 1 Panagiotis Papadopoulos 2010-04-25 22:41:03 UTC
I can confirm this:
ctrl+w in the latest git version of rekonq does *nothing*
Comment 2 Josef 2010-05-15 16:44:13 UTC
Ditto, also using rekonq 0.4.0 but on Kubuntu
Comment 3 Andrea Diamantini 2010-05-19 01:35:33 UTC
It works here. What about you, guys?
Comment 4 Panagiotis Papadopoulos 2010-05-24 03:50:28 UTC
looks like it has been fixed, at least in Version 0.4.70 it works
Comment 5 Panagiotis Papadopoulos 2010-05-24 03:53:08 UTC
after all it isn't fixed… It shows a completely strange behaviour, sometimes closing the first tab, sometimes closing the last tab.
I'll try to find a way to reliably reproduce this bug…
Comment 6 Blackpaw 2010-05-26 15:50:22 UTC
Works fine for me in 4.90
Comment 7 Nikhil Marathe 2010-05-27 10:41:24 UTC
Works fine for me too. Boris, could you verify it again with the 0.5 beta or git version
Comment 8 Boris Bigott 2010-05-27 13:12:43 UTC
Hi, I tried version 4.90 and still have the same problem. It's really strange sometimes no tab closes at all and sometimes the first tab closes.
Comment 9 Panagiotis Papadopoulos 2010-05-27 13:30:07 UTC
Same behaviour here with the latest git…
Sometimes it does close a tab (even if it is a wrong one) sometimes it does not do anything. I'll try it again with a fresh rekonqrc, to see if it helps.
Comment 10 Boris Bigott 2010-05-29 01:11:27 UTC
Hi, finally I was able to solve the problem, but it is still rather strange. As hinted by Panagiotis Papadopoulos, I removed Ctrl+W short for "close tab" from my rekonqrc and now, even with having a shortcut assigned, tabs close properly.

There seems to be something wrong with the keyboard shortcut configuration in rekonq. For example, I assigned a shortcut to "close all other tabs", which freezes rekonq for a few seconds and than closes *all* tabs.
Comment 11 Andrea Diamantini 2010-06-03 16:03:51 UTC
Understood problem :)
Don't have a clue how properly fix it :(
Spending this night fighting with..
Comment 12 Andrea Diamantini 2010-06-04 02:38:42 UTC
commit d44c64e440e8d551d528eeafef97407c77cd420a
Author: Andrea Diamantini <adjam7@gmail.com>
Date:   Fri Jun 4 02:38:35 2010 +0200

    This should fix the Ctrl+w bug. Anyway, it really doesn't solve it: there is a corner case
    where the trick implemented doesn't work. We'll see if someone can fix also that..
    
    BUG:233937

diff --git a/src/mainview.cpp b/src/mainview.cpp
index 0b17ef2..166c1a1 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -413,9 +413,11 @@ void MainView::windowCloseRequested()
 
 void MainView::closeOtherTabs(int index)
 {
-    if (-1 == index)
+    if (index < 0)
+        index = currentIndex();
+    if (index < 0 || index >= count())
         return;
-
+    
     for (int i = count() - 1; i > index; --i)
     {
         closeTab(i);
@@ -430,7 +432,6 @@ void MainView::closeOtherTabs(int index)
 }
 
 
-// When index is -1 index chooses the current tab
 void MainView::cloneTab(int index)
 {
     if (index < 0)
diff --git a/src/mainview.h b/src/mainview.h
index 636d37a..f0a1982 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -125,14 +125,17 @@ public slots:
      */
     void newTab();
 
+    // Indexed slots
     void cloneTab(int index = -1);
     void closeTab(int index = -1, bool del = true);
-    void closeOtherTabs(int index);
+    void closeOtherTabs(int index = -1);
     void reloadTab(int index = -1);
+    void detachTab(int index = -1);
+    
     void reloadAllTabs();
     void nextTab();
     void previousTab();
-    void detachTab(int index = -1);
+    
     void openClosedTabs();
     void openClosedTab();
     void switchToTab();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 5a0b256..dc1dc70 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -402,6 +402,7 @@ void MainWindow::setupActions()
 
     // ============================== Indexed Tab Actions ====================================
     a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this);
+    a->setShortcuts( KStandardShortcut::close() );
     actionCollection()->addAction(QL1S("close_tab"), a);
     connect(a, SIGNAL(triggered(bool)), m_view->tabBar(), SLOT(closeTab()));
 
@@ -1094,13 +1095,6 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
         return;
     }
 
-    // close current tab action
-    if ((event->modifiers() == Qt::ControlModifier) && event->key() == Qt::Key_W)
-    {
-        m_view->closeTab(m_view->currentIndex());
-        return;
-    }
-
     KMainWindow::keyPressEvent(event);
 }
 
diff --git a/src/tabbar.cpp b/src/tabbar.cpp
index 94c5efb..09aa814 100644
--- a/src/tabbar.cpp
+++ b/src/tabbar.cpp
@@ -120,30 +120,35 @@ QSize TabBar::tabSizeHint(int index) const
 void TabBar::cloneTab()
 {
     emit cloneTab(m_actualIndex);
+    m_actualIndex = -1;
 }
 
 
 void TabBar::closeTab()
 {
     emit closeTab(m_actualIndex);
+    m_actualIndex = -1;
 }
 
 
 void TabBar::closeOtherTabs()
 {
     emit closeOtherTabs(m_actualIndex);
+    m_actualIndex = -1;
 }
 
 
 void TabBar::reloadTab()
 {
     emit reloadTab(m_actualIndex);
+    m_actualIndex = -1;
 }
 
 
 void TabBar::detachTab()
 {
     emit detachTab(m_actualIndex);
+    m_actualIndex = -1;
 }