Mercurial > octave
changeset 29340:0e97c97044ee
improve handling focus of filter widgets in history and workspace view
* history-dock-widget.cc (set_filter_focus): new function, setting focus and
focus proxy to the filter or the list view depending on the boolean argument;
(filter_activate): call new function set_filter_focus with the filter
activation state;
(handle_contextmenu_filter): call new function set_filter_focus with
filter activation and visibility state
* history-dock-widget.h: new function set_filter_focus
* workspace-view.cc: same as for history-dock-widget.cc
* workspace-view.h: same as for history-dock-widget.h
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sat, 30 Jan 2021 12:24:05 +0100 |
parents | 93530bb4bd6f |
children | 3c6e3556fac4 |
files | libgui/src/history-dock-widget.cc libgui/src/history-dock-widget.h libgui/src/workspace-view.cc libgui/src/workspace-view.h |
diffstat | 4 files changed, 38 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/history-dock-widget.cc Thu Jan 28 00:23:00 2021 -0500 +++ b/libgui/src/history-dock-widget.cc Sat Jan 30 12:24:05 2021 +0100 @@ -124,6 +124,20 @@ m_filter->setCurrentIndex (0); } + void history_dock_widget::set_filter_focus (bool focus) + { + if (focus) + { + m_filter->setFocus (); + setFocusProxy (m_filter); + } + else + { + m_history_list_view->setFocus (); + setFocusProxy (m_history_list_view); + } + } + void history_dock_widget::filter_activate (bool state) { m_filter->setEnabled (state); @@ -133,6 +147,8 @@ m_sort_filter_proxy_model.setFilterWildcard (m_filter->currentText ()); else m_sort_filter_proxy_model.setFilterWildcard (QString ()); + + set_filter_focus (state); } void history_dock_widget::ctxMenu (const QPoint& xpos) @@ -223,6 +239,8 @@ { m_filter_shown = ! m_filter_shown; m_filter_widget->setVisible (m_filter_shown); + + set_filter_focus (m_filter_shown && m_filter_checkbox->isChecked ()) ; } void history_dock_widget::copyClipboard (void)
--- a/libgui/src/history-dock-widget.h Thu Jan 28 00:23:00 2021 -0500 +++ b/libgui/src/history-dock-widget.h Sat Jan 30 12:24:05 2021 +0100 @@ -92,6 +92,7 @@ private: void construct (void); + void set_filter_focus (bool focus); QListView *m_history_list_view; QSortFilterProxyModel m_sort_filter_proxy_model;
--- a/libgui/src/workspace-view.cc Thu Jan 28 00:23:00 2021 -0500 +++ b/libgui/src/workspace-view.cc Sat Jan 30 12:24:05 2021 +0100 @@ -246,6 +246,20 @@ octave_dock_widget::save_settings (); } + void workspace_view::set_filter_focus (bool focus) + { + if (focus) + { + m_filter->setFocus (); + setFocusProxy (m_filter); + } + else + { + m_view->setFocus (); + setFocusProxy (m_view); + } + } + void workspace_view::filter_update (const QString& expression) { @@ -263,6 +277,8 @@ filter_update (m_filter->currentText ()); else filter_update (QString ()); + + set_filter_focus (state); } void @@ -495,6 +511,8 @@ { m_filter_shown = ! m_filter_shown; m_filter_widget->setVisible (m_filter_shown); + + set_filter_focus (m_filter_shown && m_filter_checkbox->isChecked ()); } void
--- a/libgui/src/workspace-view.h Thu Jan 28 00:23:00 2021 -0500 +++ b/libgui/src/workspace-view.h Sat Jan 30 12:24:05 2021 +0100 @@ -105,6 +105,7 @@ private: void relay_contextmenu_command (const QString& cmdname, bool str = false); + void set_filter_focus (bool focus); QString get_var_name (const QModelIndex& index);