Mercurial > octave
changeset 29202:66af654b3485
provide focus follows mouse for widgets in the main window (bug #59701)
* gui-preferences-dw.h: new preference for the new feature
* octave-dock-widget.cc (octave_dock_widget): initialize new class variable;
(handle_settings): get preference for new feature from settings file
and store it in new class variable
(eventFilter): catch mouse enter event and activate widget if widget is
docked and feature is enabled
* octave-dock-widget.h: new class variable m_focus_follows_mouse
* settings-dialog.cc (settings_dialog): set related check box depending
on preference from settings file;
(write_changed_settings): write check box state into settings file
* settings-dialog.ui: add checkbos for new feature with tool tip
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sun, 20 Dec 2020 12:06:59 +0100 |
parents | 6e0952fa5a4f |
children | 5749eec4e2f2 |
files | libgui/src/gui-preferences-dw.h libgui/src/octave-dock-widget.cc libgui/src/octave-dock-widget.h libgui/src/settings-dialog.cc libgui/src/settings-dialog.ui |
diffstat | 5 files changed, 84 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/gui-preferences-dw.h Sat Dec 19 16:29:32 2020 +0100 +++ b/libgui/src/gui-preferences-dw.h Sun Dec 20 12:06:59 2020 +0100 @@ -29,6 +29,9 @@ #include "gui-preferences.h" const gui_pref +dw_focus_follows_mouse ("DockWidgets/focus_follows_mouse", QVariant (false)); + +const gui_pref dw_title_custom_style ("DockWidgets/widget_title_custom_style", QVariant (false));
--- a/libgui/src/octave-dock-widget.cc Sat Dec 19 16:29:32 2020 +0100 +++ b/libgui/src/octave-dock-widget.cc Sun Dec 20 12:06:59 2020 +0100 @@ -183,8 +183,9 @@ octave_dock_widget::octave_dock_widget (const QString& obj_name, QWidget *p, base_qobject& oct_qobj) - : label_dock_widget (p, oct_qobj), m_recent_float_geom (), - m_recent_dock_geom (), m_waiting_for_mouse_button_release (false) + : label_dock_widget (p, oct_qobj), m_focus_follows_mouse (false), + m_recent_float_geom (), m_recent_dock_geom (), + m_waiting_for_mouse_button_release (false) { setObjectName (obj_name); @@ -446,6 +447,8 @@ void octave_dock_widget::handle_settings (const gui_settings *settings) { + m_focus_follows_mouse = settings->value (dw_focus_follows_mouse).toBool (); + m_custom_style = settings->value (dw_title_custom_style).toBool (); @@ -572,12 +575,19 @@ bool octave_dock_widget::eventFilter (QObject *obj, QEvent *e) { + // Ignore double clicks into window decoration elements if (e->type () == QEvent::NonClientAreaMouseButtonDblClick) { - e->ignore (); // ignore double clicks into window decoration elements + e->ignore (); return true; } + // Detect mouse enter events if "focus follows mouse" is desired + // for widgets docked to the main window (non floating) and activate + // the widget currently under the mouse + if (m_focus_follows_mouse && ! isFloating () && (e->type () == QEvent::Enter)) + activate (); + return QDockWidget::eventFilter (obj,e); }
--- a/libgui/src/octave-dock-widget.h Sat Dec 19 16:29:32 2020 +0100 +++ b/libgui/src/octave-dock-widget.h Sun Dec 20 12:06:59 2020 +0100 @@ -167,6 +167,7 @@ QMainWindow *m_parent; bool m_custom_style; + bool m_focus_follows_mouse; int m_title_3d; QColor m_bg_color; QColor m_bg_color_active;
--- a/libgui/src/settings-dialog.cc Sat Dec 19 16:29:32 2020 +0100 +++ b/libgui/src/settings-dialog.cc Sun Dec 20 12:06:59 2020 +0100 @@ -228,6 +228,10 @@ (cs_cursor_blinking.key, cs_cursor_blinking.def).toBool ()); } + // focus follows mouse + cb_focus_follows_mouse->setChecked ( + settings->value (dw_focus_follows_mouse).toBool ()); + // prompt on exit cb_prompt_to_exit->setChecked ( settings->value (global_prompt_to_exit.key, global_prompt_to_exit.def).toBool ()); @@ -910,6 +914,9 @@ // cursor blinking settings->setValue (global_cursor_blinking.key, cb_cursor_blinking->isChecked ()); + // focus follows mouse + settings->setValue (dw_focus_follows_mouse.key, cb_focus_follows_mouse->isChecked ()); + // promp to exit settings->setValue (global_prompt_to_exit.key, cb_prompt_to_exit->isChecked ());
--- a/libgui/src/settings-dialog.ui Sat Dec 19 16:29:32 2020 +0100 +++ b/libgui/src/settings-dialog.ui Sun Dec 20 12:06:59 2020 +0100 @@ -32,7 +32,7 @@ </size> </property> <property name="currentIndex"> - <number>6</number> + <number>0</number> </property> <widget class="QWidget" name="tab_general"> <property name="enabled"> @@ -51,9 +51,9 @@ <property name="geometry"> <rect> <x>0</x> - <y>-38</y> + <y>0</y> <width>1021</width> - <height>607</height> + <height>616</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_17"> @@ -112,16 +112,6 @@ </property> </widget> </item> - <item row="8" column="0"> - <widget class="QCheckBox" name="cb_use_native_file_dialogs"> - <property name="text"> - <string>Use native file dialogs</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> <item row="3" column="1"> <layout class="QVBoxLayout" name="verticalLayout_5"> <item> @@ -174,26 +164,6 @@ </item> </layout> </item> - <item row="9" column="0"> - <widget class="QCheckBox" name="cb_cursor_blinking"> - <property name="text"> - <string>Cursor blinking</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="10" column="0"> - <widget class="QCheckBox" name="cb_status_bar"> - <property name="text"> - <string>Show status bar</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - </item> <item row="5" column="1"> <layout class="QHBoxLayout" name="horizontalLayout_9"> <item> @@ -414,13 +384,6 @@ </item> </layout> </item> - <item row="11" column="0"> - <widget class="QCheckBox" name="cb_prompt_to_exit"> - <property name="text"> - <string>Confirm before exiting</string> - </property> - </widget> - </item> <item row="1" column="0"> <widget class="QLabel" name="label_2"> <property name="text"> @@ -464,6 +427,63 @@ </item> </layout> </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_35"> + <property name="spacing"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QCheckBox" name="cb_use_native_file_dialogs"> + <property name="text"> + <string>Use native file dialogs</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cb_cursor_blinking"> + <property name="text"> + <string>Cursor blinking</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cb_status_bar"> + <property name="text"> + <string>Show status bar</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cb_focus_follows_mouse"> + <property name="toolTip"> + <string><html><head/><body><p>If set, the focus of the widgets that are docked to the main window follows the mouse cursor. This is intended for having the same behavior within the main window when &quot;focus follows mouse&quot; is used for the desktop environment.</p></body></html></string> + </property> + <property name="text"> + <string>Focus follows mouse for widgets docked to the main window</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="cb_prompt_to_exit"> + <property name="text"> + <string>Confirm before exiting</string> + </property> + </widget> + </item> + </layout> + </item> </layout> </widget> </item>