GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
settings-dialog.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2011-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 // Programming Note: this file has many lines longer than 80 characters
27 // due to long function, variable, and property names. Please don't
28 // break those lines as it tends to make this code even harder to read.
29 
30 #if defined (HAVE_CONFIG_H)
31 # include "config.h"
32 #endif
33 
34 #include <QButtonGroup>
35 #include <QDir>
36 #include <QFileDialog>
37 #include <QFileInfo>
38 #include <QHash>
39 #include <QMessageBox>
40 #include <QScrollBar>
41 #include <QStyleFactory>
42 #include <QTextCodec>
43 #include <QVector>
44 
45 #if defined (HAVE_QSCINTILLA)
46 # include "octave-qscintilla.h"
47 # include "octave-txt-lexer.h"
48 # include <QScrollArea>
49 
50 # if defined (HAVE_QSCI_QSCILEXEROCTAVE_H)
51 # define HAVE_LEXER_OCTAVE 1
52 # include <Qsci/qscilexeroctave.h>
53 # elif defined (HAVE_QSCI_QSCILEXERMATLAB_H)
54 # define HAVE_LEXER_MATLAB 1
55 # include <Qsci/qscilexermatlab.h>
56 # endif
57 
58 # include <Qsci/qscilexercpp.h>
59 # include <Qsci/qscilexerbash.h>
60 # include <Qsci/qscilexerperl.h>
61 # include <Qsci/qscilexerbatch.h>
62 # include <Qsci/qscilexerdiff.h>
63 #endif
64 
65 #include "gui-preferences-all.h"
66 #include "octave-qobject.h"
67 #include "settings-dialog.h"
68 #include "variable-editor.h"
69 #include "workspace-model.h"
70 
71 namespace octave
72 {
73 #if defined (HAVE_QSCINTILLA)
74 
75  static const int MaxLexerStyles = 64;
76  static const int MaxStyleNumber = 128;
77 
78  static int get_valid_lexer_styles (QsciLexer *lexer, int *styles)
79  {
80  int max_style = 0;
81  int actual_style = 0;
82  while (actual_style < MaxStyleNumber && max_style < MaxLexerStyles)
83  {
84  if ((lexer->description (actual_style)) != "") // valid style
85  styles[max_style++] = actual_style;
86  actual_style++;
87  }
88  return max_style;
89  }
90 
91 #endif
92 
94  const QString& desired_tab)
95  : QDialog (p), Ui::settings_dialog (), m_octave_qobj (oct_qobj)
96  {
97  setupUi (this);
98 
101 
102  if (! settings)
103  {
104  QMessageBox msgBox
105  (QMessageBox::Warning, tr ("Octave Preferences"),
106  tr ("Unable to save preferences. Missing preferences file or unknown directory."));
107 
108  msgBox.exec ();
109 
110  return;
111  }
112 
113  // look for available language files and the actual settings
114  QString qm_dir_name = rmgr.get_gui_translation_dir ();
115  QDir qm_dir (qm_dir_name);
116  QFileInfoList qm_files = qm_dir.entryInfoList (QStringList ("*.qm"),
117  QDir::Files | QDir::Readable, QDir::Name);
118 
119  for (int i = 0; i < qm_files.length (); i++) // insert available languages
120  comboBox_language->addItem (qm_files.at (i).baseName ());
121  // System at beginning
122  comboBox_language->insertItem (0, tr ("System setting"));
123  comboBox_language->insertSeparator (1); // separator after System
124  QString language = settings->value (global_language.key,
125  global_language.def).toString ();
126  if (language == global_language.def.toString ())
127  language = tr ("System setting");
128  int selected = comboBox_language->findText (language);
129  if (selected >= 0)
130  comboBox_language->setCurrentIndex (selected);
131  else
132  comboBox_language->setCurrentIndex (0); // System is default
133 
134  // Global style
135  QStringList styles = QStyleFactory::keys();
136  combo_styles->addItems (styles);
137  combo_styles->insertItem (0, global_style.def.toString ());
138  combo_styles->insertSeparator (1);
139  QString current_style = settings->value (global_style).toString ();
140  if (current_style == global_style.def.toString ())
141  current_style = global_style.def.toString ();
142  selected = combo_styles->findText (current_style);
143  if (selected >= 0)
144  combo_styles->setCurrentIndex (selected);
145  else
146  combo_styles->setCurrentIndex (0);
147 
148  // icon size and theme
149  QButtonGroup *icon_size_group = new QButtonGroup (this);
150  icon_size_group->addButton (icon_size_small);
151  icon_size_group->addButton (icon_size_normal);
152  icon_size_group->addButton (icon_size_large);
153  int icon_size = settings->value (global_icon_size).toInt ();
154  icon_size_normal->setChecked (true); // the default
155  icon_size_small->setChecked (icon_size < 0);
156  icon_size_large->setChecked (icon_size > 0);
157  cb_system_icon_theme->setChecked (settings->value (global_icon_theme).toBool ());
158 
159  // which icon has to be selected
160  QButtonGroup *icon_group = new QButtonGroup (this);
161  icon_group->addButton (general_icon_octave);
162  icon_group->addButton (general_icon_graphic);
163  icon_group->addButton (general_icon_letter);
164  QString widget_icon_set =
165  settings->value (dw_icon_set).toString ();
166  general_icon_octave->setChecked (true); // the default (if invalid set)
167  general_icon_octave->setChecked (widget_icon_set == "NONE");
168  general_icon_graphic->setChecked (widget_icon_set == "GRAPHIC");
169  general_icon_letter->setChecked (widget_icon_set == "LETTER");
170 
171  // custom title bar of dock widget
172  QColor bg_color = settings->value (dw_title_bg_color).value<QColor> ();
173  m_widget_title_bg_color = new color_picker (bg_color);
174  m_widget_title_bg_color->setEnabled (false);
175  layout_widget_bgtitle->addWidget (m_widget_title_bg_color, 0);
176 
177  connect (cb_widget_custom_style, SIGNAL (toggled (bool)),
178  m_widget_title_bg_color, SLOT (setEnabled (bool)));
179 
180  QColor bg_color_active = settings->value (dw_title_bg_color_active).value<QColor> ();
181  m_widget_title_bg_color_active = new color_picker (bg_color_active);
182  m_widget_title_bg_color_active->setEnabled (false);
183  layout_widget_bgtitle_active->addWidget (m_widget_title_bg_color_active, 0);
184 
185  connect (cb_widget_custom_style, SIGNAL (toggled (bool)),
186  m_widget_title_bg_color_active, SLOT (setEnabled (bool)));
187 
188  QColor fg_color = settings->value (dw_title_fg_color).value<QColor> ();
189  m_widget_title_fg_color = new color_picker (fg_color);
190  m_widget_title_fg_color->setEnabled (false);
191  layout_widget_fgtitle->addWidget (m_widget_title_fg_color, 0);
192 
193  connect (cb_widget_custom_style, SIGNAL (toggled (bool)),
194  m_widget_title_fg_color, SLOT (setEnabled (bool)));
195 
196  QColor fg_color_active = settings->value (dw_title_fg_color_active).value<QColor> ();
197  m_widget_title_fg_color_active = new color_picker (fg_color_active);
198  m_widget_title_fg_color_active->setEnabled (false);
199  layout_widget_fgtitle_active->addWidget (m_widget_title_fg_color_active, 0);
200 
201  connect (cb_widget_custom_style, SIGNAL (toggled (bool)),
202  m_widget_title_fg_color_active, SLOT (setEnabled (bool)));
203 
204  sb_3d_title->setValue (settings->value (dw_title_3d.key,
205  dw_title_3d.def).toInt ());
206  cb_widget_custom_style->setChecked (settings->value (dw_title_custom_style).toBool ());
207 
208  // Native file dialogs.
209  // FIXME: This preference can be deprecated / removed if all display
210  // managers, especially KDE, run those dialogs without hangs or
211  // delays from the start (bug #54607).
212  cb_use_native_file_dialogs->setChecked (settings->value (global_use_native_dialogs).toBool ());
213 
214  // Cursor blinking: consider old terminal related setting if not yet set
215  // FIXME: This pref. can be deprecated / removed if Qt adds support for
216  // getting the cursor blink preferences from all OS environments
217  if (settings->contains (global_cursor_blinking.key))
218  {
219  // Preference exists, read its value
220  cb_cursor_blinking->setChecked (settings->value
222  }
223  else
224  {
225  // Pref. does not exist, so take old terminal related pref.
226  cb_cursor_blinking->setChecked (settings->value
228  }
229 
230  // prompt on exit
231  cb_prompt_to_exit->setChecked (
233 
234  // Main status bar
235  cb_status_bar->setChecked (
236  settings->value (global_status_bar.key, global_status_bar.def).toBool ());
237 
238  // Octave startup
239  cb_restore_octave_dir->setChecked (
241  le_octave_dir->setText (settings->value (global_ov_startup_dir.key,
242  global_ov_startup_dir.def).toString ());
243 
244  connect (pb_octave_dir, SIGNAL (pressed (void)),
245  this, SLOT (get_octave_dir (void)));
246 
247  //
248  // editor
249  //
250  useCustomFileEditor->setChecked (
252  customFileEditor->setText (
254  editor_showLineNumbers->setChecked (settings->value (ed_show_line_numbers).toBool ());
255  editor_linenr_size->setValue (settings->value (ed_line_numbers_size).toInt ());
256 
257  rmgr.combo_encoding (editor_combo_encoding);
258 
259  QColor setting_color = settings->value (ed_highlight_current_line_color).value<QColor> ();
260  m_editor_current_line_color = new color_picker (setting_color);
261  editor_grid_current_line->addWidget (m_editor_current_line_color, 0, 3);
262  m_editor_current_line_color->setMinimumSize (20, 10);
263  m_editor_current_line_color->setEnabled (false);
264 
265  connect (editor_highlightCurrentLine, SIGNAL (toggled (bool)),
266  m_editor_current_line_color, SLOT (setEnabled (bool)));
267 
268  editor_highlightCurrentLine->setChecked (settings->value (ed_highlight_current_line).toBool ());
269  editor_long_line_marker->setChecked (settings->value (ed_long_line_marker).toBool ());
270  bool long_line =
271  settings->value (ed_long_line_marker_line).toBool ();
272  editor_long_line_marker_line->setChecked (long_line);
273  bool long_back =
274  settings->value (ed_long_line_marker_background).toBool ();
275  editor_long_line_marker_background->setChecked (long_back);
276  if (! (long_line || long_back))
277  editor_long_line_marker_line->setChecked (true);
278  editor_long_line_column->setValue (settings->value (ed_long_line_column).toInt ());
279  editor_break_checkbox->setChecked (settings->value (ed_break_lines).toBool ());
280  editor_break_comments_checkbox->setChecked (settings->value (ed_break_lines_comments).toBool ());
281  editor_wrap_checkbox->setChecked (settings->value (ed_wrap_lines).toBool ());
282  cb_edit_status_bar->setChecked (settings->value (ed_show_edit_status_bar).toBool ());
283  cb_edit_tool_bar->setChecked (settings->value (ed_show_toolbar).toBool ());
284  cb_code_folding->setChecked (settings->value (ed_code_folding).toBool ());
285  editor_highlight_all_occurrences->setChecked (settings->value (ed_highlight_all_occurrences).toBool ());
286 
287  editor_auto_endif->setCurrentIndex (settings->value (ed_auto_endif).toInt () );
288  editor_codeCompletion->setChecked (settings->value (ed_code_completion).toBool ());
289  editor_spinbox_ac_threshold->setValue (settings->value (ed_code_completion_threshold).toInt ());
290  editor_checkbox_ac_keywords->setChecked (settings->value (ed_code_completion_keywords).toBool ());
291  editor_checkbox_ac_builtins->setEnabled (editor_checkbox_ac_keywords->isChecked ());
292  editor_checkbox_ac_functions->setEnabled (editor_checkbox_ac_keywords->isChecked ());
293  editor_checkbox_ac_builtins->setChecked (settings->value (ed_code_completion_octave_builtins).toBool ());
294  editor_checkbox_ac_functions->setChecked (settings->value (ed_code_completion_octave_functions).toBool ());
295  editor_checkbox_ac_document->setChecked (settings->value (ed_code_completion_document).toBool ());
296  editor_checkbox_ac_case->setChecked (settings->value (ed_code_completion_case).toBool ());
297  editor_checkbox_ac_replace->setChecked (settings->value (ed_code_completion_replace).toBool ());
298  editor_ws_checkbox->setChecked (settings->value (ed_show_white_space).toBool ());
299  editor_ws_indent_checkbox->setChecked (settings->value (ed_show_white_space_indent).toBool ());
300  cb_show_eol->setChecked (settings->value (ed_show_eol_chars).toBool ());
301  cb_show_hscrollbar->setChecked (settings->value (ed_show_hscroll_bar).toBool ());
302 
303  for (int i = 0; i < ed_tab_position_names.length (); i++)
304  editor_combox_tab_pos->insertItem (i,
305  tr (ed_tab_position_names.at (i).toStdString ().data ()));
306  editor_combox_tab_pos->setCurrentIndex
307  (settings->value (ed_tab_position).toInt ());
308 
309  int selected_comment_string, selected_uncomment_string;
310 
311  if (settings->contains (ed_comment_str.key)) // new version (radio buttons)
312  selected_comment_string = settings->value (ed_comment_str).toInt ();
313  else // old version (combo box)
314  selected_comment_string = settings->value (ed_comment_str_old.key, ed_comment_str.def).toInt ();
315 
316  selected_uncomment_string = settings->value (ed_uncomment_str).toInt ();
317 
318  for (int i = 0; i < ed_comment_strings_count; i++)
319  {
320  m_rb_comment_strings[i] = new QRadioButton ();
321  m_rb_uncomment_strings[i] = new QCheckBox ();
322 
323  connect (m_rb_comment_strings[i], SIGNAL (clicked (bool)),
324  m_rb_uncomment_strings[i], SLOT (setChecked (bool)));
325  connect (m_rb_comment_strings[i], SIGNAL (toggled (bool)),
326  m_rb_uncomment_strings[i], SLOT (setDisabled (bool)));
327 
328  m_rb_comment_strings[i]->setText (ed_comment_strings.at(i));
329  m_rb_comment_strings[i]->setChecked (i == selected_comment_string);
330  layout_comment_strings->addWidget (m_rb_comment_strings[i]);
331 
332  m_rb_uncomment_strings[i]->setText (ed_comment_strings.at(i));
333  m_rb_uncomment_strings[i]->setAutoExclusive (false);
334  m_rb_uncomment_strings[i]->setChecked ( 1 << i & selected_uncomment_string);
335  layout_uncomment_strings->addWidget (m_rb_uncomment_strings[i]);
336  }
337 
338 
339  combo_eol_mode->setCurrentIndex (settings->value (ed_default_eol_mode).toInt ());
340  editor_auto_ind_checkbox->setChecked (settings->value (ed_auto_indent).toBool ());
341  editor_tab_ind_checkbox->setChecked (settings->value (ed_tab_indents_line).toBool ());
342  editor_bs_unind_checkbox->setChecked (settings->value (ed_backspace_unindents_line).toBool ());
343  editor_ind_guides_checkbox->setChecked (settings->value (ed_show_indent_guides).toBool ());
344  editor_ind_width_spinbox->setValue (settings->value (ed_indent_width).toInt ());
345  editor_ind_uses_tabs_checkbox->setChecked (settings->value (ed_indent_uses_tabs).toBool ());
346  editor_tab_width_spinbox->setValue (settings->value (ed_tab_width).toInt ());
347  editor_longWindowTitle->setChecked (settings->value (ed_long_window_title).toBool ());
348  editor_notebook_tab_width_min->setValue (settings->value (ed_notebook_tab_width_min).toInt ());
349  editor_notebook_tab_width_max->setValue (settings->value (ed_notebook_tab_width_max).toInt ());
350  editor_restoreSession->setChecked (settings->value (ed_restore_session).toBool ());
351  editor_create_new_file->setChecked (settings->value (ed_create_new_file).toBool ());
352  editor_reload_changed_files->setChecked (settings->value (ed_always_reload_changed_files).toBool ());
353  editor_hiding_closes_files->setChecked (settings->value (ed_hiding_closes_files).toBool ());
354  editor_show_dbg_file->setChecked (settings->value (ed_show_dbg_file).toBool ());
355 
356  // terminal
357  QString default_font = settings->value (global_mono_font).toString ();
358  terminal_fontName->setCurrentFont (QFont (settings->value (cs_font.key, default_font).toString ()));
359  terminal_fontSize->setValue (settings->value (cs_font_size).toInt ());
360  terminal_history_buffer->setValue (settings->value (cs_hist_buffer).toInt ());
361  terminal_cursorUseForegroundColor->setChecked (settings->value (cs_cursor_use_fgcol).toBool ());
362  terminal_focus_command->setChecked (settings->value (cs_focus_cmd).toBool ());
363  terminal_print_dbg_location->setChecked (settings->value (cs_dbg_location).toBool ());
364 
365  QString cursor_type
366  = settings->value (cs_cursor).toString ();
367 
368  QStringList items;
369  items << QString ("0") << QString ("1") << QString ("2");
370  terminal_cursorType->addItems (items);
371  terminal_cursorType->setItemText (0, tr ("IBeam Cursor"));
372  terminal_cursorType->setItemText (1, tr ("Block Cursor"));
373  terminal_cursorType->setItemText (2, tr ("Underline Cursor"));
374 
375  for (unsigned int i = 0; i < cs_cursor_types.size (); i++)
376  {
377  if (cursor_type.toStdString () == cs_cursor_types[i])
378  {
379  terminal_cursorType->setCurrentIndex (i);
380  break;
381  }
382  }
383 
384  // file browser
385  connect (sync_octave_directory, SIGNAL (toggled (bool)),
386  this, SLOT (set_disabled_pref_file_browser_dir (bool)));
387 
388  sync_octave_directory->setChecked (settings->value (fb_sync_octdir).toBool ());
389  cb_restore_file_browser_dir->setChecked (settings->value (fb_restore_last_dir).toBool ());
390  le_file_browser_dir->setText (settings->value (fb_startup_dir.key).toString ());
391 
392  connect (pb_file_browser_dir, SIGNAL (pressed (void)),
393  this, SLOT (get_file_browser_dir (void)));
394 
395  le_file_browser_extensions->setText (settings->value (fb_txt_file_ext).toString ());
396 
397  checkbox_allow_web_connect->setChecked (settings->value (nr_allow_connection).toBool ());
398  useProxyServer->setChecked (
399  settings->value (global_use_proxy.key, global_use_proxy.def).toBool ());
400  proxyHostName->setText (settings->value (global_proxy_host.key, global_proxy_host.def).toString ());
401 
402  int currentIndex = 0;
403  QString proxyTypeString = settings->value (global_proxy_type.key, global_proxy_type.def).toString ();
404  while ((currentIndex < proxyType->count ())
405  && (proxyType->currentText () != proxyTypeString))
406  {
407  currentIndex++;
408  proxyType->setCurrentIndex (currentIndex);
409  }
410  proxyPort->setText (settings->value (global_proxy_port.key, global_proxy_port.def).toString ());
411  proxyUserName->setText (settings->value (global_proxy_user.key, global_proxy_user.def).toString ());
412  proxyPassword->setText (settings->value (global_proxy_pass.key, global_proxy_pass.def).toString ());
413 
414  // Workspace
416 
417  // terminal colors
419 
420  // variable editor
421  varedit_columnWidth->setValue (settings->value (ve_column_width).toInt ());
422  varedit_rowHeight->setValue (settings->value (ve_row_height).toInt ());
423 
424  varedit_font->setCurrentFont (QFont (settings->value (ve_font_name.key,
425  settings->value (cs_font.key, default_font)).toString ()));
426  varedit_fontSize->setValue (settings->value (ve_font_size).toInt ());
427  connect (varedit_useTerminalFont, SIGNAL (toggled (bool)),
428  varedit_font, SLOT (setDisabled (bool)));
429  connect (varedit_useTerminalFont, SIGNAL (toggled (bool)),
430  varedit_fontSize, SLOT (setDisabled (bool)));
431  varedit_useTerminalFont->setChecked (settings->value (ve_use_terminal_font).toBool ());
432  varedit_font->setDisabled (varedit_useTerminalFont->isChecked ());
433  varedit_fontSize->setDisabled (varedit_useTerminalFont->isChecked ());
434 
435  varedit_alternate->setChecked (settings->value (ve_alternate_rows).toBool ());
436 
437  // variable editor colors
439 
440  // shortcuts
441 
443 
444  cb_prevent_readline_conflicts->setChecked (
446  sc_prevent_rl_conflicts.def).toBool ());
447 
448  // initialize the tree view with all shortcut data
449  scmgr.fill_treewidget (shortcuts_treewidget);
450 
451  // connect the buttons for import/export of the shortcut sets
452  connect (btn_import_shortcut_set, SIGNAL (clicked (void)),
453  this, SLOT (import_shortcut_set (void)));
454 
455  connect (btn_export_shortcut_set, SIGNAL (clicked (void)),
456  this, SLOT (export_shortcut_set (void)));
457 
458  connect (btn_default_shortcut_set, SIGNAL (clicked (void)),
459  this, SLOT (default_shortcut_set (void)));
460 
461 #if defined (HAVE_QSCINTILLA)
462 
463  // editor styles: create lexer, read settings, and create dialog elements
464  QsciLexer *lexer;
465 
466 #if defined (HAVE_LEXER_OCTAVE)
467 
468  lexer = new QsciLexerOctave ();
470  delete lexer;
471 
472 #elif defined (HAVE_LEXER_MATLAB)
473 
474  lexer = new QsciLexerMatlab ();
476  delete lexer;
477 
478 #endif
479 
480  lexer = new QsciLexerCPP ();
482  delete lexer;
483 
484  lexer = new QsciLexerPerl ();
486  delete lexer;
487 
488  lexer = new QsciLexerBatch ();
490  delete lexer;
491 
492  lexer = new QsciLexerDiff ();
494  delete lexer;
495 
496  lexer = new QsciLexerBash ();
498  delete lexer;
499 
500  lexer = new octave_txt_lexer ();
502  delete lexer;
503 
504 #endif
505 
506  // which tab is the desired one?
507  show_tab (desired_tab);
508 
509  // connect button box signal
510  connect (button_box, SIGNAL (clicked (QAbstractButton *)),
511  this, SLOT (button_clicked (QAbstractButton *)));
512 
513  // restore last geometry
514  if (settings->contains (sd_geometry.key))
515  restoreGeometry (settings->value (sd_geometry).toByteArray ());
516  else
517  setGeometry (QRect (10,50,1000,600));
518  }
519 
520  void settings_dialog::show_tab (const QString& tab)
521  {
522  if (tab.isEmpty ())
523  {
526  if (settings)
527  tabWidget->setCurrentIndex (settings->value (sd_last_tab).toInt ());
528  }
529  else
530  {
531  QHash <QString, QWidget*> tab_hash;
532  tab_hash["editor"] = tab_editor;
533  tab_hash["editor_styles"] = tab_editor;
534  tabWidget->setCurrentIndex (tabWidget->indexOf (tab_hash.value (tab)));
535  if (tab == "editor_styles")
536  tab_editor_scroll_area->ensureWidgetVisible (group_box_editor_styles);
537  }
538  }
539 
541  {
542  get_dir (le_octave_dir, tr ("Set Octave Startup Directory"));
543  }
544 
546  {
547  get_dir (le_file_browser_dir, tr ("Set File Browser Startup Directory"));
548  }
549 
550  void settings_dialog::get_dir (QLineEdit *line_edit, const QString& title)
551  {
552  // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved.
553  int opts = QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks;
556  if (! settings->value (global_use_native_dialogs).toBool ())
557  opts |= QFileDialog::DontUseNativeDialog;
558 
559  QString dir = QFileDialog::getExistingDirectory
560  (this, title, line_edit->text (), QFileDialog::Option (opts));
561 
562  line_edit->setText (dir);
563  }
564 
565  void settings_dialog::button_clicked (QAbstractButton *button)
566  {
567  QDialogButtonBox::ButtonRole button_role = button_box->buttonRole (button);
568 
569  if (button_role == QDialogButtonBox::ApplyRole
570  || button_role == QDialogButtonBox::AcceptRole)
571  {
572  write_changed_settings (button_role == QDialogButtonBox::AcceptRole);
573  emit apply_new_settings ();
574  }
575 
576  if (button_role == QDialogButtonBox::RejectRole
577  || button_role == QDialogButtonBox::AcceptRole)
578  close ();
579  }
580 
582  {
583  cb_restore_file_browser_dir->setDisabled (disable);
584 
585  if (! disable)
586  {
587  le_file_browser_dir->setDisabled (cb_restore_file_browser_dir->isChecked ());
588  pb_file_browser_dir->setDisabled (cb_restore_file_browser_dir->isChecked ());
589  }
590  else
591  {
592  le_file_browser_dir->setDisabled (disable);
593  pb_file_browser_dir->setDisabled (disable);
594  }
595  }
596 
597  // slots for import/export of shortcut sets
598 
600  {
602 
604  }
605 
607  {
609 
611  }
612 
614  {
616 
618  }
619 
622  {
623 #if defined (HAVE_QSCINTILLA)
624 
625  lexer->readSettings (*settings);
626  int styles[MaxLexerStyles]; // array for saving valid styles
627  // (enum is not continuous)
628  int max_style = get_valid_lexer_styles (lexer, styles);
629  QGridLayout *style_grid = new QGridLayout ();
630  QVector<QLabel*> description (max_style);
631  QVector<QFontComboBox*> select_font (max_style);
632  QVector<QSpinBox*> font_size (max_style);
633  QVector<QCheckBox*> attrib_font (3 * max_style);
634  QVector<color_picker*> color (max_style);
635  QVector<color_picker*> bg_color (max_style);
636  int default_size = 10;
637  QFont default_font = QFont ();
638  int label_width;
639  QColor default_color = QColor ();
640  QColor dummy_color = QColor (255, 0, 255);
641 
642  for (int i = 0; i < max_style; i++) // create dialog elements for all styles
643  {
644  QString actual_name = lexer->description (styles[i]);
645  QFont actual_font = lexer->font (styles[i]);
646  description[i] = new QLabel (actual_name);
647  description[i]->setWordWrap (true);
648  label_width = 24*description[i]->fontMetrics ().averageCharWidth ();
649  description[i]->setMaximumSize (label_width, QWIDGETSIZE_MAX);
650  description[i]->setMinimumSize (label_width, 1);
651  select_font[i] = new QFontComboBox ();
652  select_font[i]->setObjectName (actual_name + "_font");
653  select_font[i]->setMaximumSize (label_width, QWIDGETSIZE_MAX);
654  select_font[i]->setMinimumSize (label_width, 1);
655  font_size[i] = new QSpinBox ();
656  font_size[i]->setObjectName (actual_name + "_size");
657  if (styles[i] == 0) // the default
658  {
659  select_font[i]->setCurrentFont (actual_font);
660  default_font = actual_font;
661  font_size[i]->setRange (6, 24);
662  default_size = actual_font.pointSize ();
663  font_size[i]->setValue (default_size);
664  default_color = lexer->defaultPaper ();
665  bg_color[i] = new color_picker (default_color);
666  }
667  else // other styles
668  {
669  select_font[i]->setCurrentFont (actual_font);
670  if (actual_font.family () == default_font.family ())
671  select_font[i]->setEditText (lexer->description (0));
672  font_size[i]->setRange (-4, 4);
673  font_size[i]->setValue (actual_font.pointSize ()-default_size);
674  font_size[i]->setToolTip (QObject::tr ("Difference to the default size"));
675  if (lexer->paper (styles[i]) == default_color)
676  bg_color[i] = new color_picker (dummy_color);
677  else
678  bg_color[i] = new color_picker (lexer->paper (styles[i]));
679  bg_color[i]->setToolTip
680  (QObject::tr ("Background color, pink (255, 0, 255) means default"));
681  }
682  attrib_font[0+3*i] = new QCheckBox (QObject::tr ("b", "short form for bold"));
683  attrib_font[1+3*i] = new QCheckBox (QObject::tr ("i", "short form for italic"));
684  attrib_font[2+3*i] = new QCheckBox (QObject::tr ("u", "short form for underlined"));
685  attrib_font[0+3*i]->setChecked (actual_font.bold ());
686  attrib_font[0+3*i]->setObjectName (actual_name + "_bold");
687  attrib_font[1+3*i]->setChecked (actual_font.italic ());
688  attrib_font[1+3*i]->setObjectName (actual_name + "_italic");
689  attrib_font[2+3*i]->setChecked (actual_font.underline ());
690  attrib_font[2+3*i]->setObjectName (actual_name + "_underline");
691  color[i] = new color_picker (lexer->color (styles[i]));
692  color[i]->setObjectName (actual_name + "_color");
693  bg_color[i]->setObjectName (actual_name + "_bg_color");
694  int column = 1;
695  style_grid->addWidget (description[i], i, column++);
696  style_grid->addWidget (select_font[i], i, column++);
697  style_grid->addWidget (font_size[i], i, column++);
698  style_grid->addWidget (attrib_font[0+3*i], i, column++);
699  style_grid->addWidget (attrib_font[1+3*i], i, column++);
700  style_grid->addWidget (attrib_font[2+3*i], i, column++);
701  style_grid->addWidget (color[i], i, column++);
702  style_grid->addWidget (bg_color[i], i, column++);
703  }
704  // place grid with elements into the tab
705  QScrollArea *scroll_area = new QScrollArea ();
706  QWidget *scroll_area_contents = new QWidget ();
707  scroll_area_contents->setObjectName (QString (lexer->language ()) + "_styles");
708  scroll_area_contents->setLayout (style_grid);
709  scroll_area->setWidget (scroll_area_contents);
710  tabs_editor_lexers->addTab (scroll_area, lexer->language ());
711 
712  tabs_editor_lexers->setCurrentIndex (settings->value (sd_last_editor_styles_tab).toInt ());
713 
714 #else
715 
716  octave_unused_parameter (lexer);
717  octave_unused_parameter (settings);
718 
719 #endif
720  }
721 
724  {
725 #if defined (HAVE_QSCINTILLA)
726 
727  QWidget *tab = tabs_editor_lexers->
728  findChild <QWidget *> (QString (lexer->language ()) + "_styles");
729  int styles[MaxLexerStyles]; // array for saving valid styles
730  // (enum is not continuous)
731  int max_style = get_valid_lexer_styles (lexer, styles);
732  QFontComboBox *select_font;
733  QSpinBox *font_size;
734  QCheckBox *attrib_font[3];
735  color_picker *color;
736  color_picker *bg_color;
737  int default_size = 10;
738 
739  QString default_font_name
740  = settings->value (global_mono_font).toString ();
741  QFont default_font = QFont (default_font_name, 10, -1, 0);
742  QColor default_color = QColor ();
743  QColor dummy_color = QColor (255, 0, 255);
744 
745  for (int i = 0; i < max_style; i++) // get dialog elements and their contents
746  {
747  QString actual_name = lexer->description (styles[i]);
748  select_font = tab->findChild <QFontComboBox *> (actual_name + "_font");
749  font_size = tab->findChild <QSpinBox *> (actual_name + "_size");
750  attrib_font[0] = tab->findChild <QCheckBox *> (actual_name + "_bold");
751  attrib_font[1] = tab->findChild <QCheckBox *> (actual_name + "_italic");
752  attrib_font[2] = tab->findChild <QCheckBox *> (actual_name + "_underline");
753  color = tab->findChild <color_picker *> (actual_name + "_color");
754  bg_color = tab->findChild <color_picker *> (actual_name + "_bg_color");
755  QFont new_font = default_font;
756  if (select_font)
757  {
758  new_font = select_font->currentFont ();
759  if (styles[i] == 0)
760  default_font = new_font;
761  else if (select_font->currentText () == lexer->description (0))
762  new_font = default_font;
763  }
764  if (font_size)
765  {
766  if (styles[i] == 0)
767  {
768  default_size = font_size->value ();
769  new_font.setPointSize (font_size->value ());
770  }
771  else
772  new_font.setPointSize (font_size->value ()+default_size);
773  }
774  if (attrib_font[0])
775  new_font.setBold (attrib_font[0]->isChecked ());
776  if (attrib_font[1])
777  new_font.setItalic (attrib_font[1]->isChecked ());
778  if (attrib_font[2])
779  new_font.setUnderline (attrib_font[2]->isChecked ());
780  lexer->setFont (new_font, styles[i]);
781  if (styles[i] == 0)
782  lexer->setDefaultFont (new_font);
783  if (color)
784  lexer->setColor (color->color (), styles[i]);
785  if (bg_color)
786  {
787  if (styles[i] == 0)
788  {
789  default_color = bg_color->color ();
790  lexer->setPaper (default_color, styles[i]);
791  lexer->setDefaultPaper (default_color);
792  }
793  else
794  {
795  if (bg_color->color () == dummy_color)
796  lexer->setPaper (default_color, styles[i]);
797  else
798  lexer->setPaper (bg_color->color (), styles[i]);
799  }
800  }
801  }
802 
803  lexer->writeSettings (*settings);
804 
806  tabs_editor_lexers->currentIndex ());
807  settings->sync ();
808 
809 #else
810 
811  octave_unused_parameter (lexer);
812  octave_unused_parameter (settings);
813 
814 #endif
815  }
816 
818  {
821 
822  // the icon set
823  QString widget_icon_set = "NONE";
824  if (general_icon_letter->isChecked ())
825  widget_icon_set = "LETTER";
826  else if (general_icon_graphic->isChecked ())
827  widget_icon_set = "GRAPHIC";
828  settings->setValue (dw_icon_set.key, widget_icon_set);
829 
830  // language
831  QString language = comboBox_language->currentText ();
832  if (language == tr ("System setting"))
833  language = global_language.def.toString ();
834  settings->setValue (global_language.key, language);
835 
836  // style
837  QString selected_style = combo_styles->currentText ();
838  if (selected_style == global_style.def.toString ())
839  selected_style = global_style.def.toString ();
840  settings->setValue (global_style.key, selected_style);
841 
842  // dock widget title bar
843  settings->setValue (dw_title_custom_style.key, cb_widget_custom_style->isChecked ());
844  settings->setValue (dw_title_3d.key, sb_3d_title->value ());
849 
850  // icon size and theme
851  int icon_size = icon_size_large->isChecked () - icon_size_small->isChecked ();
852  settings->setValue (global_icon_size.key, icon_size);
853  settings->setValue (global_icon_theme.key, cb_system_icon_theme->isChecked ());
854 
855  // native file dialogs
856  settings->setValue (global_use_native_dialogs.key, cb_use_native_file_dialogs->isChecked ());
857 
858  // cursor blinking
859  settings->setValue (global_cursor_blinking.key, cb_cursor_blinking->isChecked ());
860 
861  // promp to exit
862  settings->setValue (global_prompt_to_exit.key, cb_prompt_to_exit->isChecked ());
863 
864  // status bar
865  settings->setValue (global_status_bar.key, cb_status_bar->isChecked ());
866 
867  // Octave startup
868  settings->setValue (global_restore_ov_dir.key, cb_restore_octave_dir->isChecked ());
869  settings->setValue (global_ov_startup_dir.key, le_octave_dir->text ());
870 
871  //editor
872  settings->setValue (global_use_custom_editor.key, useCustomFileEditor->isChecked ());
873  settings->setValue (global_custom_editor.key, customFileEditor->text ());
874  settings->setValue (ed_show_line_numbers.key, editor_showLineNumbers->isChecked ());
875  settings->setValue (ed_line_numbers_size.key, editor_linenr_size->value ());
876  settings->setValue (ed_highlight_current_line.key, editor_highlightCurrentLine->isChecked ());
878  settings->setValue (ed_long_line_marker.key, editor_long_line_marker->isChecked ());
879  settings->setValue (ed_long_line_marker_line.key, editor_long_line_marker_line->isChecked ());
880  settings->setValue (ed_long_line_marker_background.key, editor_long_line_marker_background->isChecked ());
881  settings->setValue (ed_long_line_column.key, editor_long_line_column->value ());
882  settings->setValue (ed_break_lines.key, editor_break_checkbox->isChecked ());
883  settings->setValue (ed_break_lines_comments.key, editor_break_comments_checkbox->isChecked ());
884  settings->setValue (ed_wrap_lines.key, editor_wrap_checkbox->isChecked ());
885  settings->setValue (ed_code_folding.key, cb_code_folding->isChecked ());
886  settings->setValue (ed_show_edit_status_bar.key, cb_edit_status_bar->isChecked ());
887  settings->setValue (ed_show_toolbar.key, cb_edit_tool_bar->isChecked ());
888  settings->setValue (ed_highlight_all_occurrences.key, editor_highlight_all_occurrences->isChecked ());
889  settings->setValue (ed_code_completion.key, editor_codeCompletion->isChecked ());
890  settings->setValue (ed_code_completion_threshold.key, editor_spinbox_ac_threshold->value ());
891  settings->setValue (ed_code_completion_keywords.key, editor_checkbox_ac_keywords->isChecked ());
892  settings->setValue (ed_code_completion_octave_builtins.key, editor_checkbox_ac_builtins->isChecked ());
893  settings->setValue (ed_code_completion_octave_functions.key, editor_checkbox_ac_functions->isChecked ());
894  settings->setValue (ed_code_completion_document.key, editor_checkbox_ac_document->isChecked ());
895  settings->setValue (ed_code_completion_case.key, editor_checkbox_ac_case->isChecked ());
896  settings->setValue (ed_code_completion_replace.key, editor_checkbox_ac_replace->isChecked ());
897  settings->setValue (ed_auto_endif.key, editor_auto_endif->currentIndex ());
898  settings->setValue (ed_show_white_space.key, editor_ws_checkbox->isChecked ());
899  settings->setValue (ed_show_white_space_indent.key, editor_ws_indent_checkbox->isChecked ());
900  settings->setValue (ed_show_eol_chars.key, cb_show_eol->isChecked ());
901  settings->setValue (ed_show_hscroll_bar.key, cb_show_hscrollbar->isChecked ());
902  settings->setValue (ed_default_eol_mode.key, combo_eol_mode->currentIndex ());
903 
904  settings->setValue (ed_tab_position.key, editor_combox_tab_pos->currentIndex ());
905 
906  // Comment strings
907  int rb_uncomment = 0;
908  for (int i = 0; i < ed_comment_strings_count; i++)
909  {
910  if (m_rb_comment_strings[i]->isChecked ())
911  {
912  settings->setValue (ed_comment_str.key, i);
913  if (i < 3)
914  settings->setValue (ed_comment_str_old.key, i);
915  else
917  }
918  if (m_rb_uncomment_strings[i]->isChecked ())
919  rb_uncomment = rb_uncomment + (1 << i);
920  }
921  settings->setValue (ed_uncomment_str.key, rb_uncomment);
922 
923  settings->setValue (ed_default_enc.key, editor_combo_encoding->currentText ());
924  settings->setValue (ed_auto_indent.key, editor_auto_ind_checkbox->isChecked ());
925  settings->setValue (ed_tab_indents_line.key, editor_tab_ind_checkbox->isChecked ());
926  settings->setValue (ed_backspace_unindents_line.key, editor_bs_unind_checkbox->isChecked ());
927  settings->setValue (ed_show_indent_guides.key, editor_ind_guides_checkbox->isChecked ());
928  settings->setValue (ed_indent_width.key, editor_ind_width_spinbox->value ());
929  settings->setValue (ed_indent_uses_tabs.key, editor_ind_uses_tabs_checkbox->isChecked ());
930  settings->setValue (ed_tab_width.key, editor_tab_width_spinbox->value ());
931  settings->setValue (ed_long_window_title.key, editor_longWindowTitle->isChecked ());
932  settings->setValue (ed_notebook_tab_width_min.key, editor_notebook_tab_width_min->value ());
933  settings->setValue (ed_notebook_tab_width_max.key, editor_notebook_tab_width_max->value ());
934  settings->setValue (ed_restore_session.key, editor_restoreSession->isChecked ());
935  settings->setValue (ed_create_new_file.key, editor_create_new_file->isChecked ());
936  settings->setValue (ed_hiding_closes_files.key, editor_hiding_closes_files->isChecked ());
937  settings->setValue (ed_always_reload_changed_files.key, editor_reload_changed_files->isChecked ());
938  settings->setValue (ed_show_dbg_file.key, editor_show_dbg_file->isChecked ());
939 
940  settings->setValue (cs_font_size.key, terminal_fontSize->value ());
941  settings->setValue (cs_font.key, terminal_fontName->currentFont ().family ());
942 
943  // file browser
944  settings->setValue (fb_sync_octdir.key, sync_octave_directory->isChecked ());
945  settings->setValue (fb_restore_last_dir.key, cb_restore_file_browser_dir->isChecked ());
946  settings->setValue (fb_startup_dir.key, le_file_browser_dir->text ());
947  settings->setValue (fb_txt_file_ext.key, le_file_browser_extensions->text ());
948 
949  settings->setValue (nr_allow_connection.key, checkbox_allow_web_connect->isChecked ());
950  settings->setValue (global_use_proxy.key, useProxyServer->isChecked ());
951  settings->setValue (global_proxy_type.key, proxyType->currentText ());
952  settings->setValue (global_proxy_host.key, proxyHostName->text ());
953  settings->setValue (global_proxy_port.key, proxyPort->text ());
954  settings->setValue (global_proxy_user.key, proxyUserName->text ());
955  settings->setValue (global_proxy_pass.key, proxyPassword->text ());
956  settings->setValue (cs_cursor_use_fgcol.key, terminal_cursorUseForegroundColor->isChecked ());
957  settings->setValue (cs_focus_cmd.key, terminal_focus_command->isChecked ());
958  settings->setValue (cs_dbg_location.key, terminal_print_dbg_location->isChecked ());
959  settings->setValue (cs_hist_buffer.key, terminal_history_buffer->value ());
960 
961  // the cursor
962  QString cursor_type;
963  unsigned int cursor_int = terminal_cursorType->currentIndex ();
964  if ((cursor_int > 0) && (cursor_int < cs_cursor_types.size ()))
965  cursor_type = QString (cs_cursor_types[cursor_int].data ());
966  else
967  cursor_type = cs_cursor.def.toString ();
968 
969  settings->setValue (cs_cursor.key, cursor_type);
970 
971 #if defined (HAVE_QSCINTILLA)
972  // editor styles: create lexer, get dialog contents, and write settings
973  QsciLexer *lexer;
974 
975 #if defined (HAVE_LEXER_OCTAVE)
976 
977  lexer = new QsciLexerOctave ();
979  delete lexer;
980 
981 #elif defined (HAVE_LEXER_MATLAB)
982 
983  lexer = new QsciLexerMatlab ();
985  delete lexer;
986 
987 #endif
988 
989  lexer = new QsciLexerCPP ();
991  delete lexer;
992 
993  lexer = new QsciLexerPerl ();
995  delete lexer;
996 
997  lexer = new QsciLexerBatch ();
999  delete lexer;
1000 
1001  lexer = new QsciLexerDiff ();
1003  delete lexer;
1004 
1005  lexer = new QsciLexerBash ();
1007  delete lexer;
1008 
1009  lexer = new octave_txt_lexer ();
1011  delete lexer;
1012 
1013 #endif
1014 
1015  // Workspace
1017 
1018  // Terminal
1020 
1021  // Variable editor
1022  settings->setValue (ve_column_width.key, varedit_columnWidth->value ());
1023  settings->setValue (ve_row_height.key, varedit_rowHeight->value ());
1024  settings->setValue (ve_use_terminal_font.key, varedit_useTerminalFont->isChecked ());
1025  settings->setValue (ve_alternate_rows.key, varedit_alternate->isChecked ());
1026  settings->setValue (ve_font_name.key, varedit_font->currentFont ().family ());
1027  settings->setValue (ve_font_size.key, varedit_fontSize->value ());
1029 
1030  // shortcuts
1031 
1032  settings->setValue (sc_prevent_rl_conflicts.key, cb_prevent_readline_conflicts->isChecked ());
1034  scmgr.write_shortcuts (settings, closing);
1035 
1036  // settings dialog's geometry
1037  settings->setValue (sd_last_tab.key, tabWidget->currentIndex ());
1038  settings->setValue (sd_geometry.key, saveGeometry ());
1039 
1040  settings->sync ();
1041  }
1042 
1044  {
1045  // Construct the grid with all color related settings
1046  QGridLayout *style_grid = new QGridLayout ();
1047  QVector<QLabel*> description (ws_colors_count);
1048  QVector<color_picker*> color (ws_colors_count);
1049 
1050  int column = 0;
1051  int row = 0;
1052 
1053  m_ws_enable_colors = new QCheckBox (tr ("Enable attribute colors"));
1054  style_grid->addWidget (m_ws_enable_colors, row++, column, 1, 4);
1055 
1056  m_ws_hide_tool_tips = new QCheckBox (tr ("Hide tools tips"));
1057  style_grid->addWidget (m_ws_hide_tool_tips, row++, column, 1, 4);
1058  connect (m_ws_enable_colors, SIGNAL (toggled (bool)),
1059  m_ws_hide_tool_tips, SLOT(setEnabled (bool)));
1060  m_ws_hide_tool_tips->setChecked
1061  (settings->value (ws_hide_tool_tips).toBool ());
1062 
1063  for (int i = 0; i < ws_colors_count; i++)
1064  {
1065  description[i] = new QLabel (" "
1066  + tr (ws_color_names.at (i).toStdString ().data ()));
1067  description[i]->setAlignment (Qt::AlignRight);
1068  connect (m_ws_enable_colors, SIGNAL (toggled (bool)),
1069  description[i], SLOT(setEnabled (bool)));
1070 
1071  QColor setting_color = settings->value (ws_colors[i].key,
1072  ws_colors[i].def).value<QColor> ();
1073  color[i] = new color_picker (setting_color);
1074  color[i]->setObjectName (ws_colors[i].key);
1075  color[i]->setMinimumSize (30, 10);
1076  connect (m_ws_enable_colors, SIGNAL (toggled (bool)),
1077  color[i], SLOT(setEnabled (bool)));
1078 
1079  style_grid->addWidget (description[i], row, 3*column);
1080  style_grid->addWidget (color[i], row, 3*column+1);
1081  if (++column == 3)
1082  {
1083  style_grid->setColumnStretch (4*column, 10);
1084  row++;
1085  column = 0;
1086  }
1087  }
1088 
1089  // Load enable settings at the end for having signals already connected
1090  bool colors_enabled =
1091  settings->value (ws_enable_colors).toBool ();
1092  m_ws_enable_colors->setChecked (colors_enabled);
1093  m_ws_hide_tool_tips->setEnabled (colors_enabled);
1094 
1095  // place grid with elements into the tab
1096  workspace_colors_box->setLayout (style_grid);
1097  }
1098 
1100  {
1101  settings->setValue (ws_enable_colors.key, m_ws_enable_colors->isChecked ());
1102  settings->setValue (ws_hide_tool_tips.key, m_ws_hide_tool_tips->isChecked ());
1103 
1104  color_picker *color;
1105 
1106  for (int i = 0; i < ws_colors_count; i++)
1107  {
1108  color = workspace_colors_box->findChild <color_picker *> (ws_colors[i].key);
1109  if (color)
1110  settings->setValue (ws_colors[i].key, color->color ());
1111  }
1112  settings->sync ();
1113  }
1114 
1116  {
1117  QGridLayout *style_grid = new QGridLayout ();
1118  QVector<QLabel*> description (cs_colors_count);
1119  QVector<color_picker*> color (cs_colors_count);
1120 
1121  int column = 0;
1122  int row = 0;
1123  for (unsigned int i = 0; i < cs_colors_count; i++)
1124  {
1125  description[i] = new QLabel (" "
1126  + tr (cs_color_names.at (i).toStdString ().data ()));
1127  description[i]->setAlignment (Qt::AlignRight);
1128  QVariant default_var = cs_colors[i].def;
1129  QColor setting_color = settings->value (cs_colors[i].key, cs_colors[i].def).value<QColor> ();
1130  color[i] = new color_picker (setting_color);
1131  color[i]->setObjectName (cs_colors[i].key);
1132  color[i]->setMinimumSize (30, 10);
1133  style_grid->addWidget (description[i], row, 2*column);
1134  style_grid->addWidget (color[i], row, 2*column+1);
1135  if (++column == 2)
1136  {
1137  style_grid->setColumnStretch (3*column, 10);
1138  row++;
1139  column = 0;
1140  }
1141  }
1142 
1143  // place grid with elements into the tab
1144  terminal_colors_box->setLayout (style_grid);
1145  }
1146 
1148  {
1149  color_picker *color;
1150 
1151  for (int i = 0; i < cs_color_names.size (); i++)
1152  {
1153  color = terminal_colors_box->findChild <color_picker *> (cs_colors[i].key);
1154  if (color)
1155  settings->setValue (cs_colors[i].key, color->color ());
1156  }
1157 
1158  settings->sync ();
1159  }
1160 
1162  {
1163  QGridLayout *style_grid = new QGridLayout ();
1164  QVector<QLabel*> description (ve_colors_count);
1165  QVector<color_picker*> color (ve_colors_count);
1166 
1167  int column = 0;
1168  int row = 0;
1169  for (int i = 0; i < ve_colors_count; i++)
1170  {
1171  description[i] = new QLabel (" "
1172  + tr (ve_color_names.at (i).toStdString ().data ()));
1173  description[i]->setAlignment (Qt::AlignRight);
1174 
1175  // The default colors are given as color roles for
1176  // the application's palette
1177  QColor default_color = qApp->palette ().color
1178  (static_cast<QPalette::ColorRole> (ve_colors[i].def.toInt ()));
1179  // FIXME: use value<QPalette::ColorRole> instead of static cast after
1180  // dropping support of Qt 5.4
1181 
1182  QColor setting_color =
1183  settings->value (ve_colors[i].key, default_color).value<QColor> ();
1184 
1185  color[i] = new color_picker (setting_color);
1186  color[i]->setObjectName (ve_colors[i].key);
1187  color[i]->setMinimumSize (30, 10);
1188  style_grid->addWidget (description[i], row, 2*column);
1189  style_grid->addWidget (color[i], row, 2*column+1);
1190  if (++column == 2)
1191  {
1192  style_grid->setColumnStretch (3*column, 10);
1193  row++;
1194  column = 0;
1195  }
1196  }
1197 
1198  // place grid with elements into the tab
1199  varedit_colors_box->setLayout (style_grid);
1200  }
1201 
1203  {
1204  color_picker *color;
1205 
1206  for (int i = 0; i < ve_colors_count; i++)
1207  {
1208  color = varedit_colors_box->findChild <color_picker *> (ve_colors[i].key);
1209  if (color)
1210  settings->setValue (ve_colors[i].key, color->color ());
1211  }
1212 
1213  settings->sync ();
1214  }
1215 }
Base class for Octave interfaces that use Qt.
resource_manager & get_resource_manager(void)
shortcut_manager & get_shortcut_manager(void)
QColor color(void) const
Definition: color-picker.h:45
void combo_encoding(QComboBox *combo, const QString &current=QString())
gui_settings * get_settings(void) const
QString get_gui_translation_dir(void)
void write_terminal_colors(gui_settings *settings)
QCheckBox * m_rb_uncomment_strings[ed_comment_strings_count]
void button_clicked(QAbstractButton *button)
void write_lexer_settings(QsciLexer *lexer, gui_settings *settings)
QRadioButton * m_rb_comment_strings[ed_comment_strings_count]
color_picker * m_widget_title_fg_color
void get_dir(QLineEdit *, const QString &)
void write_varedit_colors(gui_settings *settings)
void read_lexer_settings(QsciLexer *lexer, gui_settings *settings)
color_picker * m_widget_title_fg_color_active
color_picker * m_widget_title_bg_color
void read_workspace_colors(gui_settings *settings)
void set_disabled_pref_file_browser_dir(bool disable)
base_qobject & m_octave_qobj
void apply_new_settings(void)
void read_varedit_colors(gui_settings *settings)
color_picker * m_widget_title_bg_color_active
color_picker * m_editor_current_line_color
void write_changed_settings(bool closing)
void read_terminal_colors(gui_settings *settings)
settings_dialog(QWidget *parent, base_qobject &octave_qobj, const QString &desired_tab=QString())
void show_tab(const QString &)
void write_workspace_colors(gui_settings *settings)
bool import_export(int action)
void fill_treewidget(QTreeWidget *tree_view)
void write_shortcuts(gui_settings *settings, bool closing)
const unsigned int cs_colors_count
const gui_pref cs_focus_cmd("terminal/focus_after_command", QVariant(false))
const gui_pref cs_colors[cs_colors_count]
const gui_pref cs_hist_buffer("terminal/history_buffer", QVariant(1000))
const gui_pref cs_font_size("terminal/fontSize", QVariant(10))
const std::vector< std::string > cs_cursor_types
const gui_pref cs_cursor("terminal/cursorType", QVariant("ibeam"))
const gui_pref cs_dbg_location("terminal/print_debug_location", QVariant(false))
const QStringList cs_color_names(QStringList()<< QT_TRANSLATE_NOOP("octave::settings_dialog", "foreground")<< QT_TRANSLATE_NOOP("octave::settings_dialog", "background")<< QT_TRANSLATE_NOOP("octave::settings_dialog", "selection")<< QT_TRANSLATE_NOOP("octave::settings_dialog", "cursor"))
const gui_pref cs_cursor_use_fgcol("terminal/cursorUseForegroundColor", QVariant(true))
const gui_pref cs_font("terminal/fontName", QVariant())
const gui_pref cs_cursor_blinking("terminal/cursorBlinking", QVariant(true))
const gui_pref dw_title_bg_color("DockWidgets/title_bg_color", QVariant(QColor(255, 255, 255)))
const gui_pref dw_title_fg_color("DockWidgets/title_fg_color", QVariant(QColor(0, 0, 0)))
const gui_pref dw_title_3d("DockWidgets/widget_title_3d", QVariant(50))
const gui_pref dw_title_fg_color_active("DockWidgets/title_fg_color_active", QVariant(QColor(0, 0, 0)))
const gui_pref dw_title_bg_color_active("DockWidgets/title_bg_color_active", QVariant(QColor(192, 192, 192)))
const gui_pref dw_title_custom_style("DockWidgets/widget_title_custom_style", QVariant(false))
const gui_pref dw_icon_set("DockWidgets/widget_icon_set", QVariant("NONE"))
const gui_pref ed_always_reload_changed_files("editor/always_reload_changed_files", QVariant(false))
const gui_pref ed_comment_str_old("editor/octave_comment_string", QVariant(0))
const gui_pref ed_indent_uses_tabs("editor/indent_uses_tabs", QVariant(false))
const gui_pref ed_code_completion("editor/codeCompletion", QVariant(true))
const gui_pref ed_show_hscroll_bar("editor/show_hscroll_bar", QVariant(true))
const gui_pref ed_code_completion_octave_functions("editor/codeCompletion_octave_functions", QVariant(true))
const gui_pref ed_auto_endif("editor/auto_endif", QVariant(1))
const gui_pref ed_highlight_current_line_color("editor/highlight_current_line_color", QVariant(QColor(240, 240, 240)))
const gui_pref ed_show_toolbar("editor/show_toolbar", QVariant(true))
const gui_pref ed_uncomment_str("editor/oct_uncomment_str", QVariant(1+2+4+8))
const gui_pref ed_long_window_title("editor/longWindowTitle", QVariant(false))
const gui_pref ed_show_white_space("editor/show_white_space", QVariant(false))
const gui_pref ed_create_new_file("editor/create_new_file", QVariant(false))
const gui_pref ed_default_enc("editor/default_encoding", QVariant(QString("SYSTEM (")+QString(octave_locale_charset_wrapper()).toUpper()+QString(")")))
const gui_pref ed_line_numbers_size("editor/line_numbers_size", QVariant(0))
const gui_pref ed_wrap_lines("editor/wrap_lines", QVariant(false))
const gui_pref ed_highlight_current_line("editor/highlightCurrentLine", QVariant(true))
const gui_pref ed_notebook_tab_width_min("editor/notebook_tab_width_min", QVariant(160))
const gui_pref ed_code_completion_threshold("editor/codeCompletion_threshold", QVariant(2))
const gui_pref ed_break_lines("editor/break_lines", QVariant(false))
const gui_pref ed_break_lines_comments("editor/break_lines_comments", QVariant(false))
const gui_pref ed_long_line_marker("editor/long_line_marker", QVariant(true))
const gui_pref ed_tab_position("editor/tab_position", QVariant(QTabWidget::North))
const QStringList ed_tab_position_names(QStringList()<< QT_TRANSLATE_NOOP("octave::settings_dialog", "Top")<< QT_TRANSLATE_NOOP("octave::settings_dialog", "Bottom")<< QT_TRANSLATE_NOOP("octave::settings_dialog", "Left")<< QT_TRANSLATE_NOOP("octave::settings_dialog", "Right"))
const gui_pref ed_tab_indents_line("editor/tab_indents_line", QVariant(false))
const gui_pref ed_code_completion_octave_builtins("editor/codeCompletion_octave_builtins", QVariant(true))
const gui_pref ed_show_edit_status_bar("editor/show_edit_status_bar", QVariant(true))
const gui_pref ed_code_completion_document("editor/codeCompletion_document", QVariant(true))
const gui_pref ed_backspace_unindents_line("editor/backspace_unindents_line", QVariant(false))
const gui_pref ed_restore_session("editor/restoreSession", QVariant(true))
const gui_pref ed_code_completion_case("editor/codeCompletion_case", QVariant(true))
const gui_pref ed_long_line_marker_background("editor/long_line_marker_background", QVariant(false))
const QStringList ed_comment_strings(QStringList()<< "##"<< "#"<< "%"<< "%%"<< "%!")
const gui_pref ed_show_dbg_file("editor/show_dbg_file", QVariant(true))
const gui_pref ed_show_white_space_indent("editor/show_white_space_indent", QVariant(false))
const gui_pref ed_show_line_numbers("editor/showLineNumbers", QVariant(true))
const gui_pref ed_notebook_tab_width_max("editor/notebook_tab_width_max", QVariant(300))
const gui_pref ed_highlight_all_occurrences("editor/highlight_all_occurrences", QVariant(true))
const gui_pref ed_show_eol_chars("editor/show_eol_chars", QVariant(false))
const gui_pref ed_show_indent_guides("editor/show_indent_guides", QVariant(false))
const gui_pref ed_code_folding("editor/code_folding", QVariant(true))
const gui_pref ed_indent_width("editor/indent_width", QVariant(2))
const gui_pref ed_tab_width("editor/tab_width", QVariant(2))
const gui_pref ed_comment_str("editor/oct_comment_str", QVariant(0))
const gui_pref ed_hiding_closes_files("editor/hiding_closes_files", QVariant(false))
const gui_pref ed_long_line_column("editor/long_line_column", QVariant(80))
const gui_pref ed_default_eol_mode("editor/default_eol_mode", QVariant(os_eol_mode))
const gui_pref ed_code_completion_replace("editor/codeCompletion_replace", QVariant(false))
const int ed_comment_strings_count
const gui_pref ed_code_completion_keywords("editor/codeCompletion_keywords", QVariant(true))
const gui_pref ed_auto_indent("editor/auto_indent", QVariant(true))
const gui_pref ed_long_line_marker_line("editor/long_line_marker_line", QVariant(true))
const gui_pref fb_sync_octdir("filesdockwidget/sync_octave_directory", QVariant(true))
const gui_pref fb_startup_dir("filesdockwidget/startup_dir", QVariant(QString()))
const gui_pref fb_txt_file_ext("filesdockwidget/txt_file_extensions", QVariant("m;c;cc;cpp;h;txt"))
const gui_pref fb_restore_last_dir("filesdockwidget/restore_last_dir", QVariant(false))
const gui_pref global_use_proxy("useProxyServer", QVariant(false))
const gui_pref global_mono_font("monospace_font", global_font_family)
const gui_pref global_restore_ov_dir("restore_octave_dir", QVariant(false))
const gui_pref global_proxy_pass("proxyPassword", QVariant(QString()))
const gui_pref global_status_bar("show_status_bar", QVariant(true))
const gui_pref global_proxy_host("proxyHostName", QVariant(QString()))
const gui_pref global_prompt_to_exit("prompt_to_exit", QVariant(false))
const gui_pref global_proxy_type("proxyType", QVariant(QString()))
const gui_pref global_use_native_dialogs("use_native_file_dialogs", QVariant(true))
const gui_pref global_proxy_user("proxyUserName", QVariant(QString()))
const gui_pref global_icon_theme("use_system_icon_theme", QVariant(true))
const gui_pref global_use_custom_editor("useCustomFileEditor", QVariant(false))
const gui_pref global_ov_startup_dir("octave_startup_dir", QVariant(QString()))
const gui_pref global_custom_editor("customFileEditor", QVariant("emacs +%l %f"))
const gui_pref global_proxy_port("proxyPort", QVariant(80))
const gui_pref global_icon_size("toolbar_icon_size", QVariant(0))
const gui_pref global_language("language", QVariant("SYSTEM"))
const gui_pref global_cursor_blinking("cursor_blinking", QVariant(true))
const gui_pref global_style("style", QVariant("default"))
const gui_pref nr_allow_connection("news/allow_web_connection", QVariant(false))
const gui_pref sc_prevent_rl_conflicts("shortcuts/prevent_readline_conflicts", QVariant(true))
const gui_pref sd_geometry("settings/geometry", QVariant())
const gui_pref sd_last_editor_styles_tab("settings/last_editor_styles_tab", QVariant(0))
const gui_pref sd_last_tab("settings/last_tab", QVariant(0))
const int ve_colors_count
const gui_pref ve_column_width("variable_editor/column_width", QVariant(100))
const QStringList ve_color_names(QStringList()<< QT_TRANSLATE_NOOP("octave::settings_dialog", "Foreground")<< QT_TRANSLATE_NOOP("octave::settings_dialog", "Background")<< QT_TRANSLATE_NOOP("octave::settings_dialog", "Selected Foreground")<< QT_TRANSLATE_NOOP("octave::settings_dialog", "Selected Background")<< QT_TRANSLATE_NOOP("octave::settings_dialog", "Alternate Background"))
const gui_pref ve_colors[ve_colors_count]
const gui_pref ve_use_terminal_font("variable_editor/use_terminal_font", QVariant(true))
const gui_pref ve_font_size("variable_editor/font_size", QVariant(10))
const gui_pref ve_alternate_rows("variable_editor/alternate_rows", QVariant(false))
const gui_pref ve_font_name("variable_editor/font_name", QVariant())
const gui_pref ve_row_height("variable_editor/row_height", QVariant(10))
const gui_pref ws_colors[ws_colors_count]
const QStringList ws_color_names(QStringList()<< QT_TRANSLATE_NOOP("octave::settings_dialog", "argument")<< QT_TRANSLATE_NOOP("octave::settings_dialog", "global")<< QT_TRANSLATE_NOOP("octave::settings_dialog", "persistent"))
const gui_pref ws_enable_colors("workspaceview/enable_colors", QVariant(false))
const gui_pref ws_hide_tool_tips("workspaceview/hide_tools_tips", QVariant(false))
const int ws_colors_count
static int get_valid_lexer_styles(QsciLexer *lexer, int *styles)
static const int MaxLexerStyles
static const int MaxStyleNumber
#define lexer
Definition: oct-parse.cc:146
const QString key
const QVariant def