Mercurial > hg > octave-nkf
changeset 19619: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 | d93293218966 |
files | libgui/src/main-window.cc libgui/src/main-window.h |
diffstat | 2 files changed, 32 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -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)),
--- a/libgui/src/main-window.h +++ b/libgui/src/main-window.h @@ -80,6 +80,9 @@ void focus_command_window (void); signals: + + void active_dock_changed (octave_dock_widget *, octave_dock_widget *); + void settings_changed (const QSettings *); void init_terminal_size_signal (void); void new_file_signal (const QString&); @@ -98,6 +101,9 @@ public slots: + void focus_changed (QWidget *w_old, QWidget *w_new); + + void report_status_message (const QString& statusMessage); void handle_save_workspace_request (void); void handle_load_workspace_request (const QString& file = QString ()); @@ -311,6 +317,7 @@ list.append (static_cast<octave_dock_widget *> (workspace_window)); return list; } + octave_dock_widget *_active_dock; QString _release_notes_icon;