comparison 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
comparison
equal deleted inserted replaced
20603:f61c67865d9f 20605:734d446560a8
92 92
93 setWindowIcon (QIcon (":/actions/icons/logo.png")); 93 setWindowIcon (QIcon (":/actions/icons/logo.png"));
94 set_title (tr ("Command History")); 94 set_title (tr ("Command History"));
95 setWidget (new QWidget ()); 95 setWidget (new QWidget ());
96 96
97 QVBoxLayout *vbox_layout = new QVBoxLayout (); 97 _filter_widget = new QWidget (this);
98 QHBoxLayout *hbox_layout = new QHBoxLayout (); 98 QHBoxLayout *filter_layout = new QHBoxLayout ();
99 hbox_layout->addWidget (filter_label); 99 filter_layout->addWidget (filter_label);
100 hbox_layout->addWidget (_filter_checkbox); 100 filter_layout->addWidget (_filter_checkbox);
101 hbox_layout->addWidget (_filter); 101 filter_layout->addWidget (_filter);
102 vbox_layout->addLayout (hbox_layout); 102 filter_layout->setMargin(0);
103 vbox_layout->addWidget (_history_list_view); 103 _filter_widget->setLayout (filter_layout);
104 vbox_layout->setMargin (2); 104
105 105 QVBoxLayout *hist_layout = new QVBoxLayout ();
106 widget ()->setLayout (vbox_layout); 106 hist_layout->addWidget (_filter_widget);
107 hist_layout->addWidget (_history_list_view);
108
109 hist_layout->setMargin (2);
110 widget ()->setLayout (hist_layout);
107 111
108 setFocusProxy (_filter->lineEdit ()); 112 setFocusProxy (_filter->lineEdit ());
109 113
110 // Init state of the filter 114 // Init state of the filter
111 QSettings *settings = resource_manager::get_settings (); 115 QSettings *settings = resource_manager::get_settings ();
116
117 _filter_shown = settings->value ("history_dock_widget/filter_shown",true).toBool();
118 _filter_widget->setVisible (_filter_shown);
119
112 _filter->addItems (settings->value ("history_dock_widget/mru_list").toStringList ()); 120 _filter->addItems (settings->value ("history_dock_widget/mru_list").toStringList ());
113 121
114 bool filter_state = 122 bool filter_state =
115 settings->value ("history_dock_widget/filter_active", false).toBool (); 123 settings->value ("history_dock_widget/filter_active", false).toBool ();
116 _filter_checkbox->setChecked (filter_state); 124 _filter_checkbox->setChecked (filter_state);
140 { 148 {
141 QSettings *settings = resource_manager::get_settings (); 149 QSettings *settings = resource_manager::get_settings ();
142 150
143 settings->setValue ("history_dock_widget/filter_active", 151 settings->setValue ("history_dock_widget/filter_active",
144 _filter_checkbox->isChecked ()); 152 _filter_checkbox->isChecked ());
153 settings->setValue ("history_dock_widget/filter_shown", _filter_shown);
145 154
146 QStringList mru; 155 QStringList mru;
147 for (int i = 0; i < _filter->count (); i++) 156 for (int i = 0; i < _filter->count (); i++)
148 mru.append (_filter->itemText (i)); 157 mru.append (_filter->itemText (i));
149 settings->setValue ("history_dock_widget/mru_list", mru); 158 settings->setValue ("history_dock_widget/mru_list", mru);
189 menu.addAction (tr ("Evaluate"), this, 198 menu.addAction (tr ("Evaluate"), this,
190 SLOT (handle_contextmenu_evaluate (bool))); 199 SLOT (handle_contextmenu_evaluate (bool)));
191 menu.addAction (resource_manager::icon ("document-new"), 200 menu.addAction (resource_manager::icon ("document-new"),
192 tr ("Create script"), this, 201 tr ("Create script"), this,
193 SLOT (handle_contextmenu_create_script (bool))); 202 SLOT (handle_contextmenu_create_script (bool)));
194 menu.exec (_history_list_view->mapToGlobal (xpos)); 203 }
195 } 204 if (_filter_shown)
205 menu.addAction (tr ("Hide filter"), this,
206 SLOT (handle_contextmenu_filter ()));
207 else
208 menu.addAction (tr ("Show filter"), this,
209 SLOT (handle_contextmenu_filter ()));
210
211 menu.exec (_history_list_view->mapToGlobal (xpos));
196 } 212 }
197 213
198 void history_dock_widget::handle_contextmenu_copy (bool) 214 void history_dock_widget::handle_contextmenu_copy (bool)
199 { 215 {
200 QString text; 216 QString text;
248 264
249 if (text.length () > 0) 265 if (text.length () > 0)
250 emit command_create_script (text); 266 emit command_create_script (text);
251 } 267 }
252 268
269 void
270 history_dock_widget::handle_contextmenu_filter (void)
271 {
272 _filter_shown = not _filter_shown;
273 _filter_widget->setVisible (_filter_shown);
274 }
253 275
254 void 276 void
255 history_dock_widget::handle_double_click (QModelIndex modelIndex) 277 history_dock_widget::handle_double_click (QModelIndex modelIndex)
256 { 278 {
257 emit command_double_clicked (modelIndex.data ().toString ()); 279 emit command_double_clicked (modelIndex.data ().toString ());