Mercurial > octave-nkf
diff libgui/src/history-dock-widget.cc @ 20605:734d446560a8
possibility to hide filters in history and workspace view (bug#45428)
* history_dock_widget.cc(construct): use settings file for show/hide the filter;
(~history_dock_widget): save current filter state to settings file;
(ctxMenu): add menu entry for showing/hiding the filter;
(handle_contextmenu_filter): slot for the new menu entry
* history-dock-widget.h: new slot for new menu entry, new class variables for
filter and show/hide-state
* workspace-view.cc(workspace_view): use settings file for show/hide the filter;
(~workspace_view): save current filter state to settings file;
(contextmenu_requested): add menu entry for showing/hiding the filter;
(handle_contextmenu_filter): slot for the new menu entry
* workspace-view.h: new slot for new menu entry, new class variables for
filter and show/hide-state
author | Torsten <ttl@justmail.de> |
---|---|
date | Wed, 07 Oct 2015 21:01:25 +0200 |
parents | a8cc8318da8c |
children |
line wrap: on
line diff
--- a/libgui/src/history-dock-widget.cc Wed Oct 07 07:41:44 2015 -0700 +++ b/libgui/src/history-dock-widget.cc Wed Oct 07 21:01:25 2015 +0200 @@ -94,21 +94,29 @@ set_title (tr ("Command History")); setWidget (new QWidget ()); - QVBoxLayout *vbox_layout = new QVBoxLayout (); - QHBoxLayout *hbox_layout = new QHBoxLayout (); - hbox_layout->addWidget (filter_label); - hbox_layout->addWidget (_filter_checkbox); - hbox_layout->addWidget (_filter); - vbox_layout->addLayout (hbox_layout); - vbox_layout->addWidget (_history_list_view); - vbox_layout->setMargin (2); + _filter_widget = new QWidget (this); + QHBoxLayout *filter_layout = new QHBoxLayout (); + filter_layout->addWidget (filter_label); + filter_layout->addWidget (_filter_checkbox); + filter_layout->addWidget (_filter); + filter_layout->setMargin(0); + _filter_widget->setLayout (filter_layout); - widget ()->setLayout (vbox_layout); + QVBoxLayout *hist_layout = new QVBoxLayout (); + hist_layout->addWidget (_filter_widget); + hist_layout->addWidget (_history_list_view); + + hist_layout->setMargin (2); + widget ()->setLayout (hist_layout); setFocusProxy (_filter->lineEdit ()); // Init state of the filter QSettings *settings = resource_manager::get_settings (); + + _filter_shown = settings->value ("history_dock_widget/filter_shown",true).toBool(); + _filter_widget->setVisible (_filter_shown); + _filter->addItems (settings->value ("history_dock_widget/mru_list").toStringList ()); bool filter_state = @@ -142,6 +150,7 @@ settings->setValue ("history_dock_widget/filter_active", _filter_checkbox->isChecked ()); + settings->setValue ("history_dock_widget/filter_shown", _filter_shown); QStringList mru; for (int i = 0; i < _filter->count (); i++) @@ -191,8 +200,15 @@ menu.addAction (resource_manager::icon ("document-new"), tr ("Create script"), this, SLOT (handle_contextmenu_create_script (bool))); - menu.exec (_history_list_view->mapToGlobal (xpos)); } + if (_filter_shown) + menu.addAction (tr ("Hide filter"), this, + SLOT (handle_contextmenu_filter ())); + else + menu.addAction (tr ("Show filter"), this, + SLOT (handle_contextmenu_filter ())); + + menu.exec (_history_list_view->mapToGlobal (xpos)); } void history_dock_widget::handle_contextmenu_copy (bool) @@ -250,6 +266,12 @@ emit command_create_script (text); } +void +history_dock_widget::handle_contextmenu_filter (void) +{ + _filter_shown = not _filter_shown; + _filter_widget->setVisible (_filter_shown); +} void history_dock_widget::handle_double_click (QModelIndex modelIndex)