Mercurial > octave-nkf
diff libgui/src/main-window.cc @ 19456:476032040df9 gui-release
determining the active dock from focus changes in the gui
* main-window.cc (focus_changed): new slot for qApp::focusChagned signal,
determining the active dock to which the new focus-widget belongs and
emitting a signal indicating a change of the active dock;
(constructor): connect focusChagned signal to the new slot
* main-window.h: new slot, new signal, and new class variable for active dock
author | Torsten <ttl@justmail.de> |
---|---|
date | Tue, 23 Dec 2014 15:04:00 +0100 |
parents | ed0df431631b |
children | 5e93d228ff6b |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Sat Dec 20 17:26:53 2014 +0100 +++ b/libgui/src/main-window.cc Tue Dec 23 15:04:00 2014 +0100 @@ -103,6 +103,7 @@ bool connect_to_web = true; QDateTime last_checked; int serial = 0; + _active_dock = 0; if (settings) { @@ -158,6 +159,27 @@ delete _cmd_queue; } +// catch focus changes and determine the active dock widget +void +main_window::focus_changed (QWidget *, QWidget *w_new) +{ + octave_dock_widget* dock = 0; + while (w_new && w_new != _main_tool_bar) + { + dock = qobject_cast <octave_dock_widget *> (w_new); + if (dock) + break; // its a QDockWidget + w_new = qobject_cast <QWidget *> (w_new->previousInFocusChain ()); + } + + // if new dock has focus, emit signal and store active focus + if (dock != _active_dock) + { + emit active_dock_changed (_active_dock, dock); + _active_dock = dock; + } +} + bool main_window::command_window_has_focus (void) const { @@ -1279,6 +1301,9 @@ construct_octave_qt_link (); + connect (qApp, SIGNAL (focusChanged (QWidget*, QWidget*)), + this, SLOT(focus_changed (QWidget*, QWidget*))); + #ifdef HAVE_QSCINTILLA connect (this, SIGNAL (insert_debugger_pointer_signal (const QString&, int)),