changeset 25168:8c38361718a9 stable

When Variable Editor is tabbed, activate that tab via openvar (bug #53443). * variable_editor.cc (variable_dock_widget::toplevel_change): Move setFocus() after activateWindow(). (variable_editor::edit_variable): Call tab_to_front() and setFocus() after raising and activating. (variable_editor::tab_to_front): Added. New routine that looks through the QTabBar list on the QMainWindow searching for the Variable Editor and if found set as the current tab. * variable_editor.h (variable_editor): Declare new function tab_to_front().
author Daniel J Sebald <daniel.sebald@ieee.org>
date Sun, 08 Apr 2018 01:23:15 -0500
parents f83c2015cbc7
children 512b68611097 c38c70a5222c
files libgui/src/variable-editor.cc libgui/src/variable-editor.h
diffstat 2 files changed, 28 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/variable-editor.cc	Sun Apr 08 15:13:45 2018 +0200
+++ b/libgui/src/variable-editor.cc	Sun Apr 08 01:23:15 2018 -0500
@@ -176,8 +176,8 @@
         m_dock_action->setIcon (QIcon (":/actions/icons/widget-dock.png"));
         m_dock_action->setToolTip (tr ("Dock widget"));
 
+        activateWindow();
         setFocus (Qt::OtherFocusReason);
-        activateWindow();
       }
     else
       {
@@ -1079,11 +1079,11 @@
           }
 
         // Put existing variable in focus and raise
-        QFocusEvent event (QEvent::FocusIn, Qt::OtherFocusReason);
-        QApplication::sendEvent (existing_qdw, &event);
         existing_qdw->show ();
         existing_qdw->raise ();
         existing_qdw->activateWindow ();
+        tab_to_front ();
+        existing_qdw->setFocus ();
 
         return;
       }
@@ -1184,6 +1184,29 @@
     page->show ();
     page->raise ();
     page->activateWindow ();
+    tab_to_front ();
+    page->setFocus ();
+  }
+
+  void
+  variable_editor::tab_to_front (void)
+  {
+    if (parent () != nullptr)
+      {
+        QList<QTabBar *> barlist = main_win ()->findChildren<QTabBar *> ();
+
+        foreach (QTabBar *tbar, barlist)
+          {
+            for (int i=0; i < tbar->count (); i++)
+              {
+                  if ((QWidget *) tbar->tabData (i).toULongLong () == this)
+                  {
+                    tbar->setCurrentIndex (i);
+                    return;
+                  }
+              }
+          }
+      }
   }
 
   void
--- a/libgui/src/variable-editor.h	Sun Apr 08 15:13:45 2018 +0200
+++ b/libgui/src/variable-editor.h	Sun Apr 08 01:23:15 2018 -0500
@@ -270,6 +270,8 @@
 
     static QStringList color_names (void);
 
+    void tab_to_front (void);
+
   public slots:
 
     void callUpdate (const QModelIndex&, const QModelIndex&);