Mercurial > octave
changeset 27849:28d7ec92bae6
replace prefs literals by symbolic constant in main window
* gui-preferences-cs.h: new symbolic constants for pref keys and defaults
* gui-preferences-ed.h: new symbolic constants for pref keys and defaults
* gui-preferences-mw.h: new symbolic constants for pref keys and defaults
* file-editor.cc (request_open_file): replace literals by const. symbols
* main-window.cc ((notice_settings, read_settings, handle_octave_ready,
restore_create_file_setting, focus_console_after_command):
replace literals by const. symbols
* qt-interpreter-events.cc (prompt_new_edit_file):
replace literals by const. symbols
* settings-dialog.cc (settings_dialog, write_changed_settings):
replace literals by const. symbols
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Mon, 16 Dec 2019 08:00:43 +0100 |
parents | 7a3444bdf958 |
children | 8384125d6f5f |
files | libgui/src/gui-preferences-cs.h libgui/src/gui-preferences-ed.h libgui/src/gui-preferences-mw.h libgui/src/m-editor/file-editor.cc libgui/src/main-window.cc libgui/src/qt-interpreter-events.cc libgui/src/settings-dialog.cc |
diffstat | 7 files changed, 28 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/gui-preferences-cs.h Tue Dec 17 22:14:24 2019 +0100 +++ b/libgui/src/gui-preferences-cs.h Mon Dec 16 08:00:43 2019 +0100 @@ -67,4 +67,10 @@ << QT_TRANSLATE_NOOP ("QTerminal::QTerminal", "selection") << QT_TRANSLATE_NOOP ("QTerminal::QTerminal", "cursor")); +const gui_pref +cs_focus_cmd ("terminal/focus_after_command", QVariant (false)); + +const gui_pref +cs_dbg_location ("terminal/print_debug_location", QVariant (false)); + #endif
--- a/libgui/src/gui-preferences-ed.h Tue Dec 17 22:14:24 2019 +0100 +++ b/libgui/src/gui-preferences-ed.h Mon Dec 16 08:00:43 2019 +0100 @@ -80,6 +80,9 @@ ed_default_enc ("editor/default_encoding", QVariant (QTextCodec::codecForLocale ()->name ().toUpper ().prepend ("SYSTEM (").append (")"))); +const gui_pref +ed_create_new_file ("editor/create_new_file", QVariant (false)); + // The find dialog enum find_dialog_options
--- a/libgui/src/gui-preferences-mw.h Tue Dec 17 22:14:24 2019 +0100 +++ b/libgui/src/gui-preferences-mw.h Mon Dec 16 08:00:43 2019 +0100 @@ -83,4 +83,7 @@ mw_state ("MainWindow/windowState", QVariant (QByteArray (reinterpret_cast<const char*> (ba_state_data), sizeof (ba_state_data)))); +const gui_pref +mw_dir_list ("MainWindow/current_directory_list", QVariant (QStringList ())); + #endif
--- a/libgui/src/m-editor/file-editor.cc Tue Dec 17 22:14:24 2019 +0100 +++ b/libgui/src/m-editor/file-editor.cc Mon Dec 16 08:00:43 2019 +0100 @@ -1582,7 +1582,7 @@ bool create_file = true; QMessageBox *msgBox; - if (! settings->value ("editor/create_new_file", false).toBool ()) + if (! settings->value (ed_create_new_file).toBool ()) { msgBox = new QMessageBox (QMessageBox::Question, tr ("Octave Editor"),
--- a/libgui/src/main-window.cc Tue Dec 17 22:14:24 2019 +0100 +++ b/libgui/src/main-window.cc Mon Dec 16 08:00:43 2019 +0100 @@ -906,7 +906,7 @@ sc_prevent_rl_conflicts.def).toBool (); m_suppress_dbg_location - = ! settings->value ("terminal/print_debug_location", false).toBool (); + = ! settings->value (cs_dbg_location).toBool (); resource_manager& rmgr = m_octave_qobj.get_resource_manager (); rmgr.update_network_settings (); @@ -1298,10 +1298,10 @@ if (new_name.rightRef (2) != ".m") new_name.append (".m"); // check whether new files are created without prompt - if (! settings->value ("editor/create_new_file",false).toBool ()) + if (! settings->value (ed_create_new_file).toBool ()) { // no, so enable this settings and wait for end of new file loading - settings->setValue ("editor/create_new_file",true); + settings->setValue (ed_create_new_file.key, true); connect (m_editor_window, SIGNAL (file_loaded_signal (void)), this, SLOT (restore_create_file_setting (void))); } @@ -1459,8 +1459,7 @@ set_window_layout (settings); // restore the list of the last directories - QStringList curr_dirs - = settings->value ("MainWindow/current_directory_list").toStringList (); + QStringList curr_dirs = settings->value (mw_dir_list).toStringList (); for (int i=0; i < curr_dirs.size (); i++) { m_current_directory_combo_box->addItem (curr_dirs.at (i)); @@ -1565,7 +1564,7 @@ { curr_dirs.append (m_current_directory_combo_box->itemText (i)); } - settings->setValue ("MainWindow/current_directory_list", curr_dirs); + settings->setValue (mw_dir_list.key, curr_dirs); settings->sync (); } @@ -1657,7 +1656,7 @@ { // restore last dir from previous session QStringList curr_dirs - = settings->value ("MainWindow/current_directory_list").toStringList (); + = settings->value (mw_dir_list).toStringList (); startup_dir = QDir (curr_dirs.at (0)); // last dir in previous session } @@ -1865,7 +1864,7 @@ // restore the new files creation setting resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - settings->setValue ("editor/create_new_file",false); + settings->setValue (ed_create_new_file.key, false); disconnect (m_editor_window, SIGNAL (file_loaded_signal (void)), this, SLOT (restore_create_file_setting (void))); } @@ -2735,7 +2734,7 @@ { resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - if (settings->value ("terminal/focus_after_command",false).toBool ()) + if (settings->value (cs_focus_cmd).toBool ()) focus_command_window (); }
--- a/libgui/src/qt-interpreter-events.cc Tue Dec 17 22:14:24 2019 +0100 +++ b/libgui/src/qt-interpreter-events.cc Mon Dec 16 08:00:43 2019 +0100 @@ -277,7 +277,7 @@ resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - if (! settings || settings->value ("editor/create_new_file",false).toBool ()) + if (! settings || settings->value (ed_create_new_file).toBool ()) return true; std::string abs_fname = sys::env::make_absolute (file);
--- a/libgui/src/settings-dialog.cc Tue Dec 17 22:14:24 2019 +0100 +++ b/libgui/src/settings-dialog.cc Mon Dec 16 08:00:43 2019 +0100 @@ -351,7 +351,7 @@ editor_notebook_tab_width_min->setValue (settings->value ("editor/notebook_tab_width_min", 160).toInt ()); editor_notebook_tab_width_max->setValue (settings->value ("editor/notebook_tab_width_max", 300).toInt ()); editor_restoreSession->setChecked (settings->value ("editor/restoreSession", true).toBool ()); - editor_create_new_file->setChecked (settings->value ("editor/create_new_file", false).toBool ()); + editor_create_new_file->setChecked (settings->value (ed_create_new_file).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).toBool ()); @@ -362,8 +362,8 @@ 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 ()); + terminal_focus_command->setChecked (settings->value (cs_focus_cmd).toBool ()); + terminal_print_dbg_location->setChecked (settings->value (cs_dbg_location).toBool ()); QString cursor_type = settings->value (cs_cursor).toString (); @@ -935,7 +935,7 @@ settings->setValue ("editor/notebook_tab_width_min", editor_notebook_tab_width_min->value ()); settings->setValue ("editor/notebook_tab_width_max", editor_notebook_tab_width_max->value ()); settings->setValue ("editor/restoreSession", editor_restoreSession->isChecked ()); - settings->setValue ("editor/create_new_file", editor_create_new_file->isChecked ()); + settings->setValue (ed_create_new_file.key, editor_create_new_file->isChecked ()); settings->setValue ("editor/hiding_closes_files", editor_hiding_closes_files->isChecked ()); settings->setValue ("editor/always_reload_changed_files", editor_reload_changed_files->isChecked ()); settings->setValue (ed_show_dbg_file.key, editor_show_dbg_file->isChecked ()); @@ -957,8 +957,8 @@ settings->setValue (global_proxy_user.key, proxyUserName->text ()); settings->setValue (global_proxy_pass.key, proxyPassword->text ()); settings->setValue (cs_cursor_use_fgcol.key, terminal_cursorUseForegroundColor->isChecked ()); - settings->setValue ("terminal/focus_after_command", terminal_focus_command->isChecked ()); - settings->setValue ("terminal/print_debug_location", terminal_print_dbg_location->isChecked ()); + settings->setValue (mw_dir_list.key, terminal_focus_command->isChecked ()); + settings->setValue (cs_dbg_location.key, terminal_print_dbg_location->isChecked ()); settings->setValue (cs_hist_buffer.key, terminal_history_buffer->value ()); // the cursor