Mercurial > octave
diff libgui/src/settings-dialog.cc @ 25974:c3cd63006870
add preference for disabling workspace colors for different attributes
* gui-preferences.h: add new and mive existing preferences for the
workspace view
* settings-dialog.cc (settings_dialog, write_changed_settings):
remove use of workspace prefs here;
(read_workspace_colors): construct all elements of the workspace tab by
code instead of the designer file;
(write_workspace_colors): store the values of the check boxes for
workspace preferences
* settings-dialog.h: add check boxes of workspace view, that are removed from
the designer file and now constructed in the code, as class variables;
* settings-dialog.ui: clear the workspace tab, all elements are now
constructed and laid out in the the code
* workspace-model.cc (data): set background color only if attribute colors
are desired
* workspace-model.h: new class variable holding whether colors are used or not
* workspace-view.cc (notice_settings): use constants from gui-preferences.h
for key names and default values instead of hard coded values and store
preference for using attribute colors
author | Torsten <mttl@mailbox.org> |
---|---|
date | Sun, 28 Oct 2018 20:31:08 +0100 |
parents | f2406585a974 |
children | 38a881b8fbec |
line wrap: on
line diff
--- a/libgui/src/settings-dialog.cc Sat Oct 27 06:54:47 2018 -0400 +++ b/libgui/src/settings-dialog.cc Sun Oct 28 20:31:08 2018 +0100 @@ -388,10 +388,7 @@ proxyPassword->setText (settings->value ("proxyPassword").toString ()); // Workspace - // colors read_workspace_colors (settings); - // hide tool tips - cb_hide_tool_tips->setChecked (settings->value ("workspaceview/hide_tool_tips", false).toBool ()); // terminal colors read_terminal_colors (settings); @@ -965,8 +962,6 @@ // Workspace write_workspace_colors (settings); - // hide tool tips - settings->setValue ("workspaceview/hide_tool_tips", cb_hide_tool_tips->isChecked ()); // Terminal write_terminal_colors (settings); @@ -996,7 +991,7 @@ void settings_dialog::read_workspace_colors (QSettings *settings) { - + // Construct the grid with all color related settings QList<QColor> default_colors = resource_manager::storage_class_default_colors (); QStringList class_names = resource_manager::storage_class_names (); @@ -1009,15 +1004,32 @@ int column = 0; int row = 0; + + m_ws_enable_colors = new QCheckBox (tr ("Enable attribute colors")); + style_grid->addWidget (m_ws_enable_colors, row++, column, 1, 4); + + m_ws_hide_tool_tips = new QCheckBox (tr ("Hide tools tips")); + style_grid->addWidget (m_ws_hide_tool_tips, row++, column, 1, 4); + connect (m_ws_enable_colors, SIGNAL (toggled (bool)), + m_ws_hide_tool_tips, SLOT(setEnabled (bool))); + m_ws_hide_tool_tips->setChecked ( + settings->value (ws_hide_tool_tips.key, ws_hide_tool_tips.def).toBool ()); + for (int i = 0; i < nr_of_classes; i++) { description[i] = new QLabel (" " + class_names.at (i)); description[i]->setAlignment (Qt::AlignRight); + connect (m_ws_enable_colors, SIGNAL (toggled (bool)), + description[i], SLOT(setEnabled (bool))); + QVariant default_var = default_colors.at (i); QColor setting_color = settings->value ("workspaceview/color_" + class_chars.mid (i, 1), default_var).value<QColor> (); color[i] = new color_picker (setting_color); color[i]->setObjectName ("color_" + class_chars.mid (i, 1)); color[i]->setMinimumSize (30, 10); + connect (m_ws_enable_colors, SIGNAL (toggled (bool)), + color[i], SLOT(setEnabled (bool))); + style_grid->addWidget (description[i], row, 3*column); style_grid->addWidget (color[i], row, 3*column+1); if (++column == 3) @@ -1028,12 +1040,20 @@ } } + // Load enable settings at the end for having signals already connected + bool colors_enabled = + settings->value (ws_enable_colors.key, ws_enable_colors.def).toBool (); + m_ws_enable_colors->setChecked (colors_enabled); + m_ws_hide_tool_tips->setEnabled (colors_enabled); + // place grid with elements into the tab workspace_colors_box->setLayout (style_grid); } void settings_dialog::write_workspace_colors (QSettings *settings) { + settings->setValue (ws_enable_colors.key, m_ws_enable_colors->isChecked ()); + settings->setValue (ws_hide_tool_tips.key, m_ws_hide_tool_tips->isChecked ()); QString class_chars = resource_manager::storage_class_chars (); color_picker *color;