Bug 115748

Summary: context menu of tabs only applies to current tab.
Product: [Applications] kst Reporter: Matthew Truch <matt>
Component: generalAssignee: kst
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 1.x   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Matthew Truch 2005-11-05 23:35:00 UTC
Version:           1.2.0_svn_476698 (using KDE KDE 3.4.1)
OS:                Linux

The context menu for tabs seems to only apply to the current tab.   That is, if you right click on any tab (visible or one of the others) the menu (and any settings changed because of it) actually apply to the current tab.  This is extra weird since the greying-out action of the "move left" and "move right" entries in the context menu does seem to know about which tab you are clicking on, but the actual action of moving left and right applies to the current tab.  

Expected behavior: If one right clicks on the non-current tab, the context menu appears, applies to the tab clicked on (not the current tab), and the changes are made (whatever they are).  The 'current tab' (one that is visible) should remain that way during the whole process.
Comment 1 George Staikos 2005-11-06 02:47:38 UTC
  This is one of about a dozen bugs in the context menu.  KMDI is so royally 
broken, I really don't know what to say.
Comment 2 Matthew Truch 2005-11-08 23:51:59 UTC
It seems that everything except for "move right" and "move left" are fixed now.  
Comment 3 George Staikos 2005-11-09 04:18:28 UTC
SVN commit 479070 by staikos:

moveLeft/moveRight fixed
BUG: 115748


 M  +18 -10    kst.cpp  
 M  +3 -2      kst.h  
 M  +10 -0     kstviewwindow.cpp  
 M  +3 -0      kstviewwindow.h  


--- trunk/extragear/graphics/kst/kst/kst.cpp #479069:479070
@@ -2503,9 +2503,9 @@
   if (vw) {
     KTabWidget *tw = tabWidget();
     if (tw) { // should always be true, but who knows how KMdi might change
-      int id = pm->insertItem(i18n("Move &Left"), this, SLOT(moveTabLeft()));
+      int id = pm->insertItem(i18n("Move &Left"), vw, SLOT(moveTabLeft()));
       pm->setItemEnabled(id, tw->indexOf(w) > 0);
-      id = pm->insertItem(i18n("Move &Right"), this, SLOT(moveTabRight()));
+      id = pm->insertItem(i18n("Move &Right"), vw, SLOT(moveTabRight()));
       pm->setItemEnabled(id, tw->indexOf(w) < tw->count() - 1);
     }
     pm->insertItem(i18n("R&ename..."), vw, SLOT(rename()));
@@ -2525,19 +2525,27 @@
 }
 
 
-void KstApp::moveTabLeft() {
+void KstApp::moveTabLeft(KstViewWindow *tab) {
   KTabWidget *tw = tabWidget();
-  int cur = tw->currentPageIndex();
-  tw->moveTab(cur, cur - 1);
-  tw->setCurrentPage(cur - 1);
+  if (tw) {
+    int cur = tw->indexOf(tab);
+    if (cur > 0) {
+      tw->moveTab(cur, cur - 1);
+      tw->showPage(tab);
+    }
+  }
 }
 
 
-void KstApp::moveTabRight() {
+void KstApp::moveTabRight(KstViewWindow *tab) {
   KTabWidget *tw = tabWidget();
-  int cur = tw->currentPageIndex();
-  tw->moveTab(cur, cur + 1);
-  tw->setCurrentPage(cur + 1);
+  if (tw) {
+    int cur = tw->indexOf(tab);
+    if (cur >= 0 && cur < tw->count() - 1) {
+      tw->moveTab(cur, cur + 1);
+      tw->showPage(tab);
+    }
+  }
 }
 
 
--- trunk/extragear/graphics/kst/kst/kst.h #479069:479070
@@ -158,6 +158,9 @@
 
     bool paused() const;
 
+    void moveTabLeft(KstViewWindow*);
+    void moveTabRight(KstViewWindow*);
+
   protected:
     void customEvent(QCustomEvent *e);
 
@@ -218,8 +221,6 @@
     void fixKMdi();
     void showContextMenu(QWidget *w, const QPoint& pos);
     void showContextMenu(const QPoint& pos);
-    void moveTabLeft();
-    void moveTabRight();
 
   public slots:
     void fromEnd();
--- trunk/extragear/graphics/kst/kst/kstviewwindow.cpp #479069:479070
@@ -98,6 +98,16 @@
 }
 
 
+void KstViewWindow::moveTabLeft() {
+  KstApp::inst()->moveTabLeft(this);
+}
+
+
+void KstViewWindow::moveTabRight() {
+  KstApp::inst()->moveTabRight(this);
+}
+
+
 void KstViewWindow::updateActions() {
 }
 
--- trunk/extragear/graphics/kst/kst/kstviewwindow.h #479069:479070
@@ -85,6 +85,9 @@
       file and window*/
     void slotFileClose();
 
+    void moveTabLeft();
+    void moveTabRight();
+
     /** print without querying */
     void immediatePrintToFile(const QString& filename);
     void immediatePrintToEps(const QString& filename, const QSize& size);