Mercurial > octave
changeset 27672:a36443e94f8a
simplify gui_settings->value (PREF.key, PREF.def) calls
* gui-settings.h (gui_settings::value (const gui_pref& PREF) const):
New method, equivalent to "value (PREF.key, PREF.def)". Change all
calls that use that form to use "value (PREF)" instead.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 12 Nov 2019 12:10:33 -0500 |
parents | 61883a1a80a1 |
children | 58bff27d8714 |
files | libgui/qterminal/libqterminal/QTerminal.cc libgui/src/documentation.cc libgui/src/files-dock-widget.cc libgui/src/gui-settings.h libgui/src/history-dock-widget.cc libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor.cc libgui/src/m-editor/octave-qscintilla.cc libgui/src/main-window.cc libgui/src/octave-dock-widget.cc libgui/src/resource-manager.cc libgui/src/settings-dialog.cc libgui/src/terminal-dock-widget.cc libgui/src/variable-editor.cc libgui/src/workspace-model.cc libgui/src/workspace-view.cc |
diffstat | 16 files changed, 124 insertions(+), 167 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/qterminal/libqterminal/QTerminal.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/qterminal/libqterminal/QTerminal.cc Tue Nov 12 12:10:33 2019 -0500 @@ -223,26 +223,24 @@ // Set terminal font: QFont term_font = QFont (); term_font.setStyleHint (QFont::TypeWriter); - QString default_font = settings->value (global_mono_font.key, global_mono_font.def).toString (); + QString default_font = settings->value (global_mono_font).toString (); term_font.setFamily (settings->value (cs_font.key, default_font).toString ()); term_font.setPointSize - (settings->value (cs_font_size.key, cs_font_size.def).toInt ()); + (settings->value (cs_font_size).toInt ()); setTerminalFont (term_font); QFontMetrics metrics (term_font); setMinimumSize (metrics.maxWidth ()*16, metrics.height ()*3); QString cursor_type - = settings->value (cs_cursor.key, cs_cursor.def).toString (); + = settings->value (cs_cursor).toString (); bool cursor_blinking; if (settings->contains (global_cursor_blinking.key)) - cursor_blinking = settings->value (global_cursor_blinking.key, - global_cursor_blinking.def).toBool (); + cursor_blinking = settings->value (global_cursor_blinking).toBool (); else - cursor_blinking = settings->value (cs_cursor_blinking.key, - cs_cursor_blinking.def).toBool (); + cursor_blinking = settings->value (cs_cursor_blinking).toBool (); for (int ct = IBeamCursor; ct <= UnderlineCursor; ct++) { @@ -254,7 +252,7 @@ } bool cursorUseForegroundColor - = settings->value (cs_cursor_use_fgcol.key, cs_cursor_use_fgcol.def).toBool (); + = settings->value (cs_cursor_use_fgcol).toBool (); setForegroundColor (settings->value (cs_colors[0].key, cs_colors[0].def).value<QColor> ()); @@ -268,13 +266,12 @@ setCursorColor (cursorUseForegroundColor, settings->value (cs_colors[3].key, cs_colors[3].def).value<QColor> ()); - setScrollBufferSize (settings->value (cs_hist_buffer.key, - cs_hist_buffer.def).toInt ()); + setScrollBufferSize (settings->value (cs_hist_buffer).toInt ()); // If the Copy shortcut is Ctrl-C, then set up to allow Ctrl-C to also // be processed as the interrupt character in the command window. - QVariant tmp = settings->value (sc_main_edit_copy.key, sc_main_edit_copy.def); + QVariant tmp = settings->value (sc_main_edit_copy); QKeySequence sc = tmp.value<QKeySequence> (); // dis- or enable extra interrupt action @@ -283,7 +280,7 @@ has_extra_interrupt (extra_ir_action); // check whether shortcut Ctrl-D is in use by the main-window - bool ctrld = settings->value (sc_main_ctrld.key, sc_main_ctrld.def).toBool (); + bool ctrld = settings->value (sc_main_ctrld).toBool (); _nop_action->setEnabled (! ctrld); }
--- a/libgui/src/documentation.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/documentation.cc Tue Nov 12 12:10:33 2019 -0500 @@ -571,8 +571,7 @@ return; // Icon size in the toolbar. - int size_idx = settings->value (global_icon_size.key, - global_icon_size.def).toInt (); + int size_idx = settings->value (global_icon_size).toInt (); size_idx = (size_idx > 0) - (size_idx < 0) + 1; // Make valid index from 0 to 2 QStyle *st = style ();
--- a/libgui/src/files-dock-widget.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/files-dock-widget.cc Tue Nov 12 12:10:33 2019 -0500 @@ -192,8 +192,7 @@ // Create the QFileSystemModel starting in the desired directory QDir startup_dir; // take current dir - if (settings->value (fb_restore_last_dir.key, - fb_restore_last_dir.def).toBool ()) + if (settings->value (fb_restore_last_dir).toBool ()) { // restore last dir from previous session QStringList last_dirs @@ -201,12 +200,10 @@ if (last_dirs.length () > 0) startup_dir = QDir (last_dirs.at (0)); // last dir in previous session } - else if (! settings->value (fb_startup_dir.key, fb_startup_dir.def) - .toString ().isEmpty ()) + else if (! settings->value (fb_startup_dir).toString ().isEmpty ()) { // do not restore but there is a startup dir configured - startup_dir - = QDir (settings->value (fb_startup_dir.key).toString ()); + startup_dir = QDir (settings->value (fb_startup_dir.key).toString ()); } if (! startup_dir.exists ()) @@ -232,8 +229,8 @@ // get sort column and order as well as cloumn state (order and width) m_file_tree_view->sortByColumn - (settings->value (fb_sort_column.key, fb_sort_column.def).toInt (), - static_cast<Qt::SortOrder> (settings->value (fb_sort_order.key, fb_sort_order.def).toUInt ())); + (settings->value (fb_sort_column).toInt (), + static_cast<Qt::SortOrder> (settings->value (fb_sort_order).toUInt ())); if (settings->contains (fb_column_state.key)) m_file_tree_view->header ()->restoreState @@ -409,8 +406,7 @@ QString suffix = fileInfo.suffix ().toLower (); resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - QString ext = settings->value (fb_txt_file_ext.key, - fb_txt_file_ext.def).toString (); + QString ext = settings->value (fb_txt_file_ext).toString (); QStringList extensions = ext.split (";", QString::SkipEmptyParts); if (QFile::exists (abs_fname)) @@ -868,8 +864,7 @@ { // Qsettings pointer is checked before emitting. - int size_idx = settings->value (global_icon_size.key, - global_icon_size.def).toInt (); + int size_idx = settings->value (global_icon_size).toInt (); size_idx = (size_idx > 0) - (size_idx < 0) + 1; // Make valid index from 0 to 2 QStyle *st = style (); @@ -894,7 +889,7 @@ // enable the buttons to sync octave/browser dir // only if this is not done by default m_sync_octave_dir - = settings->value (fb_sync_octdir.key, fb_sync_octdir.def).toBool (); + = settings->value (fb_sync_octdir).toBool (); m_sync_octave_directory_action->setEnabled (! m_sync_octave_dir); m_sync_browser_directory_action->setEnabled (! m_sync_octave_dir); @@ -924,8 +919,7 @@ int opts = QFileDialog::ShowDirsOnly; resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - if (! settings->value (global_use_native_dialogs.key, - global_use_native_dialogs.def).toBool ()) + if (! settings->value (global_use_native_dialogs).toBool ()) opts |= QFileDialog::DontUseNativeDialog; QString dir = QFileDialog::getExistingDirectory (this,
--- a/libgui/src/gui-settings.h Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/gui-settings.h Tue Nov 12 12:10:33 2019 -0500 @@ -25,10 +25,14 @@ #include <QSettings> +#include "gui-preferences.h" + namespace octave { class gui_settings : public QSettings { + Q_OBJECT + public: gui_settings (const QString& file_name, QSettings::Format format, @@ -50,6 +54,13 @@ gui_settings& operator = (const gui_settings&) = delete; ~gui_settings (void) = default; + + using QSettings::value; + + QVariant value (const gui_pref& pref) const + { + return value (pref.key, pref.def); + } }; }
--- a/libgui/src/history-dock-widget.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/history-dock-widget.cc Tue Nov 12 12:10:33 2019 -0500 @@ -321,14 +321,14 @@ gui_settings *settings = rmgr.get_settings (); m_filter_shown - = settings->value (hw_filter_shown.key, hw_filter_shown.def).toBool (); + = settings->value (hw_filter_shown).toBool (); m_filter_widget->setVisible (m_filter_shown); m_filter->addItems - (settings->value (hw_mru_list.key, hw_mru_list.def).toStringList ()); + (settings->value (hw_mru_list).toStringList ()); bool filter_state - = settings->value (hw_filter_active.key, hw_filter_active.def).toBool (); + = settings->value (hw_filter_active).toBool (); m_filter_checkbox->setChecked (filter_state); filter_activate (filter_state); @@ -352,10 +352,10 @@ QFont font = QFont (); font.setStyleHint (QFont::TypeWriter); - QString default_font = settings->value (global_mono_font.key, global_mono_font.def).toString (); + QString default_font = settings->value (global_mono_font).toString (); font.setFamily (settings->value (cs_font.key, default_font).toString ()); - font.setPointSize (settings->value (cs_font_size.key, cs_font_size.def).toInt ()); + font.setPointSize (settings->value (cs_font_size).toInt ()); m_history_list_view->setFont (font); }
--- a/libgui/src/m-editor/file-editor-tab.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/m-editor/file-editor-tab.cc Tue Nov 12 12:10:33 2019 -0500 @@ -266,8 +266,7 @@ // encoding, not updated with the settings QString locale_enc_name = QTextCodec::codecForLocale ()->name ().toUpper ().prepend ("SYSTEM (").append (")"); - m_encoding = settings->value (ed_default_enc.key, locale_enc_name) - .toString (); + m_encoding = settings->value (ed_default_enc.key, locale_enc_name).toString (); m_enc_indicator->setText (m_encoding); // no changes in encoding yet m_new_encoding = m_encoding; @@ -2908,11 +2907,9 @@ bool cursor_blinking; if (settings->contains (global_cursor_blinking.key)) - cursor_blinking = settings->value (global_cursor_blinking.key, - global_cursor_blinking.def).toBool (); + cursor_blinking = settings->value (global_cursor_blinking).toBool (); else - cursor_blinking = settings->value (cs_cursor_blinking.key, - cs_cursor_blinking.def).toBool (); + cursor_blinking = settings->value (cs_cursor_blinking).toBool (); if (cursor_blinking) m_edit_area->SendScintilla (QsciScintillaBase::SCI_SETCARETPERIOD,500);
--- a/libgui/src/m-editor/file-editor.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/m-editor/file-editor.cc Tue Nov 12 12:10:33 2019 -0500 @@ -284,20 +284,16 @@ // get the data from the settings file QStringList sessionFileNames - = settings->value (ed_session_names.key, ed_session_names.def) - .toStringList (); + = settings->value (ed_session_names).toStringList (); QStringList session_encodings - = settings->value (ed_session_enc.key, ed_session_enc.def) - .toStringList (); + = settings->value (ed_session_enc).toStringList (); QStringList session_index - = settings->value (ed_session_ind.key, ed_session_ind.def) - .toStringList (); + = settings->value (ed_session_ind).toStringList (); QStringList session_lines - = settings->value (ed_session_lines.key, ed_session_lines.def) - .toStringList (); + = settings->value (ed_session_lines).toStringList (); // fill a list of the struct and sort it (depending on index) QList<session_data> s_data; @@ -1135,8 +1131,7 @@ void file_editor::notice_settings (const gui_settings *settings) { - int size_idx = settings->value (global_icon_size.key, - global_icon_size.def).toInt (); + int size_idx = settings->value (global_icon_size).toInt (); size_idx = (size_idx > 0) - (size_idx < 0) + 1; // Make valid index from 0 to 2 QStyle *st = style (); @@ -1145,7 +1140,7 @@ // Tab position QTabWidget::TabPosition pos - = static_cast<QTabWidget::TabPosition> (settings->value (ed_tab_position.key, ed_tab_position.def).toInt ()); + = static_cast<QTabWidget::TabPosition> (settings->value (ed_tab_position).toInt ()); m_tab_widget->setTabPosition (pos); @@ -1395,7 +1390,7 @@ resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); bool show_dbg_file - = settings->value (ed_show_dbg_file.key, ed_show_dbg_file.def).toBool (); + = settings->value (ed_show_dbg_file).toBool (); if (openFileName.isEmpty ()) {
--- a/libgui/src/m-editor/octave-qscintilla.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/m-editor/octave-qscintilla.cc Tue Nov 12 12:10:33 2019 -0500 @@ -406,12 +406,10 @@ // The commenting string is requested if (settings->contains (ed_comment_str.key)) // new version (radio buttons) - comment_string = settings->value (ed_comment_str.key, - ed_comment_str.def).toInt (); + comment_string = settings->value (ed_comment_str).toInt (); else // old version (combo box) - comment_string = settings->value (ed_comment_str_old.key, - ed_comment_str.def).toInt (); + comment_string = settings->value (ed_comment_str_old.key, ed_comment_str.def).toInt (); return (QStringList (ed_comment_strings.at (comment_string))); } @@ -420,8 +418,7 @@ QStringList c_str; // The possible uncommenting string(s) are requested - comment_string = settings->value (ed_uncomment_str.key, - ed_uncomment_str.def).toInt (); + comment_string = settings->value (ed_uncomment_str).toInt (); for (int i = 0; i < ed_comment_strings_count; i++) { @@ -865,8 +862,7 @@ // Disable opening a file at a breakpoint in case keyboard () is used gui_settings* settings = rmgr.get_settings (); - bool show_dbg_file = settings->value (ed_show_dbg_file.key, - ed_show_dbg_file.def).toBool (); + bool show_dbg_file = settings->value (ed_show_dbg_file).toBool (); settings->setValue (ed_show_dbg_file.key, false); emit focus_console_after_command_signal ();
--- a/libgui/src/main-window.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/main-window.cc Tue Nov 12 12:10:33 2019 -0500 @@ -198,15 +198,13 @@ if (settings) { connect_to_web - = settings->value (nr_allow_connection.key, - nr_allow_connection.def).toBool (); + = settings->value (nr_allow_connection).toBool (); last_checked - = settings->value (nr_last_time.key, nr_last_time.def).toDateTime (); - - serial = settings->value (nr_last_news.key, nr_last_news.def).toInt (); - m_default_encoding = settings->value (ed_default_enc.key, - ed_default_enc.def).toString (); + = settings->value (nr_last_time).toDateTime (); + + serial = settings->value (nr_last_news).toInt (); + m_default_encoding = settings->value (ed_default_enc).toString (); } QDateTime current = QDateTime::currentDateTime (); @@ -693,8 +691,7 @@ bool connect_to_web = (settings - ? settings->value (nr_allow_connection.key, - nr_allow_connection.def).toBool () + ? settings->value (nr_allow_connection).toBool () : true); QString base_url = "https://octave.org"; @@ -837,7 +834,7 @@ // Get desired style from preferences or take the default one if // the desired one is not found QString preferred_style - = settings->value (global_style.key, global_style.def).toString (); + = settings->value (global_style).toString (); if (preferred_style == global_style.def.toString ()) preferred_style = m_default_style; @@ -852,7 +849,7 @@ // the widget's icons (when floating) QString icon_set - = settings->value (dw_icon_set.key, dw_icon_set.def).toString (); + = settings->value (dw_icon_set).toString (); int count = 0; int icon_set_found = 0; // default @@ -888,8 +885,7 @@ else m_release_notes_icon = ":/actions/icons/logo.png"; - int size_idx = settings->value (global_icon_size.key, - global_icon_size.def).toInt (); + int size_idx = settings->value (global_icon_size).toInt (); size_idx = (size_idx > 0) - (size_idx < 0) + 1; // Make valid index from 0 to 2 QStyle *st = style (); @@ -918,7 +914,7 @@ // Check whether some octave internal preferences have to be updated QString new_default_encoding - = settings->value (ed_default_enc.key, ed_default_enc.def).toString (); + = settings->value (ed_default_enc).toString (); if (new_default_encoding != m_default_encoding) update_default_encoding (new_default_encoding); @@ -929,11 +925,9 @@ bool cursor_blinking; if (settings->contains (global_cursor_blinking.key)) - cursor_blinking = settings->value (global_cursor_blinking.key, - global_cursor_blinking.def).toBool (); + cursor_blinking = settings->value (global_cursor_blinking).toBool (); else - cursor_blinking = settings->value (cs_cursor_blinking.key, - cs_cursor_blinking.def).toBool (); + cursor_blinking = settings->value (cs_cursor_blinking).toBool (); if (cursor_blinking) QApplication::setCursorFlashTime (1000); // 1000 ms flash time @@ -1476,10 +1470,10 @@ // of an error from the default layout if (settings) { - if (! restoreState (settings->value (mw_state.key, mw_state.def).toByteArray ())) + if (! restoreState (settings->value (mw_state).toByteArray ())) restoreState (mw_state.def.toByteArray ()); - if (! restoreGeometry (settings->value (mw_geometry.key, mw_geometry.def).toByteArray ())) + if (! restoreGeometry (settings->value (mw_geometry).toByteArray ())) restoreGeometry (mw_geometry.def.toByteArray ()); } @@ -1665,8 +1659,7 @@ } update_default_encoding - (settings->value (ed_default_enc.key, - ed_default_enc.def).toString ()); + (settings->value (ed_default_enc).toString ()); } if (! startup_dir.exists ())
--- a/libgui/src/octave-dock-widget.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/octave-dock-widget.cc Tue Nov 12 12:10:33 2019 -0500 @@ -424,25 +424,20 @@ octave_dock_widget::handle_settings (const gui_settings *settings) { m_custom_style - = settings->value (dw_title_custom_style.key, - dw_title_custom_style.def).toBool (); + = settings->value (dw_title_custom_style).toBool (); m_title_3d = settings->value (dw_title_3d.key, dw_title_3d.def).toInt (); m_fg_color - = settings->value (dw_title_fg_color.key, - dw_title_fg_color.def).value<QColor> (); + = settings->value (dw_title_fg_color).value<QColor> (); m_fg_color_active - = settings->value (dw_title_fg_color_active.key, - dw_title_fg_color_active.def).value<QColor> (); + = settings->value (dw_title_fg_color_active).value<QColor> (); - m_bg_color = settings->value (dw_title_bg_color.key, - dw_title_bg_color.def).value<QColor> (); + m_bg_color = settings->value (dw_title_bg_color).value<QColor> (); m_bg_color_active - = settings->value (dw_title_bg_color_active.key, - dw_title_bg_color_active.def).value<QColor> (); + = settings->value (dw_title_bg_color_active).value<QColor> (); QColor bcol (m_bg_color); QColor bcola (m_bg_color_active);
--- a/libgui/src/resource-manager.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/resource-manager.cc Tue Nov 12 12:10:33 2019 -0500 @@ -365,7 +365,7 @@ QIcon resource_manager::icon (const QString& icon_name, bool fallback) { // If system icon theme is not desired, take own icon files - if (! m_settings->value (global_icon_theme.key, global_icon_theme.def).toBool ()) + if (! m_settings->value (global_icon_theme).toBool ()) return QIcon (":/actions/icons/" + icon_name + ".png"); // Use system icon theme with own files as fallback except the fallback is @@ -421,7 +421,7 @@ ("SYSTEM (").append (")"); if (enc.isEmpty ()) { - enc = m_settings->value (ed_default_enc.key, ed_default_enc.def).toString (); + enc = m_settings->value (ed_default_enc).toString (); if (enc.isEmpty ()) // still empty? {
--- a/libgui/src/settings-dialog.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/settings-dialog.cc Tue Nov 12 12:10:33 2019 -0500 @@ -131,7 +131,7 @@ combo_styles->addItems (styles); combo_styles->insertItem (0, global_style.def.toString ()); combo_styles->insertSeparator (1); - QString current_style = settings->value (global_style.key, global_style.def).toString (); + QString current_style = settings->value (global_style).toString (); if (current_style == global_style.def.toString ()) current_style = global_style.def.toString (); selected = combo_styles->findText (current_style); @@ -145,11 +145,11 @@ icon_size_group->addButton (icon_size_small); icon_size_group->addButton (icon_size_normal); icon_size_group->addButton (icon_size_large); - int icon_size = settings->value (global_icon_size.key, global_icon_size.def).toInt (); + int icon_size = settings->value (global_icon_size).toInt (); icon_size_normal->setChecked (true); // the default icon_size_small->setChecked (icon_size < 0); icon_size_large->setChecked (icon_size > 0); - cb_system_icon_theme->setChecked (settings->value (global_icon_theme.key, global_icon_theme.def).toBool ()); + cb_system_icon_theme->setChecked (settings->value (global_icon_theme).toBool ()); // which icon has to be selected QButtonGroup *icon_group = new QButtonGroup (this); @@ -157,15 +157,14 @@ icon_group->addButton (general_icon_graphic); icon_group->addButton (general_icon_letter); QString widget_icon_set = - settings->value (dw_icon_set.key, dw_icon_set.def).toString (); + settings->value (dw_icon_set).toString (); general_icon_octave->setChecked (true); // the default (if invalid set) general_icon_octave->setChecked (widget_icon_set == "NONE"); general_icon_graphic->setChecked (widget_icon_set == "GRAPHIC"); general_icon_letter->setChecked (widget_icon_set == "LETTER"); // custom title bar of dock widget - QColor bg_color = settings->value (dw_title_bg_color.key, - dw_title_bg_color.def).value<QColor> (); + QColor bg_color = settings->value (dw_title_bg_color).value<QColor> (); m_widget_title_bg_color = new color_picker (bg_color); m_widget_title_bg_color->setEnabled (false); layout_widget_bgtitle->addWidget (m_widget_title_bg_color, 0); @@ -173,8 +172,7 @@ connect (cb_widget_custom_style, SIGNAL (toggled (bool)), m_widget_title_bg_color, SLOT (setEnabled (bool))); - QColor bg_color_active = settings->value (dw_title_bg_color_active.key, - dw_title_bg_color_active.def).value<QColor> (); + QColor bg_color_active = settings->value (dw_title_bg_color_active).value<QColor> (); m_widget_title_bg_color_active = new color_picker (bg_color_active); m_widget_title_bg_color_active->setEnabled (false); layout_widget_bgtitle_active->addWidget (m_widget_title_bg_color_active, 0); @@ -182,8 +180,7 @@ connect (cb_widget_custom_style, SIGNAL (toggled (bool)), m_widget_title_bg_color_active, SLOT (setEnabled (bool))); - QColor fg_color = settings->value (dw_title_fg_color.key, - dw_title_fg_color.def).value<QColor> (); + QColor fg_color = settings->value (dw_title_fg_color).value<QColor> (); m_widget_title_fg_color = new color_picker (fg_color); m_widget_title_fg_color->setEnabled (false); layout_widget_fgtitle->addWidget (m_widget_title_fg_color, 0); @@ -191,8 +188,7 @@ connect (cb_widget_custom_style, SIGNAL (toggled (bool)), m_widget_title_fg_color, SLOT (setEnabled (bool))); - QColor fg_color_active = settings->value (dw_title_fg_color_active.key, - dw_title_fg_color_active.def).value<QColor> (); + QColor fg_color_active = settings->value (dw_title_fg_color_active).value<QColor> (); m_widget_title_fg_color_active = new color_picker (fg_color_active); m_widget_title_fg_color_active->setEnabled (false); layout_widget_fgtitle_active->addWidget (m_widget_title_fg_color_active, 0); @@ -200,18 +196,14 @@ connect (cb_widget_custom_style, SIGNAL (toggled (bool)), m_widget_title_fg_color_active, SLOT (setEnabled (bool))); - sb_3d_title->setValue (settings->value (dw_title_3d.key, - dw_title_3d.def).toInt ()); - cb_widget_custom_style->setChecked (settings->value (dw_title_custom_style.key, - dw_title_custom_style.def).toBool ()); + sb_3d_title->setValue (settings->value (dw_title_3d.key, dw_title_3d.def).toInt ()); + cb_widget_custom_style->setChecked (settings->value (dw_title_custom_style).toBool ()); // Native file dialogs. // FIXME: This preference can be deprecated / removed if all display // managers, especially KDE, run those dialogs without hangs or // delays from the start (bug #54607). - cb_use_native_file_dialogs->setChecked (settings->value ( - global_use_native_dialogs.key, - global_use_native_dialogs.def).toBool ()); + cb_use_native_file_dialogs->setChecked (settings->value (global_use_native_dialogs).toBool ()); // Cursor blinking: consider old terminal related setting if not yet set // FIXME: This pref. can be deprecated / removed if Qt adds support for @@ -299,19 +291,16 @@ editor_combox_tab_pos->insertItems (0, ed_tab_position_names); editor_combox_tab_pos->setCurrentIndex - (settings->value (ed_tab_position.key, ed_tab_position.def).toInt ()); + (settings->value (ed_tab_position).toInt ()); int selected_comment_string, selected_uncomment_string; if (settings->contains (ed_comment_str.key)) // new version (radio buttons) - selected_comment_string = settings->value (ed_comment_str.key, - ed_comment_str.def).toInt (); + selected_comment_string = settings->value (ed_comment_str).toInt (); else // old version (combo box) - selected_comment_string = settings->value (ed_comment_str_old.key, - ed_comment_str.def).toInt (); + selected_comment_string = settings->value (ed_comment_str_old.key, ed_comment_str.def).toInt (); - selected_uncomment_string = settings->value (ed_uncomment_str.key, - ed_uncomment_str.def).toInt (); + selected_uncomment_string = settings->value (ed_uncomment_str).toInt (); for (int i = 0; i < ed_comment_strings_count; i++) { @@ -358,19 +347,19 @@ editor_create_new_file->setChecked (settings->value ("editor/create_new_file", false).toBool ()); editor_reload_changed_files->setChecked (settings->value ("editor/always_reload_changed_files", false).toBool ()); editor_hiding_closes_files->setChecked (settings->value ("editor/hiding_closes_files", false).toBool ()); - editor_show_dbg_file->setChecked (settings->value (ed_show_dbg_file.key, ed_show_dbg_file.def).toBool ()); + editor_show_dbg_file->setChecked (settings->value (ed_show_dbg_file).toBool ()); // terminal - QString default_font = settings->value (global_mono_font.key, global_mono_font.def).toString (); + QString default_font = settings->value (global_mono_font).toString (); terminal_fontName->setCurrentFont (QFont (settings->value (cs_font.key, default_font).toString ())); - terminal_fontSize->setValue (settings->value (cs_font_size.key, cs_font_size.def).toInt ()); - terminal_history_buffer->setValue (settings->value (cs_hist_buffer.key, cs_hist_buffer.def).toInt ()); - terminal_cursorUseForegroundColor->setChecked (settings->value (cs_cursor_use_fgcol.key, cs_cursor_use_fgcol.def).toBool ()); + terminal_fontSize->setValue (settings->value (cs_font_size).toInt ()); + terminal_history_buffer->setValue (settings->value (cs_hist_buffer).toInt ()); + terminal_cursorUseForegroundColor->setChecked (settings->value (cs_cursor_use_fgcol).toBool ()); terminal_focus_command->setChecked (settings->value ("terminal/focus_after_command", false).toBool ()); terminal_print_dbg_location->setChecked (settings->value ("terminal/print_debug_location", false).toBool ()); QString cursor_type - = settings->value (cs_cursor.key, cs_cursor.def).toString (); + = settings->value (cs_cursor).toString (); QStringList items; items << QString ("0") << QString ("1") << QString ("2"); @@ -392,16 +381,16 @@ connect (sync_octave_directory, SIGNAL (toggled (bool)), this, SLOT (set_disabled_pref_file_browser_dir (bool))); - sync_octave_directory->setChecked (settings->value (fb_sync_octdir.key, fb_sync_octdir.def).toBool ()); - cb_restore_file_browser_dir->setChecked (settings->value (fb_restore_last_dir.key, fb_restore_last_dir.def).toBool ()); + sync_octave_directory->setChecked (settings->value (fb_sync_octdir).toBool ()); + cb_restore_file_browser_dir->setChecked (settings->value (fb_restore_last_dir).toBool ()); le_file_browser_dir->setText (settings->value (fb_startup_dir.key).toString ()); connect (pb_file_browser_dir, SIGNAL (pressed (void)), this, SLOT (get_file_browser_dir (void))); - le_file_browser_extensions->setText (settings->value (fb_txt_file_ext.key, fb_txt_file_ext.def).toString ()); + le_file_browser_extensions->setText (settings->value (fb_txt_file_ext).toString ()); - checkbox_allow_web_connect->setChecked (settings->value (nr_allow_connection.key, nr_allow_connection.def).toBool ()); + checkbox_allow_web_connect->setChecked (settings->value (nr_allow_connection).toBool ()); useProxyServer->setChecked (settings->value ("useProxyServer", false).toBool ()); proxyHostName->setText (settings->value ("proxyHostName").toString ()); @@ -425,21 +414,21 @@ read_terminal_colors (settings); // variable editor - varedit_columnWidth->setValue (settings->value (ve_column_width.key, ve_column_width.def).toInt ()); - varedit_rowHeight->setValue (settings->value (ve_row_height.key, ve_row_height.def).toInt ()); + varedit_columnWidth->setValue (settings->value (ve_column_width).toInt ()); + varedit_rowHeight->setValue (settings->value (ve_row_height).toInt ()); varedit_font->setCurrentFont (QFont (settings->value (ve_font_name.key, settings->value (cs_font.key, default_font)).toString ())); - varedit_fontSize->setValue (settings->value (ve_font_size.key, ve_font_size.def).toInt ()); + varedit_fontSize->setValue (settings->value (ve_font_size).toInt ()); connect (varedit_useTerminalFont, SIGNAL (toggled (bool)), varedit_font, SLOT (setDisabled (bool))); connect (varedit_useTerminalFont, SIGNAL (toggled (bool)), varedit_fontSize, SLOT (setDisabled (bool))); - varedit_useTerminalFont->setChecked (settings->value (ve_use_terminal_font.key, ve_use_terminal_font.def).toBool ()); + varedit_useTerminalFont->setChecked (settings->value (ve_use_terminal_font).toBool ()); varedit_font->setDisabled (varedit_useTerminalFont->isChecked ()); varedit_fontSize->setDisabled (varedit_useTerminalFont->isChecked ()); - varedit_alternate->setChecked (settings->value (ve_alternate_rows.key, ve_alternate_rows.def).toBool ()); + varedit_alternate->setChecked (settings->value (ve_alternate_rows).toBool ()); // variable editor colors read_varedit_colors (settings); @@ -558,8 +547,7 @@ int opts = QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks; resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - if (! settings->value (global_use_native_dialogs.key, - global_use_native_dialogs.def).toBool ()) + if (! settings->value (global_use_native_dialogs).toBool ()) opts |= QFileDialog::DontUseNativeDialog; QString dir = QFileDialog::getExistingDirectory @@ -743,7 +731,7 @@ int default_size = 10; QString default_font_name - = settings->value (global_mono_font.key, global_mono_font.def).toString (); + = settings->value (global_mono_font).toString (); QFont default_font = QFont (default_font_name, 10, -1, 0); QColor default_color = QColor (); QColor dummy_color = QColor (255, 0, 255); @@ -1064,7 +1052,7 @@ 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 ()); + (settings->value (ws_hide_tool_tips).toBool ()); for (int i = 0; i < ws_colors_count; i++) { @@ -1093,7 +1081,7 @@ // 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 (); + settings->value (ws_enable_colors).toBool (); m_ws_enable_colors->setChecked (colors_enabled); m_ws_hide_tool_tips->setEnabled (colors_enabled);
--- a/libgui/src/terminal-dock-widget.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/terminal-dock-widget.cc Tue Nov 12 12:10:33 2019 -0500 @@ -67,11 +67,11 @@ QFont font = QFont (); font.setStyleHint (QFont::TypeWriter); - QString default_font = settings->value (global_mono_font.key, global_mono_font.def).toString (); + QString default_font = settings->value (global_mono_font).toString (); font.setFamily (settings->value (cs_font.key, default_font).toString ()); font.setPointSize - (settings->value (cs_font_size.key, cs_font_size.def).toInt ()); + (settings->value (cs_font_size).toInt ()); QFontMetrics metrics(font);
--- a/libgui/src/variable-editor.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/variable-editor.cc Tue Nov 12 12:10:33 2019 -0500 @@ -461,8 +461,7 @@ int opts = 0; // No options by default. resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - if (! settings->value (global_use_native_dialogs.key, - global_use_native_dialogs.def).toBool ()) + if (! settings->value (global_use_native_dialogs).toBool ()) opts = QFileDialog::DontUseNativeDialog; QString name = objectName (); @@ -1352,32 +1351,27 @@ { m_main->notice_settings (settings); // update settings in parent main win - m_default_width = settings->value (ve_column_width.key, - ve_column_width.def).toInt (); + m_default_width = settings->value (ve_column_width).toInt (); - m_default_height = settings->value (ve_row_height.key, - ve_row_height.def).toInt (); + m_default_height = settings->value (ve_row_height).toInt (); - m_alternate_rows = settings->value (ve_alternate_rows.key, - ve_alternate_rows.def).toBool (); + m_alternate_rows = settings->value (ve_alternate_rows).toBool (); - m_use_terminal_font = settings->value (ve_use_terminal_font.key, - ve_use_terminal_font.def).toBool (); + m_use_terminal_font = settings->value (ve_use_terminal_font).toBool (); QString font_name; int font_size; - QString default_font = settings->value (global_mono_font.key, - global_mono_font.def).toString (); + QString default_font = settings->value (global_mono_font).toString (); if (m_use_terminal_font) { font_name = settings->value (cs_font.key, default_font).toString (); - font_size = settings->value (cs_font_size.key, cs_font_size.def).toInt (); + font_size = settings->value (cs_font_size).toInt (); } else { font_name = settings->value (ve_font_name.key, default_font).toString (); - font_size = settings->value (ve_font_size.key, ve_font_size.def).toInt (); + font_size = settings->value (ve_font_size).toInt (); } m_font = QFont (font_name, font_size); @@ -1402,8 +1396,7 @@ // Icon size in the toolbar. - int size_idx = settings->value (global_icon_size.key, - global_icon_size.def).toInt (); + int size_idx = settings->value (global_icon_size).toInt (); size_idx = (size_idx > 0) - (size_idx < 0) + 1; // Make valid index from 0 to 2 QStyle *st = style ();
--- a/libgui/src/workspace-model.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/workspace-model.cc Tue Nov 12 12:10:33 2019 -0500 @@ -197,7 +197,7 @@ workspace_model::notice_settings (const gui_settings *settings) { m_enable_colors = - settings->value (ws_enable_colors.key, ws_enable_colors.def).toBool (); + settings->value (ws_enable_colors).toBool (); for (int i = 0; i < ws_colors_count; i++) {
--- a/libgui/src/workspace-view.cc Tue Nov 12 11:15:40 2019 -0500 +++ b/libgui/src/workspace-view.cc Tue Nov 12 12:10:33 2019 -0500 @@ -101,8 +101,7 @@ if (settings) { - m_filter_shown = settings->value (ws_filter_shown.key, - ws_filter_shown.def).toBool (); + m_filter_shown = settings->value (ws_filter_shown).toBool (); m_filter_widget->setVisible (m_filter_shown); ws_layout->setMargin (2); @@ -130,8 +129,8 @@ m_view->horizontalHeader ()->setMovable (true); #endif m_view->horizontalHeader ()->setSortIndicator ( - settings->value (ws_sort_column.key, ws_sort_column.def).toInt (), - static_cast<Qt::SortOrder> (settings->value (ws_sort_order.key, ws_sort_order.def).toUInt ())); + settings->value (ws_sort_column).toInt (), + static_cast<Qt::SortOrder> (settings->value (ws_sort_order).toUInt ())); m_view->horizontalHeader ()->setSortIndicatorShown (true); m_view->horizontalHeader ()->setContextMenuPolicy (Qt::CustomContextMenu); @@ -143,7 +142,7 @@ m_filter->addItems (settings->value (ws_mru_list.key).toStringList ()); bool filter_state = - settings->value (ws_filter_active.key, ws_filter_active.def).toBool (); + settings->value (ws_filter_active).toBool (); m_filter_checkbox->setChecked (filter_state); filter_activate (filter_state); } @@ -182,7 +181,7 @@ resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); m_view->sortByColumn ( - settings->value (ws_sort_column.key ,ws_sort_column.def).toInt (), + settings->value (ws_sort_column).toInt (), static_cast<Qt::SortOrder> (settings->value (ws_sort_order.key, ws_sort_column.def).toUInt ())); m_model = model; @@ -198,8 +197,8 @@ QString tool_tip; - if (settings->value (ws_enable_colors.key, ws_enable_colors.def).toBool () - && ! settings->value (ws_hide_tool_tips.key, ws_hide_tool_tips.def).toBool ()) + if (settings->value (ws_enable_colors).toBool () + && ! settings->value (ws_hide_tool_tips).toBool ()) { tool_tip = QString (tr ("View the variables in the active workspace.<br>")); tool_tip += QString (tr ("Colors for variable attributes:"));