# HG changeset patch # User Daniel J Sebald # Date 1523168595 18000 # Node ID 8c38361718a973e96c49a0bc3cec4f80e2b95cd4 # Parent f83c2015cbc7fb4d50de89d9481957ac205723aa 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(). diff -r f83c2015cbc7 -r 8c38361718a9 libgui/src/variable-editor.cc --- 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 barlist = main_win ()->findChildren (); + + foreach (QTabBar *tbar, barlist) + { + for (int i=0; i < tbar->count (); i++) + { + if ((QWidget *) tbar->tabData (i).toULongLong () == this) + { + tbar->setCurrentIndex (i); + return; + } + } + } + } } void diff -r f83c2015cbc7 -r 8c38361718a9 libgui/src/variable-editor.h --- 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&);