Mercurial > octave
changeset 27818:fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
* QTerminal.cc (doc_on_expression): sc_value already returns a string now
* documentation.cc (notice_settings): replace literal key names by
symb. constants of complete pref structure
* dw-main-window.cc (notice_settings): replace literal key names by
symb. constants of complete pref structure
* gui-preferences-sc.h: add constant sc_pref stuctures for all shortcuts
* gui-preferences.h: define a string constant for the shortcut setting group
* gui-settings.cc (sc_value): use new method sc_def_value for getting the
default value, already returning the shortcut as string
(sc_def_value): new method for reading the default value from the
shortcuts preferences structure
* gui-settings.h: new method sc_def_value, sc_value returns a string
* file-editor.cc (handle_enter_debug_mode, handle_exit_debug_mode,
set_shortcuts): replace literal key names by symb. constants of
complete pref structure
* main-window.cc (notice_settings): replace literals by symbolic constant
(configure_shortcuts): replace literal key names by symb. constants of
complete pref structure
* settings-dialog.cc (settings_dialog, write_changed_settings):
replace literals by symbolic constants
* shortcut-manager.cc (init_data): move all constants into
gui-preferences-sc.h, update calls to init (), which now takes
complete sc_pref structure as second argument;
(write_shortcuts, fill_treewidget, import_shortcuts):
replace literals by symbolic constants;
(init): only two arguments, second argument gets complete pref structure;
(set_shortcut, shortcut): takes complete shortcut structure as second
argument instead of key name
* shortcut-manager.h: init, set_shortcut, shortcut with new argument types
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Fri, 13 Dec 2019 21:33:28 +0100 |
parents | 78435ddc9f88 |
children | a2a5b75efdcf |
files | libgui/qterminal/libqterminal/QTerminal.cc libgui/src/documentation.cc libgui/src/dw-main-window.cc libgui/src/gui-preferences-sc.h libgui/src/gui-preferences.h libgui/src/gui-settings.cc libgui/src/gui-settings.h libgui/src/m-editor/file-editor.cc libgui/src/main-window.cc libgui/src/settings-dialog.cc libgui/src/shortcut-manager.cc libgui/src/shortcut-manager.h |
diffstat | 12 files changed, 540 insertions(+), 420 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/qterminal/libqterminal/QTerminal.cc Wed Dec 11 13:00:31 2019 +0000 +++ b/libgui/qterminal/libqterminal/QTerminal.cc Fri Dec 13 21:33:28 2019 +0100 @@ -273,7 +273,7 @@ // If the Copy shortcut is not Ctrl+C, an extra interrupt action is // set up for emitting the interrupt signal. - QString sc = settings->sc_value (sc_main_edit_copy).toString (); + QString sc = settings->sc_value (sc_main_edit_copy); // Dis- or enable extra interrupt action depending on the Copy shortcut bool extra_ir_action
--- a/libgui/src/documentation.cc Wed Dec 11 13:00:31 2019 +0000 +++ b/libgui/src/documentation.cc Fri Dec 13 21:33:28 2019 +0100 @@ -44,6 +44,7 @@ #include "documentation.h" #include "gui-preferences-global.h" +#include "gui-preferences-sc.h" #include "octave-qobject.h" #include "shortcut-manager.h" @@ -581,15 +582,15 @@ // Shortcuts shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager (); - scmgr.set_shortcut (m_action_find, "editor_edit:find_replace"); - scmgr.shortcut (m_findnext_shortcut, "editor_edit:find_next"); - scmgr.shortcut (m_findprev_shortcut, "editor_edit:find_previous"); - scmgr.set_shortcut (m_action_zoom_in, "editor_view:zoom_in"); - scmgr.set_shortcut (m_action_zoom_out, "editor_view:zoom_out"); - scmgr.set_shortcut (m_action_zoom_original, "editor_view:zoom_normal"); - scmgr.set_shortcut (m_action_go_home, "doc_browser:go_home"); - scmgr.set_shortcut (m_action_go_prev, "doc_browser:go_back"); - scmgr.set_shortcut (m_action_go_next, "doc_browser:go_next"); + scmgr.set_shortcut (m_action_find, sc_edit_edit_find_replace); + scmgr.shortcut (m_findnext_shortcut, sc_edit_edit_find_next); + scmgr.shortcut (m_findprev_shortcut, sc_edit_edit_find_previous); + scmgr.set_shortcut (m_action_zoom_in, sc_edit_view_zoom_in); + scmgr.set_shortcut (m_action_zoom_out, sc_edit_view_zoom_out); + scmgr.set_shortcut (m_action_zoom_original, sc_edit_view_zoom_normal); + scmgr.set_shortcut (m_action_go_home, sc_doc_go_home); + scmgr.set_shortcut (m_action_go_prev, sc_doc_go_back); + scmgr.set_shortcut (m_action_go_next, sc_doc_go_next); } void documentation::copyClipboard (void)
--- a/libgui/src/dw-main-window.cc Wed Dec 11 13:00:31 2019 +0000 +++ b/libgui/src/dw-main-window.cc Fri Dec 13 21:33:28 2019 +0100 @@ -35,6 +35,7 @@ #include "dw-main-window.h" #include "octave-qobject.h" #include "shortcut-manager.h" +#include "gui-preferences-sc.h" namespace octave { @@ -130,12 +131,12 @@ { shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager (); - scmgr.set_shortcut (m_close_action, "editor_file:close"); - scmgr.set_shortcut (m_close_all_action, "editor_file:close_all"); - scmgr.set_shortcut (m_close_others_action, "editor_file:close_other"); + scmgr.set_shortcut (m_close_action, sc_edit_file_close); + scmgr.set_shortcut (m_close_all_action, sc_edit_file_close_all); + scmgr.set_shortcut (m_close_others_action, sc_edit_file_close_other); - scmgr.set_shortcut (m_switch_left_action, "editor_tabs:switch_left_tab"); - scmgr.set_shortcut (m_switch_right_action, "editor_tabs:switch_right_tab"); + scmgr.set_shortcut (m_switch_left_action, sc_edit_tabs_switch_left_tab); + scmgr.set_shortcut (m_switch_right_action, sc_edit_tabs_switch_right_tab); }
--- a/libgui/src/gui-preferences-sc.h Wed Dec 11 13:00:31 2019 +0000 +++ b/libgui/src/gui-preferences-sc.h Fri Dec 13 21:33:28 2019 +0100 @@ -29,20 +29,222 @@ // The shortcut's default values are given as QKeySequence for being able // to use platform independent standard keys (QKeySequence::StandardKey). -// However, converting key sequences into QVariants does not seem to -// revertable. In addition the related string (which is saved in the +// However, converting key sequences into QVariants does not seem to be +// revertible. In addition the related string (which is saved in the // preferences file) can not be determined during compile time since the // result depends on the platform (at least in case of standard key sequences // like, e.g., QKeySequence::Copy) // Therefore, these prefs for key sequences require a separate constant // definition and value method for the settings class. +#if defined (Q_OS_MAC) + // Use CMD key as an equivalent of Ctrl key on other platforms +const Qt::KeyboardModifier CTRL = Qt::MetaModifier; + // Some of octave default shortcuts on windows/linux are already defined + // as system wide shortcuts on Mac Os X (almost all Function keys). + // Prefix those with Option (Alt) modifier to avoid conflicts. +const int PRE = Qt::AltModifier; +#else +const Qt::KeyboardModifier CTRL = Qt::ControlModifier; +const int PRE = Qt::NoModifier; +#endif + +const Qt::KeyboardModifiers CTRL_SHIFT = CTRL | Qt::ShiftModifier; +const Qt::KeyboardModifiers CTRL_ALT = CTRL | Qt::AltModifier; + +// Main window menu + +// file +const QString sc_main_file ("main_file"); +const sc_pref sc_main_file_new_file (sc_main_file + ":new_file", QKeySequence::New); +const sc_pref sc_main_file_new_function (sc_main_file + ":new_function", CTRL_SHIFT + Qt::Key_N); +const sc_pref sc_main_file_new_figure (sc_main_file + ":new_figure", QKeySequence::UnknownKey); +const sc_pref sc_main_file_open_file (sc_main_file + ":open_file", QKeySequence::Open); +const sc_pref sc_main_file_load_workspace (sc_main_file + ":load_workspace", QKeySequence::UnknownKey); +const sc_pref sc_main_file_save_workspace (sc_main_file + ":save_workspace", QKeySequence::UnknownKey); +const sc_pref sc_main_file_exit (sc_main_file + ":exit", QKeySequence::Quit); + +// edit +const QString sc_main_edit ("main_edit"); +const sc_pref sc_main_edit_copy (sc_main_edit + ":copy", QKeySequence::Copy); +const sc_pref sc_main_edit_paste (sc_main_edit + ":paste", QKeySequence::Paste); +const sc_pref sc_main_edit_undo (sc_main_edit + ":undo", QKeySequence::Undo); +const sc_pref sc_main_edit_select_all (sc_main_edit + ":select_all", QKeySequence::SelectAll); +const sc_pref sc_main_edit_clear_clipboard (sc_main_edit + ":clear_clipboard", QKeySequence::UnknownKey); +const sc_pref sc_main_edit_find_in_files (sc_main_edit + ":find_in_files", CTRL_SHIFT + Qt::Key_F); +const sc_pref sc_main_edit_clear_command_window (sc_main_edit + ":clear_command_window", QKeySequence::UnknownKey); +const sc_pref sc_main_edit_clear_history (sc_main_edit + ":clear_history", QKeySequence::UnknownKey); +const sc_pref sc_main_edit_clear_workspace (sc_main_edit + ":clear_workspace", QKeySequence::UnknownKey); +const sc_pref sc_main_edit_set_path (sc_main_edit + ":set_path", QKeySequence::UnknownKey); +const sc_pref sc_main_edit_preferences (sc_main_edit + ":preferences", QKeySequence::UnknownKey); + +// debug +const QString sc_main_debug ("main_debug"); +const sc_pref sc_main_debug_step_over (sc_main_debug + ":step_over", PRE + Qt::Key_F10); +const sc_pref sc_main_debug_step_into (sc_main_debug + ":step_into", PRE + Qt::Key_F11); +const sc_pref sc_main_debug_step_out (sc_main_debug + ":step_out", PRE + Qt::ShiftModifier + Qt::Key_F11); +const sc_pref sc_main_debug_continue (sc_main_debug + ":continue", PRE + Qt::Key_F5); +const sc_pref sc_main_debug_quit (sc_main_debug + ":quit", PRE + Qt::ShiftModifier + Qt::Key_F5); + +// window +const QString sc_main_window ("main_window"); +const sc_pref sc_main_window_show_command (sc_main_window + ":show_command", PRE + CTRL_SHIFT + Qt::Key_0); +const sc_pref sc_main_window_show_history (sc_main_window + ":show_history", PRE + CTRL_SHIFT + Qt::Key_1); +const sc_pref sc_main_window_show_file_browser (sc_main_window + ":show_file_browser", PRE + CTRL_SHIFT + Qt::Key_2); +const sc_pref sc_main_window_show_workspace (sc_main_window + ":show_workspace", PRE + CTRL_SHIFT + Qt::Key_3); +const sc_pref sc_main_window_show_editor (sc_main_window + ":show_editor", PRE + CTRL_SHIFT + Qt::Key_4); +const sc_pref sc_main_window_show_doc (sc_main_window + ":show_doc", PRE + CTRL_SHIFT + Qt::Key_5); +const sc_pref sc_main_window_show_variable_editor (sc_main_window + ":show_variable_editor", PRE + CTRL_SHIFT + Qt::Key_6); +const sc_pref sc_main_window_command (sc_main_window + ":command", PRE + CTRL + Qt::Key_0); +const sc_pref sc_main_window_history (sc_main_window + ":history", PRE + CTRL + Qt::Key_1); +const sc_pref sc_main_window_file_browser (sc_main_window + ":file_browser", PRE + CTRL + Qt::Key_2); +const sc_pref sc_main_window_workspace (sc_main_window + ":workspace", PRE + CTRL + Qt::Key_3); +const sc_pref sc_main_window_editor (sc_main_window + ":editor", PRE + CTRL + Qt::Key_4); +const sc_pref sc_main_window_doc (sc_main_window + ":doc", PRE + CTRL + Qt::Key_5); +const sc_pref sc_main_window_variable_editor (sc_main_window + ":variable_editor", PRE + CTRL + Qt::Key_6); +const sc_pref sc_main_window_reset (sc_main_window + ":reset", QKeySequence::UnknownKey); + +// help +const QString sc_main_help ("main_help"); +const sc_pref sc_main_help_ondisk_doc (sc_main_help + ":ondisk_doc", QKeySequence::UnknownKey); +const sc_pref sc_main_help_online_doc (sc_main_help + ":online_doc", QKeySequence::UnknownKey); +const sc_pref sc_main_help_report_bug (sc_main_help + ":report_bug", QKeySequence::UnknownKey); +const sc_pref sc_main_help_packages (sc_main_help + ":packages", QKeySequence::UnknownKey); +const sc_pref sc_main_help_contribute (sc_main_help + ":contribute", QKeySequence::UnknownKey); +const sc_pref sc_main_help_developer (sc_main_help + ":developer", QKeySequence::UnknownKey); +const sc_pref sc_main_help_about (sc_main_help + ":about", QKeySequence::UnknownKey); + +// news +const QString sc_main_news ("main_news"); +const sc_pref sc_main_news_release_notes (sc_main_news + ":release_notes", QKeySequence::UnknownKey); +const sc_pref sc_main_news_community_news (sc_main_news + ":community_news", QKeySequence::UnknownKey); + +// Tab handling +// The following shortcuts are moved into a separate tab. The key names +// are not change for preserving compatibility with older versions +const QString sc_edit_file ("editor_file"); +const QString sc_edit_file_cl (sc_edit_file + ":close"); +const sc_pref sc_edit_file_close (sc_edit_file_cl, QKeySequence::Close); +const sc_pref sc_edit_file_close_all (sc_edit_file_cl + "_all", QKeySequence::UnknownKey); +const sc_pref sc_edit_file_close_other (sc_edit_file_cl + "_other", QKeySequence::UnknownKey); +const QString sc_edit_tabs ("editor_tabs"); +const sc_pref sc_edit_tabs_switch_left_tab (sc_edit_tabs + ":switch_left_tab", CTRL + Qt::Key_PageUp); +const sc_pref sc_edit_tabs_switch_right_tab (sc_edit_tabs + ":switch_right_tab", CTRL + Qt::Key_PageDown); +const sc_pref sc_edit_tabs_move_tab_left (sc_edit_tabs + ":move_tab_left", Qt::AltModifier + Qt::Key_PageUp); +const sc_pref sc_edit_tabs_move_tab_right (sc_edit_tabs + ":move_tab_right", Qt::AltModifier + Qt::Key_PageDown); + +// Zooming +const QString sc_edit_zoom ("editor_zoom"); // only a group name in the pref dialog +const QString sc_edit_view ("editor_view"); +const QString sc_edit_view_zoom (sc_edit_view + ":zoom"); +const sc_pref sc_edit_view_zoom_in (sc_edit_view_zoom + "_in", QKeySequence::ZoomIn); +const sc_pref sc_edit_view_zoom_out (sc_edit_view_zoom + "_out", QKeySequence::ZoomOut); +#if defined (Q_OS_MAC) +const sc_pref sc_edit_view_zoom_normal (sc_edit_view_zoom + "_normal", CTRL + Qt::Key_Underscore); +#else +const sc_pref sc_edit_view_zoom_normal (sc_edit_view_zoom + "_normal", CTRL + Qt::Key_Period); +#endif + +// Actions of the editor + +// file +const sc_pref sc_edit_file_edit_function (sc_edit_file + ":edit_function", CTRL + Qt::Key_E); +const sc_pref sc_edit_file_save (sc_edit_file + ":save", QKeySequence::Save); +const sc_pref sc_edit_file_save_as (sc_edit_file + ":save_as", QKeySequence::SaveAs); +const sc_pref sc_edit_file_print (sc_edit_file + ":print", QKeySequence::Print); + +// edit +const QString sc_edit_find ("editor_find"); // only a group name in the pref dialog +const QString sc_edit_edit ("editor_edit"); +const QString sc_edit_edit_find (sc_edit_edit + ":find"); +const sc_pref sc_edit_edit_redo (sc_edit_edit + ":redo", QKeySequence::Redo); +const sc_pref sc_edit_edit_cut (sc_edit_edit + ":cut", QKeySequence::Cut); +const sc_pref sc_edit_edit_find_replace (sc_edit_edit_find + "_replace", QKeySequence::Find); +const sc_pref sc_edit_edit_find_next (sc_edit_edit_find + "_next", QKeySequence::FindNext); +const sc_pref sc_edit_edit_find_previous (sc_edit_edit_find + "_previous", QKeySequence::FindPrevious); +const sc_pref sc_edit_edit_delete_start_word (sc_edit_edit + ":delete_start_word", QKeySequence::DeleteStartOfWord); +const sc_pref sc_edit_edit_delete_end_word (sc_edit_edit + ":delete_end_word", QKeySequence::DeleteEndOfWord); +const sc_pref sc_edit_edit_delete_start_line (sc_edit_edit + ":delete_start_line", CTRL_SHIFT + Qt::Key_Backspace); +const sc_pref sc_edit_edit_delete_end_line (sc_edit_edit + ":delete_end_line", CTRL_SHIFT + Qt::Key_Delete); +const sc_pref sc_edit_edit_delete_line (sc_edit_edit + ":delete_line", CTRL_SHIFT + Qt::Key_L); +const sc_pref sc_edit_edit_copy_line (sc_edit_edit + ":copy_line", CTRL_SHIFT + Qt::Key_C); +const sc_pref sc_edit_edit_cut_line (sc_edit_edit + ":cut_line", CTRL_SHIFT + Qt::Key_X); +const sc_pref sc_edit_edit_duplicate_selection (sc_edit_edit + ":duplicate_selection", CTRL + Qt::Key_D); +const sc_pref sc_edit_edit_transpose_line (sc_edit_edit + ":transpose_line", CTRL + Qt::Key_T); +const sc_pref sc_edit_edit_completion_list (sc_edit_edit + ":completion_list", CTRL + Qt::Key_Space); + +const sc_pref sc_edit_edit_comment_selection (sc_edit_edit + ":comment_selection", CTRL + Qt::Key_R); +const sc_pref sc_edit_edit_uncomment_selection (sc_edit_edit + ":uncomment_selection", CTRL_SHIFT + Qt::Key_R); +const sc_pref sc_edit_edit_comment_var_selection (sc_edit_edit + ":comment_var_selection", CTRL_ALT + Qt::Key_R); +const sc_pref sc_edit_edit_upper_case (sc_edit_edit + ":upper_case", CTRL + Qt::Key_U); +const sc_pref sc_edit_edit_lower_case (sc_edit_edit + ":lower_case", CTRL_ALT + Qt::Key_U); + +#if defined (Q_OS_MAC) +const sc_pref sc_edit_edit_indent_selection (sc_edit_edit + ":indent_selection", PRE + Qt::Key_Tab); +const sc_pref sc_edit_edit_unindent_selection (sc_edit_edit + ":unindent_selection", PRE + Qt::ShiftModifier + Qt::Key_Tab); +#else +const sc_pref sc_edit_edit_indent_selection (sc_edit_edit + ":indent_selection", CTRL + Qt::Key_Tab); +const sc_pref sc_edit_edit_unindent_selection (sc_edit_edit + ":unindent_selection", CTRL_SHIFT + Qt::Key_Tab); +#endif +const sc_pref sc_edit_edit_smart_indent_line_or_selection (sc_edit_edit + ":smart_indent_line_or_selection", QKeySequence::UnknownKey); + +const sc_pref sc_edit_edit_conv_eol_winows (sc_edit_edit + ":conv_eol_winows", QKeySequence::UnknownKey); +const sc_pref sc_edit_edit_conv_eol_unix (sc_edit_edit + ":conv_eol_unix", QKeySequence::UnknownKey); +const sc_pref sc_edit_edit_conv_eol_mac (sc_edit_edit + ":conv_eol_mac", QKeySequence::UnknownKey); + +const sc_pref sc_edit_edit_goto_line (sc_edit_edit + ":goto_line", CTRL + Qt::Key_L); +const sc_pref sc_edit_edit_move_to_brace (sc_edit_edit + ":move_to_brace", CTRL + Qt::Key_M); +const sc_pref sc_edit_edit_select_to_brace (sc_edit_edit + ":select_to_brace", CTRL_SHIFT + Qt::Key_M); +const sc_pref sc_edit_edit_toggle_bookmark (sc_edit_edit + ":toggle_bookmark", PRE + Qt::Key_F7); +const sc_pref sc_edit_edit_next_bookmark (sc_edit_edit + ":next_bookmark", PRE + Qt::Key_F2); +const sc_pref sc_edit_edit_previous_bookmark (sc_edit_edit + ":previous_bookmark", PRE + Qt::SHIFT + Qt::Key_F2); +const sc_pref sc_edit_edit_remove_bookmark (sc_edit_edit + ":remove_bookmark", QKeySequence::UnknownKey); + +const sc_pref sc_edit_edit_preferences (sc_edit_edit + ":preferences", QKeySequence::UnknownKey); +const sc_pref sc_edit_edit_styles_preferences (sc_edit_edit + ":styles_preferences", QKeySequence::UnknownKey); + +// view +const sc_pref sc_edit_view_show_line_numbers (sc_edit_view + ":show_line_numbers", QKeySequence::UnknownKey); +const sc_pref sc_edit_view_show_white_spaces (sc_edit_view + ":show_white_spaces", QKeySequence::UnknownKey); +const sc_pref sc_edit_view_show_eol_chars (sc_edit_view + ":show_eol_chars", QKeySequence::UnknownKey); +const sc_pref sc_edit_view_show_ind_guides (sc_edit_view + ":show_ind_guides", QKeySequence::UnknownKey); +const sc_pref sc_edit_view_show_long_line (sc_edit_view + ":show_long_line", QKeySequence::UnknownKey); +const sc_pref sc_edit_view_show_toolbar (sc_edit_view + ":show_toolbar", QKeySequence::UnknownKey); +const sc_pref sc_edit_view_show_statusbar (sc_edit_view + ":show_statusbar", QKeySequence::UnknownKey); +const sc_pref sc_edit_view_show_hscrollbar (sc_edit_view + ":show_hscrollbar", QKeySequence::UnknownKey); +const sc_pref sc_edit_view_sort_tabs (sc_edit_view + ":sort_tabs", QKeySequence::UnknownKey); + +// debug +const QString sc_edit_debug ("editor_debug"); +const sc_pref sc_edit_debug_toggle_breakpoint (sc_edit_debug + ":toggle_breakpoint", QKeySequence::UnknownKey); +const sc_pref sc_edit_debug_next_breakpoint (sc_edit_debug + ":next_breakpoint", QKeySequence::UnknownKey); +const sc_pref sc_edit_debug_previous_breakpoint (sc_edit_debug + ":previous_breakpoint", QKeySequence::UnknownKey); +const sc_pref sc_edit_debug_remove_breakpoints (sc_edit_debug + ":remove_breakpoints", QKeySequence::UnknownKey); + +// run +const QString sc_edit_run ("editor_run"); +const sc_pref sc_edit_run_run_file (sc_edit_run + ":run_file", PRE + Qt::Key_F5); +const sc_pref sc_edit_run_run_selection (sc_edit_run + ":run_selection", PRE + Qt::Key_F9); + +// help +const QString sc_edit_help ("editor_help"); +const sc_pref sc_edit_help_help_keyword (sc_edit_help + ":help_keyword", QKeySequence::HelpContents); +const sc_pref sc_edit_help_doc_keyword (sc_edit_help + ":doc_keyword", Qt::SHIFT + Qt::Key_F1); -const sc_pref sc_main_edit_copy ("shortcuts/main_edit:copy", Qt::CTRL + Qt::Key_C); +// Documentation browser +const QString sc_doc ("doc_browser"); +const sc_pref sc_doc_go_home (sc_doc + ":go_home", Qt::AltModifier + Qt::Key_Home); +const sc_pref sc_doc_go_back (sc_doc + ":go_back", QKeySequence::Back); +const sc_pref sc_doc_go_next (sc_doc + ":go_next", QKeySequence::Forward); + // Other normal, shortcut related options const gui_pref sc_main_ctrld ("shortcuts/main_ctrld", QVariant (false)); + +const gui_pref +sc_prevent_rl_conflicts ("shortcuts/prevent_readline_conflicts", QVariant (true)); + #endif
--- a/libgui/src/gui-preferences.h Wed Dec 11 13:00:31 2019 +0000 +++ b/libgui/src/gui-preferences.h Fri Dec 13 21:33:28 2019 +0100 @@ -53,6 +53,8 @@ // combination of Qt:Keys (resutling in an unsigend int, when added) // or as one of the predefined standard key sequences. +const QString sc_group ("shortcuts/"); // group name is handled separately + struct sc_pref { sc_pref (const QString& key_arg, Qt::Key def_arg)
--- a/libgui/src/gui-settings.cc Wed Dec 11 13:00:31 2019 +0000 +++ b/libgui/src/gui-settings.cc Fri Dec 13 21:33:28 2019 +0100 @@ -31,7 +31,16 @@ namespace octave { - QVariant gui_settings::sc_value (const sc_pref& pref) const + QString gui_settings::sc_value (const sc_pref& pref) const + { + QKeySequence key_seq = sc_def_value (pref); + + // Get the value from the settings where the key sequences are stored + // as strings + return value (sc_group + pref.key, key_seq.toString ()).toString (); + } + + QKeySequence gui_settings::sc_def_value (const sc_pref& pref) const { QKeySequence key_seq = QKeySequence (); @@ -43,11 +52,7 @@ else if (pref.def_std != QKeySequence::UnknownKey) key_seq = QKeySequence (pref.def_std); - // Get the value from the settings where the key sequences are stored - // as strings - return value (pref.key, key_seq.toString ()); + return key_seq; } - // Additional gui_settings functions will be added later. - }
--- a/libgui/src/gui-settings.h Wed Dec 11 13:00:31 2019 +0000 +++ b/libgui/src/gui-settings.h Fri Dec 13 21:33:28 2019 +0100 @@ -62,7 +62,9 @@ return value (pref.key, pref.def); } - QVariant sc_value (const sc_pref& pref) const; + QString sc_value (const sc_pref& pref) const; + + QKeySequence sc_def_value (const sc_pref& pref) const; }; }
--- a/libgui/src/m-editor/file-editor.cc Wed Dec 11 13:00:31 2019 +0000 +++ b/libgui/src/m-editor/file-editor.cc Fri Dec 13 21:33:28 2019 +0100 @@ -42,6 +42,7 @@ #include "file-editor.h" #include "gui-preferences-ed.h" +#include "gui-preferences-sc.h" #include "gui-preferences-global.h" #include "main-window.h" #include "octave-qobject.h" @@ -166,8 +167,8 @@ { resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - QString sc_run = settings->value ("shortcuts/editor_run:run_file").toString (); - QString sc_cont = settings->value ("shortcuts/main_debug:continue").toString (); + QString sc_run = settings->sc_value (sc_edit_run_run_file); + QString sc_cont = settings->sc_value (sc_main_debug_continue); if (sc_run == sc_cont) m_run_action->setShortcut (QKeySequence ()); // prevent ambigous shortcuts @@ -178,7 +179,7 @@ void file_editor::handle_exit_debug_mode (void) { shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager (); - scmgr.set_shortcut (m_run_action, "editor_run:run_file"); + scmgr.set_shortcut (m_run_action, sc_edit_run_run_file); m_run_action->setToolTip (tr ("Save File and Run")); // update tool tip } @@ -1299,87 +1300,87 @@ shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager (); // File menu - scmgr.set_shortcut (m_edit_function_action, "editor_file:edit_function"); - scmgr.set_shortcut (m_save_action, "editor_file:save"); - scmgr.set_shortcut (m_save_as_action, "editor_file:save_as"); - scmgr.set_shortcut (m_close_action, "editor_file:close"); - scmgr.set_shortcut (m_close_all_action, "editor_file:close_all"); - scmgr.set_shortcut (m_close_others_action, "editor_file:close_other"); - scmgr.set_shortcut (m_print_action, "editor_file:print"); + scmgr.set_shortcut (m_edit_function_action, sc_edit_file_edit_function); + scmgr.set_shortcut (m_save_action, sc_edit_file_save); + scmgr.set_shortcut (m_save_as_action, sc_edit_file_save_as); + scmgr.set_shortcut (m_close_action, sc_edit_file_close); + scmgr.set_shortcut (m_close_all_action, sc_edit_file_close_all); + scmgr.set_shortcut (m_close_others_action, sc_edit_file_close_other); + scmgr.set_shortcut (m_print_action, sc_edit_file_print); // Edit menu - scmgr.set_shortcut (m_redo_action, "editor_edit:redo"); - scmgr.set_shortcut (m_cut_action, "editor_edit:cut"); - scmgr.set_shortcut (m_find_action, "editor_edit:find_replace"); - scmgr.set_shortcut (m_find_next_action, "editor_edit:find_next"); - scmgr.set_shortcut (m_find_previous_action, "editor_edit:find_previous"); - - scmgr.set_shortcut (m_delete_start_word_action, "editor_edit:delete_start_word"); - scmgr.set_shortcut (m_delete_end_word_action, "editor_edit:delete_end_word"); - scmgr.set_shortcut (m_delete_start_line_action, "editor_edit:delete_start_line"); - scmgr.set_shortcut (m_delete_end_line_action, "editor_edit:delete_end_line"); - scmgr.set_shortcut (m_delete_line_action, "editor_edit:delete_line"); - scmgr.set_shortcut (m_copy_line_action, "editor_edit:copy_line"); - scmgr.set_shortcut (m_cut_line_action, "editor_edit:cut_line"); - scmgr.set_shortcut (m_duplicate_selection_action, "editor_edit:duplicate_selection"); - scmgr.set_shortcut (m_transpose_line_action, "editor_edit:transpose_line"); - scmgr.set_shortcut (m_comment_selection_action, "editor_edit:comment_selection"); - scmgr.set_shortcut (m_uncomment_selection_action, "editor_edit:uncomment_selection"); - scmgr.set_shortcut (m_comment_var_selection_action, "editor_edit:comment_var_selection"); - - scmgr.set_shortcut (m_upper_case_action, "editor_edit:upper_case"); - scmgr.set_shortcut (m_lower_case_action, "editor_edit:lower_case"); - scmgr.set_shortcut (m_indent_selection_action, "editor_edit:indent_selection"); - scmgr.set_shortcut (m_unindent_selection_action, "editor_edit:unindent_selection"); - scmgr.set_shortcut (m_smart_indent_line_or_selection_action, "editor_edit:smart_indent_line_or_selection"); - scmgr.set_shortcut (m_completion_action, "editor_edit:completion_list"); - scmgr.set_shortcut (m_goto_line_action, "editor_edit:goto_line"); - scmgr.set_shortcut (m_move_to_matching_brace, "editor_edit:move_to_brace"); - scmgr.set_shortcut (m_sel_to_matching_brace, "editor_edit:select_to_brace"); - scmgr.set_shortcut (m_toggle_bookmark_action, "editor_edit:toggle_bookmark"); - scmgr.set_shortcut (m_next_bookmark_action, "editor_edit:next_bookmark"); - scmgr.set_shortcut (m_previous_bookmark_action, "editor_edit:previous_bookmark"); - scmgr.set_shortcut (m_remove_bookmark_action, "editor_edit:remove_bookmark"); - scmgr.set_shortcut (m_preferences_action, "editor_edit:preferences"); - scmgr.set_shortcut (m_styles_preferences_action, "editor_edit:styles_preferences"); - - scmgr.set_shortcut (m_conv_eol_windows_action, "editor_edit:conv_eol_winows"); - scmgr.set_shortcut (m_conv_eol_unix_action, "editor_edit:conv_eol_unix"); - scmgr.set_shortcut (m_conv_eol_mac_action, "editor_edit:conv_eol_mac"); + scmgr.set_shortcut (m_redo_action, sc_edit_edit_redo); + scmgr.set_shortcut (m_cut_action, sc_edit_edit_cut); + scmgr.set_shortcut (m_find_action, sc_edit_edit_find_replace); + scmgr.set_shortcut (m_find_next_action, sc_edit_edit_find_next); + scmgr.set_shortcut (m_find_previous_action, sc_edit_edit_find_previous); + + scmgr.set_shortcut (m_delete_start_word_action, sc_edit_edit_delete_start_word); + scmgr.set_shortcut (m_delete_end_word_action, sc_edit_edit_delete_end_word); + scmgr.set_shortcut (m_delete_start_line_action, sc_edit_edit_delete_start_line); + scmgr.set_shortcut (m_delete_end_line_action, sc_edit_edit_delete_end_line); + scmgr.set_shortcut (m_delete_line_action, sc_edit_edit_delete_line); + scmgr.set_shortcut (m_copy_line_action, sc_edit_edit_copy_line); + scmgr.set_shortcut (m_cut_line_action, sc_edit_edit_cut_line); + scmgr.set_shortcut (m_duplicate_selection_action, sc_edit_edit_duplicate_selection); + scmgr.set_shortcut (m_transpose_line_action, sc_edit_edit_transpose_line); + scmgr.set_shortcut (m_comment_selection_action, sc_edit_edit_comment_selection); + scmgr.set_shortcut (m_uncomment_selection_action, sc_edit_edit_uncomment_selection); + scmgr.set_shortcut (m_comment_var_selection_action, sc_edit_edit_comment_var_selection); + + scmgr.set_shortcut (m_upper_case_action, sc_edit_edit_upper_case); + scmgr.set_shortcut (m_lower_case_action, sc_edit_edit_lower_case); + scmgr.set_shortcut (m_indent_selection_action, sc_edit_edit_indent_selection); + scmgr.set_shortcut (m_unindent_selection_action, sc_edit_edit_unindent_selection); + scmgr.set_shortcut (m_smart_indent_line_or_selection_action, sc_edit_edit_smart_indent_line_or_selection); + scmgr.set_shortcut (m_completion_action, sc_edit_edit_completion_list); + scmgr.set_shortcut (m_goto_line_action, sc_edit_edit_goto_line); + scmgr.set_shortcut (m_move_to_matching_brace, sc_edit_edit_move_to_brace); + scmgr.set_shortcut (m_sel_to_matching_brace, sc_edit_edit_select_to_brace); + scmgr.set_shortcut (m_toggle_bookmark_action, sc_edit_edit_toggle_bookmark); + scmgr.set_shortcut (m_next_bookmark_action, sc_edit_edit_next_bookmark); + scmgr.set_shortcut (m_previous_bookmark_action, sc_edit_edit_previous_bookmark); + scmgr.set_shortcut (m_remove_bookmark_action, sc_edit_edit_remove_bookmark); + scmgr.set_shortcut (m_preferences_action, sc_edit_edit_preferences); + scmgr.set_shortcut (m_styles_preferences_action, sc_edit_edit_styles_preferences); + + scmgr.set_shortcut (m_conv_eol_windows_action, sc_edit_edit_conv_eol_winows); + scmgr.set_shortcut (m_conv_eol_unix_action, sc_edit_edit_conv_eol_unix); + scmgr.set_shortcut (m_conv_eol_mac_action, sc_edit_edit_conv_eol_mac); // View menu - scmgr.set_shortcut (m_show_linenum_action, "editor_view:show_line_numbers"); - scmgr.set_shortcut (m_show_whitespace_action, "editor_view:show_white_spaces"); - scmgr.set_shortcut (m_show_eol_action, "editor_view:show_eol_chars"); - scmgr.set_shortcut (m_show_indguide_action, "editor_view:show_ind_guides"); - scmgr.set_shortcut (m_show_longline_action, "editor_view:show_long_line"); - scmgr.set_shortcut (m_show_toolbar_action, "editor_view:show_toolbar"); - scmgr.set_shortcut (m_show_statusbar_action, "editor_view:show_statusbar"); - scmgr.set_shortcut (m_show_hscrollbar_action, "editor_view:show_hscrollbar"); - scmgr.set_shortcut (m_zoom_in_action, "editor_view:zoom_in"); - scmgr.set_shortcut (m_zoom_out_action, "editor_view:zoom_out"); - scmgr.set_shortcut (m_zoom_normal_action, "editor_view:zoom_normal"); - scmgr.set_shortcut (m_sort_tabs_action, "editor_view:sort_tabs"); + scmgr.set_shortcut (m_show_linenum_action, sc_edit_view_show_line_numbers); + scmgr.set_shortcut (m_show_whitespace_action, sc_edit_view_show_white_spaces); + scmgr.set_shortcut (m_show_eol_action, sc_edit_view_show_eol_chars); + scmgr.set_shortcut (m_show_indguide_action, sc_edit_view_show_ind_guides); + scmgr.set_shortcut (m_show_longline_action, sc_edit_view_show_long_line); + scmgr.set_shortcut (m_show_toolbar_action, sc_edit_view_show_toolbar); + scmgr.set_shortcut (m_show_statusbar_action, sc_edit_view_show_statusbar); + scmgr.set_shortcut (m_show_hscrollbar_action, sc_edit_view_show_hscrollbar); + scmgr.set_shortcut (m_zoom_in_action, sc_edit_view_zoom_in); + scmgr.set_shortcut (m_zoom_out_action, sc_edit_view_zoom_out); + scmgr.set_shortcut (m_zoom_normal_action, sc_edit_view_zoom_normal); + scmgr.set_shortcut (m_sort_tabs_action, sc_edit_view_sort_tabs); // Debug menu - scmgr.set_shortcut (m_toggle_breakpoint_action, "editor_debug:toggle_breakpoint"); - scmgr.set_shortcut (m_next_breakpoint_action, "editor_debug:next_breakpoint"); - scmgr.set_shortcut (m_previous_breakpoint_action, "editor_debug:previous_breakpoint"); - scmgr.set_shortcut (m_remove_all_breakpoints_action, "editor_debug:remove_breakpoints"); + scmgr.set_shortcut (m_toggle_breakpoint_action, sc_edit_debug_toggle_breakpoint); + scmgr.set_shortcut (m_next_breakpoint_action, sc_edit_debug_next_breakpoint); + scmgr.set_shortcut (m_previous_breakpoint_action, sc_edit_debug_previous_breakpoint); + scmgr.set_shortcut (m_remove_all_breakpoints_action, sc_edit_debug_remove_breakpoints); // Run menu - scmgr.set_shortcut (m_run_action, "editor_run:run_file"); - scmgr.set_shortcut (m_run_selection_action, "editor_run:run_selection"); + scmgr.set_shortcut (m_run_action, sc_edit_run_run_file); + scmgr.set_shortcut (m_run_selection_action, sc_edit_run_run_selection); // Help menu - scmgr.set_shortcut (m_context_help_action, "editor_help:help_keyword"); - scmgr.set_shortcut (m_context_doc_action, "editor_help:doc_keyword"); + scmgr.set_shortcut (m_context_help_action, sc_edit_help_help_keyword); + scmgr.set_shortcut (m_context_doc_action, sc_edit_help_doc_keyword); // Tab navigation without menu entries - scmgr.set_shortcut (m_switch_left_tab_action, "editor_tabs:switch_left_tab"); - scmgr.set_shortcut (m_switch_right_tab_action, "editor_tabs:switch_right_tab"); - scmgr.set_shortcut (m_move_tab_left_action, "editor_tabs:move_tab_left"); - scmgr.set_shortcut (m_move_tab_right_action, "editor_tabs:move_tab_right"); + scmgr.set_shortcut (m_switch_left_tab_action, sc_edit_tabs_switch_left_tab); + scmgr.set_shortcut (m_switch_right_tab_action, sc_edit_tabs_switch_right_tab); + scmgr.set_shortcut (m_move_tab_left_action, sc_edit_tabs_move_tab_left); + scmgr.set_shortcut (m_move_tab_right_action, sc_edit_tabs_move_tab_right); }
--- a/libgui/src/main-window.cc Wed Dec 11 13:00:31 2019 +0000 +++ b/libgui/src/main-window.cc Fri Dec 13 21:33:28 2019 +0100 @@ -61,6 +61,7 @@ #include "gui-preferences-global.h" #include "gui-preferences-mw.h" #include "gui-preferences-nr.h" +#include "gui-preferences-sc.h" #include "gui-settings.h" #include "interpreter-qobject.h" #include "main-window.h" @@ -901,7 +902,8 @@ m_status_bar->hide (); m_prevent_readline_conflicts - = settings->value ("shortcuts/prevent_readline_conflicts", true).toBool (); + = settings->value (sc_prevent_rl_conflicts.key, + sc_prevent_rl_conflicts.def).toBool (); m_suppress_dbg_location = ! settings->value ("terminal/print_debug_location", false).toBool (); @@ -2742,63 +2744,63 @@ shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager (); // file menu - scmgr.set_shortcut (m_open_action, "main_file:open_file"); - scmgr.set_shortcut (m_new_script_action, "main_file:new_file"); - scmgr.set_shortcut (m_new_function_action, "main_file:new_function"); - scmgr.set_shortcut (m_new_function_action, "main_file:new_figure"); - scmgr.set_shortcut (m_load_workspace_action, "main_file:load_workspace"); - scmgr.set_shortcut (m_save_workspace_action, "main_file:save_workspace"); - scmgr.set_shortcut (m_exit_action, "main_file:exit"); + scmgr.set_shortcut (m_open_action, sc_main_file_open_file); + scmgr.set_shortcut (m_new_script_action, sc_main_file_new_file); + scmgr.set_shortcut (m_new_function_action, sc_main_file_new_function); + scmgr.set_shortcut (m_new_function_action, sc_main_file_new_figure); + scmgr.set_shortcut (m_load_workspace_action, sc_main_file_load_workspace); + scmgr.set_shortcut (m_save_workspace_action, sc_main_file_save_workspace); + scmgr.set_shortcut (m_exit_action, sc_main_file_exit); // edit menu - scmgr.set_shortcut (m_copy_action, "main_edit:copy"); - scmgr.set_shortcut (m_paste_action, "main_edit:paste"); - scmgr.set_shortcut (m_undo_action, "main_edit:undo"); - scmgr.set_shortcut (m_select_all_action, "main_edit:select_all"); - scmgr.set_shortcut (m_clear_clipboard_action, "main_edit:clear_clipboard"); - scmgr.set_shortcut (m_find_files_action, "main_edit:find_in_files"); - scmgr.set_shortcut (m_clear_command_history_action, "main_edit:clear_history"); - scmgr.set_shortcut (m_clear_command_window_action, "main_edit:clear_command_window"); - scmgr.set_shortcut (m_clear_workspace_action, "main_edit:clear_workspace"); - scmgr.set_shortcut (m_set_path_action, "main_edit:set_path"); - scmgr.set_shortcut (m_preferences_action, "main_edit:preferences"); + scmgr.set_shortcut (m_copy_action, sc_main_edit_copy); + scmgr.set_shortcut (m_paste_action, sc_main_edit_paste); + scmgr.set_shortcut (m_undo_action, sc_main_edit_undo); + scmgr.set_shortcut (m_select_all_action, sc_main_edit_select_all); + scmgr.set_shortcut (m_clear_clipboard_action, sc_main_edit_clear_clipboard); + scmgr.set_shortcut (m_find_files_action, sc_main_edit_find_in_files); + scmgr.set_shortcut (m_clear_command_history_action, sc_main_edit_clear_history); + scmgr.set_shortcut (m_clear_command_window_action, sc_main_edit_clear_command_window); + scmgr.set_shortcut (m_clear_workspace_action, sc_main_edit_clear_workspace); + scmgr.set_shortcut (m_set_path_action, sc_main_edit_set_path); + scmgr.set_shortcut (m_preferences_action, sc_main_edit_preferences); // debug menu - scmgr.set_shortcut (m_debug_step_over, "main_debug:step_over"); - scmgr.set_shortcut (m_debug_step_into, "main_debug:step_into"); - scmgr.set_shortcut (m_debug_step_out, "main_debug:step_out"); - scmgr.set_shortcut (m_debug_continue, "main_debug:continue"); - scmgr.set_shortcut (m_debug_quit, "main_debug:quit"); + scmgr.set_shortcut (m_debug_step_over, sc_main_debug_step_over); + scmgr.set_shortcut (m_debug_step_into, sc_main_debug_step_into); + scmgr.set_shortcut (m_debug_step_out, sc_main_debug_step_out); + scmgr.set_shortcut (m_debug_continue, sc_main_debug_continue); + scmgr.set_shortcut (m_debug_quit, sc_main_debug_quit); // window menu - scmgr.set_shortcut (m_show_command_window_action, "main_window:show_command"); - scmgr.set_shortcut (m_show_history_action, "main_window:show_history"); - scmgr.set_shortcut (m_show_workspace_action, "main_window:show_workspace"); - scmgr.set_shortcut (m_show_file_browser_action, "main_window:show_file_browser"); - scmgr.set_shortcut (m_show_editor_action, "main_window:show_editor"); - scmgr.set_shortcut (m_show_documentation_action, "main_window:show_doc"); - scmgr.set_shortcut (m_show_variable_editor_action, "main_window:show_variable_editor"); - scmgr.set_shortcut (m_command_window_action, "main_window:command"); - scmgr.set_shortcut (m_history_action, "main_window:history"); - scmgr.set_shortcut (m_workspace_action, "main_window:workspace"); - scmgr.set_shortcut (m_file_browser_action, "main_window:file_browser"); - scmgr.set_shortcut (m_editor_action, "main_window:editor"); - scmgr.set_shortcut (m_documentation_action, "main_window:doc"); - scmgr.set_shortcut (m_variable_editor_action, "main_window:variable_editor"); - scmgr.set_shortcut (m_reset_windows_action, "main_window:reset"); + scmgr.set_shortcut (m_show_command_window_action, sc_main_window_show_command); + scmgr.set_shortcut (m_show_history_action, sc_main_window_show_history); + scmgr.set_shortcut (m_show_workspace_action, sc_main_window_show_workspace); + scmgr.set_shortcut (m_show_file_browser_action, sc_main_window_show_file_browser); + scmgr.set_shortcut (m_show_editor_action, sc_main_window_show_editor); + scmgr.set_shortcut (m_show_documentation_action, sc_main_window_show_doc); + scmgr.set_shortcut (m_show_variable_editor_action, sc_main_window_show_variable_editor); + scmgr.set_shortcut (m_command_window_action, sc_main_window_command); + scmgr.set_shortcut (m_history_action, sc_main_window_history); + scmgr.set_shortcut (m_workspace_action, sc_main_window_workspace); + scmgr.set_shortcut (m_file_browser_action, sc_main_window_file_browser); + scmgr.set_shortcut (m_editor_action, sc_main_window_editor); + scmgr.set_shortcut (m_documentation_action, sc_main_window_doc); + scmgr.set_shortcut (m_variable_editor_action, sc_main_window_variable_editor); + scmgr.set_shortcut (m_reset_windows_action, sc_main_window_reset); // help menu - scmgr.set_shortcut (m_ondisk_doc_action, "main_help:ondisk_doc"); - scmgr.set_shortcut (m_online_doc_action, "main_help:online_doc"); - scmgr.set_shortcut (m_report_bug_action, "main_help:report_bug"); - scmgr.set_shortcut (m_octave_packages_action, "main_help:packages"); - scmgr.set_shortcut (m_contribute_action, "main_help:contribute"); - scmgr.set_shortcut (m_developer_action, "main_help:developer"); - scmgr.set_shortcut (m_about_octave_action, "main_help:about"); + scmgr.set_shortcut (m_ondisk_doc_action, sc_main_help_ondisk_doc); + scmgr.set_shortcut (m_online_doc_action, sc_main_help_online_doc); + scmgr.set_shortcut (m_report_bug_action, sc_main_help_report_bug); + scmgr.set_shortcut (m_octave_packages_action, sc_main_help_packages); + scmgr.set_shortcut (m_contribute_action, sc_main_help_contribute); + scmgr.set_shortcut (m_developer_action, sc_main_help_developer); + scmgr.set_shortcut (m_about_octave_action, sc_main_help_about); // news menu - scmgr.set_shortcut (m_release_notes_action, "main_news:release_notes"); - scmgr.set_shortcut (m_current_news_action, "main_news:community_news"); + scmgr.set_shortcut (m_release_notes_action, sc_main_news_release_notes); + scmgr.set_shortcut (m_current_news_action, sc_main_news_community_news); } QList<octave_dock_widget *> main_window::dock_widget_list (void)
--- a/libgui/src/settings-dialog.cc Wed Dec 11 13:00:31 2019 +0000 +++ b/libgui/src/settings-dialog.cc Fri Dec 13 21:33:28 2019 +0100 @@ -444,7 +444,9 @@ shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager (); - cb_prevent_readline_conflicts->setChecked (settings->value ("shortcuts/prevent_readline_conflicts", true).toBool ()); + cb_prevent_readline_conflicts->setChecked ( + settings->value (sc_prevent_rl_conflicts.key, + sc_prevent_rl_conflicts.def).toBool ()); // initialize the tree view with all shortcut data scmgr.fill_treewidget (shortcuts_treewidget); @@ -1030,7 +1032,7 @@ // shortcuts - settings->setValue ("shortcuts/prevent_readline_conflicts", cb_prevent_readline_conflicts->isChecked ()); + settings->setValue (sc_prevent_rl_conflicts.key, cb_prevent_readline_conflicts->isChecked ()); shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager (); scmgr.write_shortcuts (settings, closing);
--- a/libgui/src/shortcut-manager.cc Wed Dec 11 13:00:31 2019 +0000 +++ b/libgui/src/shortcut-manager.cc Fri Dec 13 21:33:28 2019 +0100 @@ -42,6 +42,7 @@ #include "octave-qobject.h" #include "shortcut-manager.h" #include "gui-preferences-global.h" +#include "gui-preferences-sc.h" #include "error.h" namespace octave @@ -122,278 +123,177 @@ void shortcut_manager::init_data (void) { - Qt::KeyboardModifier ctrl; - int prefix; -#if defined (Q_OS_MAC) - // Use CMD key as an equivalent of Ctrl key on other platforms - ctrl = Qt::MetaModifier; - // Some of octave default shortcuts on windows/linux are already defined - // as system wide shortcuts on Mac Os X (almost all Function keys). - // Prefix those with Option (Alt) modifier to avoid conflicts. - prefix = Qt::AltModifier; -#else - ctrl = Qt::ControlModifier; - prefix = Qt::NoModifier; -#endif - - Qt::KeyboardModifiers ctrl_shift = ctrl | Qt::ShiftModifier; - Qt::KeyboardModifiers ctrl_alt = ctrl | Qt::AltModifier; - // actions of the main window resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - settings->setValue ("shortcuts/main_ctrld",false); // reset use fo ctrl-d + settings->setValue (sc_main_ctrld.key, false); // reset use fo ctrl-d // file - init (tr ("New File"), "main_file:new_file", QKeySequence::New); - init (tr ("New Function"), "main_file:new_function", - QKeySequence (ctrl_shift + Qt::Key_N)); - init (tr ("New Figure"), "main_file:new_figure", QKeySequence ()); - init (tr ("Open File"), "main_file:open_file", QKeySequence::Open); - init (tr ("Load Workspace"), "main_file:load_workspace", QKeySequence ()); - init (tr ("Save Workspace As"), "main_file:save_workspace", QKeySequence ()); - init (tr ("Exit Octave"), "main_file:exit", QKeySequence::Quit); + init (tr ("New File"), sc_main_file_new_file); + init (tr ("New Function"), sc_main_file_new_function); + init (tr ("New Figure"), sc_main_file_new_figure); + init (tr ("Open File"), sc_main_file_open_file); + init (tr ("Load Workspace"), sc_main_file_load_workspace); + init (tr ("Save Workspace As"), sc_main_file_save_workspace); + init (tr ("Exit Octave"), sc_main_file_exit); // edit - init (tr ("Copy"), "main_edit:copy", QKeySequence::Copy); - init (tr ("Paste"), "main_edit:paste", QKeySequence::Paste); - init (tr ("Undo"), "main_edit:undo", QKeySequence::Undo); - init (tr ("Select All"), "main_edit:select_all", QKeySequence::SelectAll); - init (tr ("Clear Clipboard"), "main_edit:clear_clipboard", QKeySequence ()); - init (tr ("Find in Files"), "main_edit:find_in_files", - QKeySequence (ctrl_shift + Qt::Key_F)); - init (tr ("Clear Command Window"), "main_edit:clear_command_window", - QKeySequence ()); - init (tr ("Clear Command History"), "main_edit:clear_history", - QKeySequence ()); - init (tr ("Clear Workspace"), "main_edit:clear_workspace", QKeySequence ()); - init (tr ("Set Path"), "main_edit:set_path", QKeySequence ()); - init (tr ("Preferences"), "main_edit:preferences", QKeySequence ()); + init (tr ("Copy"), sc_main_edit_copy); + init (tr ("Paste"), sc_main_edit_paste); + init (tr ("Undo"), sc_main_edit_undo); + init (tr ("Select All"), sc_main_edit_select_all); + init (tr ("Clear Clipboard"), sc_main_edit_clear_clipboard); + init (tr ("Find in Files"), sc_main_edit_find_in_files); + init (tr ("Clear Command Window"), sc_main_edit_clear_command_window); + init (tr ("Clear Command History"), sc_main_edit_clear_history); + init (tr ("Clear Workspace"), sc_main_edit_clear_workspace); + init (tr ("Set Path"), sc_main_edit_set_path); + init (tr ("Preferences"), sc_main_edit_preferences); // debug - init (tr ("Step"), "main_debug:step_over", - QKeySequence (prefix + Qt::Key_F10)); - init (tr ("Step Into"), "main_debug:step_into", - QKeySequence (prefix + Qt::Key_F11)); - init (tr ("Step Out"), "main_debug:step_out", - QKeySequence (prefix + Qt::ShiftModifier + Qt::Key_F11)); - init (tr ("Continue"), "main_debug:continue", - QKeySequence (prefix + Qt::Key_F5)); - init (tr ("Quit Debug Mode"), "main_debug:quit", - QKeySequence (prefix + Qt::ShiftModifier + Qt::Key_F5)); + init (tr ("Step"), sc_main_debug_step_over); + init (tr ("Step Into"), sc_main_debug_step_into); + init (tr ("Step Out"), sc_main_debug_step_out); + init (tr ("Continue"), sc_main_debug_continue); + init (tr ("Quit Debug Mode"), sc_main_debug_quit); // window - init (tr ("Show Command Window"), "main_window:show_command", - prefix + ctrl_shift + Qt::Key_0); - init (tr ("Show Command History"), "main_window:show_history", - prefix + ctrl_shift + Qt::Key_1); - init (tr ("Show File Browser"), "main_window:show_file_browser", - prefix + ctrl_shift + Qt::Key_2); - init (tr ("Show Workspace"), "main_window:show_workspace", - prefix + ctrl_shift + Qt::Key_3); - init (tr ("Show Editor"), "main_window:show_editor", - prefix + ctrl_shift + Qt::Key_4); - init (tr ("Show Documentation"), "main_window:show_doc", - prefix + ctrl_shift + Qt::Key_5); - init (tr ("Show Variable Editor"), "main_window:show_variable_editor", - prefix + ctrl_shift + Qt::Key_6); - init (tr ("Command Window"), "main_window:command", - prefix + ctrl + Qt::Key_0); - init (tr ("Command History"), "main_window:history", - prefix + ctrl + Qt::Key_1); - init (tr ("File Browser"), "main_window:file_browser", - prefix + ctrl + Qt::Key_2); - init (tr ("Workspace"), "main_window:workspace", - prefix + ctrl + Qt::Key_3); - init (tr ("Editor"), "main_window:editor", - prefix + ctrl + Qt::Key_4); - init (tr ("Documentation"), "main_window:doc", - prefix + ctrl + Qt::Key_5); - init (tr ("Variable Editor"), "main_window:variable_editor", - prefix + ctrl + Qt::Key_6); - init (tr ("Reset Default Window Layout"), "main_window:reset", QKeySequence ()); + init (tr ("Show Command Window"), sc_main_window_show_command); + init (tr ("Show Command History"), sc_main_window_show_history); + init (tr ("Show File Browser"), sc_main_window_show_file_browser); + init (tr ("Show Workspace"), sc_main_window_show_workspace); + init (tr ("Show Editor"), sc_main_window_show_editor); + init (tr ("Show Documentation"), sc_main_window_show_doc); + init (tr ("Show Variable Editor"), sc_main_window_show_variable_editor); + init (tr ("Command Window"), sc_main_window_command); + init (tr ("Command History"), sc_main_window_history); + init (tr ("File Browser"), sc_main_window_file_browser); + init (tr ("Workspace"), sc_main_window_workspace); + init (tr ("Editor"), sc_main_window_editor); + init (tr ("Documentation"), sc_main_window_doc); + init (tr ("Variable Editor"), sc_main_window_variable_editor); + init (tr ("Reset Default Window Layout"), sc_main_window_reset); // help - init (tr ("Show Ondisk Documentation"), "main_help:ondisk_doc", - QKeySequence ()); - init (tr ("Show Online Documentation"), "main_help:online_doc", - QKeySequence ()); - init (tr ("Report Bug"), "main_help:report_bug", QKeySequence ()); - init (tr ("Octave Packages"), "main_help:packages", QKeySequence ()); - init (tr ("Contribute to Octave"), "main_help:contribute", QKeySequence ()); - init (tr ("Octave Developer Resources"), "main_help:developer", - QKeySequence ()); - init (tr ("About Octave"), "main_help:about", QKeySequence ()); + init (tr ("Show Ondisk Documentation"), sc_main_help_ondisk_doc); + init (tr ("Show Online Documentation"), sc_main_help_online_doc); + init (tr ("Report Bug"), sc_main_help_report_bug); + init (tr ("Octave Packages"), sc_main_help_packages); + init (tr ("Contribute to Octave"), sc_main_help_contribute); + init (tr ("Octave Developer Resources"), sc_main_help_developer); + init (tr ("About Octave"), sc_main_help_about); // news - init (tr ("Release Notes"), "main_news:release_notes", QKeySequence ()); - init (tr ("Community News"), "main_news:community_news", QKeySequence ()); + init (tr ("Release Notes"), sc_main_news_release_notes); + init (tr ("Community News"), sc_main_news_community_news); // Tab handling // The following shortcuts are moved into a separate tab. The key names // are not change for preserving compatibility with older versions - init (tr ("Close Tab"), "editor_file:close", QKeySequence::Close); - init (tr ("Close All Tabs"), "editor_file:close_all", QKeySequence ()); - init (tr ("Close Other Tabs"), "editor_file:close_other", QKeySequence ()); - init (tr ("Switch to Left Tab"), "editor_tabs:switch_left_tab", - QKeySequence (ctrl + Qt::Key_PageUp)); - init (tr ("Switch to Right Tab"), "editor_tabs:switch_right_tab", - QKeySequence (ctrl + Qt::Key_PageDown)); - init (tr ("Move Tab Left"), "editor_tabs:move_tab_left", - QKeySequence (Qt::AltModifier + Qt::Key_PageUp)); - init (tr ("Move Tab Right"), "editor_tabs:move_tab_right", - QKeySequence (Qt::AltModifier + Qt::Key_PageDown)); + init (tr ("Close Tab"), sc_edit_file_close); + init (tr ("Close All Tabs"), sc_edit_file_close_all); + init (tr ("Close Other Tabs"), sc_edit_file_close_other); + init (tr ("Switch to Left Tab"), sc_edit_tabs_switch_left_tab); + init (tr ("Switch to Right Tab"), sc_edit_tabs_switch_right_tab); + init (tr ("Move Tab Left"), sc_edit_tabs_move_tab_left); + init (tr ("Move Tab Right"), sc_edit_tabs_move_tab_right); // Zooming - init (tr ("Zoom In"), "editor_view:zoom_in", QKeySequence::ZoomIn); - init (tr ("Zoom Out"), "editor_view:zoom_out", QKeySequence::ZoomOut); + init (tr ("Zoom In"), sc_edit_view_zoom_in); + init (tr ("Zoom Out"), sc_edit_view_zoom_out); #if defined (Q_OS_MAC) - init (tr ("Zoom Normal"), "editor_view:zoom_normal", - QKeySequence (ctrl + Qt::Key_Underscore)); + init (tr ("Zoom Normal"), sc_edit_view_zoom_normal); #else - init (tr ("Zoom Normal"), "editor_view:zoom_normal", - QKeySequence (ctrl + Qt::Key_Period)); + init (tr ("Zoom Normal"), sc_edit_view_zoom_normal); #endif // actions of the editor // file - init (tr ("Edit Function"), "editor_file:edit_function", - QKeySequence (ctrl + Qt::Key_E)); - init (tr ("Save File"), "editor_file:save", QKeySequence::Save); - init (tr ("Save File As"), "editor_file:save_as", QKeySequence::SaveAs); - init (tr ("Print"), "editor_file:print", QKeySequence::Print); + init (tr ("Edit Function"), sc_edit_file_edit_function); + init (tr ("Save File"), sc_edit_file_save); + init (tr ("Save File As"), sc_edit_file_save_as); + init (tr ("Print"), sc_edit_file_print); // edit - init (tr ("Redo"), "editor_edit:redo", QKeySequence::Redo); - init (tr ("Cut"), "editor_edit:cut", QKeySequence::Cut); - init (tr ("Find and Replace"), "editor_edit:find_replace", - QKeySequence::Find); - init (tr ("Find Next"), "editor_edit:find_next", - QKeySequence::FindNext); - init (tr ("Find Previous"), "editor_edit:find_previous", - QKeySequence::FindPrevious); - init (tr ("Delete to Start of Word"), "editor_edit:delete_start_word", - QKeySequence::DeleteStartOfWord); - init (tr ("Delete to End of Word"), "editor_edit:delete_end_word", - QKeySequence::DeleteEndOfWord); - init (tr ("Delete to Start of Line"), "editor_edit:delete_start_line", - QKeySequence (ctrl_shift + Qt::Key_Backspace)); - init (tr ("Delete to End of Line"), "editor_edit:delete_end_line", - QKeySequence (ctrl_shift + Qt::Key_Delete)); - init (tr ("Delete Line"), "editor_edit:delete_line", - QKeySequence (ctrl_shift + Qt::Key_L)); - init (tr ("Copy Line"), "editor_edit:copy_line", - QKeySequence (ctrl_shift + Qt::Key_C)); - init (tr ("Cut Line"), "editor_edit:cut_line", - QKeySequence (ctrl_shift + Qt::Key_X)); - init (tr ("Duplicate Selection/Line"), "editor_edit:duplicate_selection", - QKeySequence (ctrl + Qt::Key_D)); - init (tr ("Transpose Line"), "editor_edit:transpose_line", - QKeySequence (ctrl + Qt::Key_T)); - init (tr ("Show Completion List"), "editor_edit:completion_list", - QKeySequence (ctrl + Qt::Key_Space)); + init (tr ("Redo"), sc_edit_edit_redo); + init (tr ("Cut"), sc_edit_edit_cut); + init (tr ("Find and Replace"), sc_edit_edit_find_replace); + init (tr ("Find Next"), sc_edit_edit_find_next); + init (tr ("Find Previous"), sc_edit_edit_find_previous); + init (tr ("Delete to Start of Word"), sc_edit_edit_delete_start_word); + init (tr ("Delete to End of Word"), sc_edit_edit_delete_end_word); + init (tr ("Delete to Start of Line"), sc_edit_edit_delete_start_line); + init (tr ("Delete to End of Line"), sc_edit_edit_delete_end_line); + init (tr ("Delete Line"), sc_edit_edit_delete_line); + init (tr ("Copy Line"), sc_edit_edit_copy_line); + init (tr ("Cut Line"), sc_edit_edit_cut_line); + init (tr ("Duplicate Selection/Line"), sc_edit_edit_duplicate_selection); + init (tr ("Transpose Line"), sc_edit_edit_transpose_line); + init (tr ("Show Completion List"), sc_edit_edit_completion_list); - init (tr ("Comment Selection"), "editor_edit:comment_selection", - QKeySequence (ctrl + Qt::Key_R)); - init (tr ("Uncomment Selection"), "editor_edit:uncomment_selection", - QKeySequence (ctrl_shift + Qt::Key_R)); - init (tr ("Comment Selection (Choosing String)"), "editor_edit:comment_var_selection", - QKeySequence (ctrl_alt + Qt::Key_R)); - init (tr ("Uppercase Selection"), "editor_edit:upper_case", - QKeySequence (ctrl + Qt::Key_U)); - init (tr ("Lowercase Selection"), "editor_edit:lower_case", - QKeySequence (ctrl_alt + Qt::Key_U)); + init (tr ("Comment Selection"), sc_edit_edit_comment_selection); + init (tr ("Uncomment Selection"), sc_edit_edit_uncomment_selection); + init (tr ("Comment Selection (Choosing String)"), sc_edit_edit_comment_var_selection); + init (tr ("Uppercase Selection"), sc_edit_edit_upper_case); + init (tr ("Lowercase Selection"), sc_edit_edit_lower_case); #if defined (Q_OS_MAC) - init (tr ("Indent Selection Rigidly"), "editor_edit:indent_selection", - QKeySequence (prefix + Qt::Key_Tab)); - init (tr ("Unindent Selection Rigidly"), "editor_edit:unindent_selection", - QKeySequence (prefix + Qt::ShiftModifier + Qt::Key_Tab)); + init (tr ("Indent Selection Rigidly"), sc_edit_edit_indent_selection); + init (tr ("Unindent Selection Rigidly"), sc_edit_edit_unindent_selection); #else - init (tr ("Indent Selection Rigidly"), "editor_edit:indent_selection", - QKeySequence (ctrl + Qt::Key_Tab)); - init (tr ("Unindent Selection Rigidly"), "editor_edit:unindent_selection", - QKeySequence (ctrl_shift + Qt::Key_Tab)); + init (tr ("Indent Selection Rigidly"), sc_edit_edit_indent_selection); + init (tr ("Unindent Selection Rigidly"), sc_edit_edit_unindent_selection); #endif - init (tr ("Indent Code"), "editor_edit:smart_indent_line_or_selection", - QKeySequence ()); + init (tr ("Indent Code"), sc_edit_edit_smart_indent_line_or_selection); - init (tr ("Convert Line Endings to Windows"), "editor_edit:conv_eol_winows", - QKeySequence ()); - init (tr ("Convert Line Endings to Unix"), "editor_edit:conv_eol_unix", - QKeySequence ()); - init (tr ("Convert Line Endings to Mac"), "editor_edit:conv_eol_mac", - QKeySequence ()); + init (tr ("Convert Line Endings to Windows"), sc_edit_edit_conv_eol_winows); + init (tr ("Convert Line Endings to Unix"), sc_edit_edit_conv_eol_unix); + init (tr ("Convert Line Endings to Mac"), sc_edit_edit_conv_eol_mac); - init (tr ("Goto Line"), "editor_edit:goto_line", - QKeySequence (ctrl + Qt::Key_L)); - init (tr ("Move to Matching Brace"), "editor_edit:move_to_brace", - QKeySequence (ctrl + Qt::Key_M)); - init (tr ("Select to Matching Brace"), "editor_edit:select_to_brace", - QKeySequence (ctrl_shift + Qt::Key_M)); - init (tr ("Toggle Bookmark"), "editor_edit:toggle_bookmark", - QKeySequence (prefix + Qt::Key_F7)); - init (tr ("Next Bookmark"), "editor_edit:next_bookmark", - QKeySequence (prefix + Qt::Key_F2)); - init (tr ("Previous Bookmark"), "editor_edit:previous_bookmark", - QKeySequence (prefix + Qt::SHIFT + Qt::Key_F2)); - init (tr ("Remove All Bookmark"), "editor_edit:remove_bookmark", - QKeySequence ()); + init (tr ("Goto Line"), sc_edit_edit_goto_line); + init (tr ("Move to Matching Brace"), sc_edit_edit_move_to_brace); + init (tr ("Select to Matching Brace"), sc_edit_edit_select_to_brace); + init (tr ("Toggle Bookmark"), sc_edit_edit_toggle_bookmark); + init (tr ("Next Bookmark"), sc_edit_edit_next_bookmark); + init (tr ("Previous Bookmark"), sc_edit_edit_previous_bookmark); + init (tr ("Remove All Bookmark"), sc_edit_edit_remove_bookmark); - init (tr ("Preferences"), "editor_edit:preferences", QKeySequence ()); - init (tr ("Styles Preferences"), "editor_edit:styles_preferences", - QKeySequence ()); + init (tr ("Preferences"), sc_edit_edit_preferences); + init (tr ("Styles Preferences"), sc_edit_edit_styles_preferences); // view - init (tr ("Show Line Numbers"), "editor_view:show_line_numbers", - QKeySequence ()); - init (tr ("Show Whitespace Characters"), "editor_view:show_white_spaces", - QKeySequence ()); - init (tr ("Show Line Endings"), "editor_view:show_eol_chars", QKeySequence ()); - init (tr ("Show Indentation Guides"), "editor_view:show_ind_guides", - QKeySequence ()); - init (tr ("Show Long Line Marker"), "editor_view:show_long_line", - QKeySequence ()); - init (tr ("Show Toolbar"), "editor_view:show_toolbar", - QKeySequence ()); - init (tr ("Show Statusbar"), "editor_view:show_statusbar", - QKeySequence ()); - init (tr ("Show Horizontal Scrollbar"), "editor_view:show_hscrollbar", - QKeySequence ()); - init (tr ("Sort Tabs Alphabetically"), "editor_view:sort_tabs", - QKeySequence ()); + init (tr ("Show Line Numbers"), sc_edit_view_show_line_numbers); + init (tr ("Show Whitespace Characters"), sc_edit_view_show_white_spaces); + init (tr ("Show Line Endings"), sc_edit_view_show_eol_chars); + init (tr ("Show Indentation Guides"), sc_edit_view_show_ind_guides); + init (tr ("Show Long Line Marker"), sc_edit_view_show_long_line); + init (tr ("Show Toolbar"), sc_edit_view_show_toolbar); + init (tr ("Show Statusbar"), sc_edit_view_show_statusbar); + init (tr ("Show Horizontal Scrollbar"), sc_edit_view_show_hscrollbar); + init (tr ("Sort Tabs Alphabetically"), sc_edit_view_sort_tabs); // debug - init (tr ("Toggle Breakpoint"), "editor_debug:toggle_breakpoint", - QKeySequence ()); - init (tr ("Next Breakpoint"), "editor_debug:next_breakpoint", - QKeySequence ()); - init (tr ("Previous Breakpoint"), "editor_debug:previous_breakpoint", - QKeySequence ()); - init (tr ("Remove All Breakpoints"), "editor_debug:remove_breakpoints", - QKeySequence ()); + init (tr ("Toggle Breakpoint"), sc_edit_debug_toggle_breakpoint); + init (tr ("Next Breakpoint"), sc_edit_debug_next_breakpoint); + init (tr ("Previous Breakpoint"), sc_edit_debug_previous_breakpoint); + init (tr ("Remove All Breakpoints"), sc_edit_debug_remove_breakpoints); // run - init (tr ("Run File"), "editor_run:run_file", - QKeySequence (prefix + Qt::Key_F5)); - init (tr ("Run Selection"), "editor_run:run_selection", - QKeySequence (prefix + Qt::Key_F9)); + init (tr ("Run File"), sc_edit_run_run_file); + init (tr ("Run Selection"), sc_edit_run_run_selection); // help - init (tr ("Help on Keyword"), "editor_help:help_keyword", - QKeySequence::HelpContents); - init (tr ("Document on Keyword"), "editor_help:doc_keyword", - QKeySequence (Qt::SHIFT + Qt::Key_F1)); + init (tr ("Help on Keyword"), sc_edit_help_help_keyword); + init (tr ("Document on Keyword"), sc_edit_help_doc_keyword); // Documentation browser - init (tr ("Go to Homepage"), "doc_browser:go_home", - QKeySequence (Qt::AltModifier + Qt::Key_Home)); - init (tr ("Go Back one Page"), "doc_browser:go_back", QKeySequence::Back); - init (tr ("Go Forward one Page"), "doc_browser:go_next", QKeySequence::Forward); + init (tr ("Go to Homepage"), sc_doc_go_home); + init (tr ("Go Back one Page"), sc_doc_go_back); + init (tr ("Go Forward one Page"), sc_doc_go_next); } // write one or all actual shortcut set(s) into a settings file @@ -402,17 +302,20 @@ { bool sc_ctrld = false; + QString sc_main + = sc_main_file.mid (0, sc_main_file.indexOf ('_') + 1); + for (int i = 0; i < m_sc.count (); i++) // loop over all shortcuts { - settings->setValue ("shortcuts/" + m_sc.at (i).m_settings_key, + settings->setValue (sc_group + "/" + m_sc.at (i).m_settings_key, m_sc.at (i).m_actual_sc.toString ()); // special: check main-window for Ctrl-D (Terminal) - if (m_sc.at (i).m_settings_key.startsWith ("main_") + if (m_sc.at (i).m_settings_key.startsWith (sc_main) && m_sc.at (i).m_actual_sc == QKeySequence (Qt::ControlModifier+Qt::Key_D)) sc_ctrld = true; } - settings->setValue ("shortcuts/main_ctrld",sc_ctrld); + settings->setValue (sc_main_ctrld.key, sc_ctrld); if (closing) { @@ -423,36 +326,36 @@ settings->sync (); // sync the settings file } - void shortcut_manager::set_shortcut (QAction *action, const QString& key) + void shortcut_manager::set_shortcut (QAction *action, const sc_pref& scpref) { int index; - index = m_action_hash[key] - 1; - - resource_manager& rmgr = m_octave_qobj.get_resource_manager (); - gui_settings *settings = rmgr.get_settings (); + index = m_action_hash[scpref.key] - 1; if (index > -1 && index < m_sc.count ()) - action->setShortcut - (QKeySequence (settings->value ("shortcuts/" + key, m_sc.at (index).m_default_sc).toString ())); + { + resource_manager& rmgr = m_octave_qobj.get_resource_manager (); + gui_settings *settings = rmgr.get_settings (); + action->setShortcut (QKeySequence (settings->sc_value (scpref))); + } else - qDebug () << "Key: " << key << " not found in m_action_hash"; + qDebug () << "Key: " << scpref.key << " not found in m_action_hash"; } - void shortcut_manager::shortcut (QShortcut *sc, const QString& key) + void shortcut_manager::shortcut (QShortcut *sc, const sc_pref& scpref) { int index; - index = m_action_hash[key] - 1; - - resource_manager& rmgr = m_octave_qobj.get_resource_manager (); - gui_settings *settings = rmgr.get_settings (); + index = m_action_hash[scpref.key] - 1; if (index > -1 && index < m_sc.count ()) - sc->setKey (QKeySequence (settings->value ("shortcuts/" + key, - m_sc.at (index).m_default_sc).toString ())); + { + resource_manager& rmgr = m_octave_qobj.get_resource_manager (); + gui_settings *settings = rmgr.get_settings (); + sc->setKey (QKeySequence (settings->sc_value (scpref))); + } else - qDebug () << "Key: " << key << " not found in m_action_hash"; + qDebug () << "Key: " << scpref.key << " not found in m_action_hash"; } void shortcut_manager::fill_treewidget (QTreeWidget *tree_view) @@ -488,16 +391,15 @@ QTreeWidgetItem *main_zoom = new QTreeWidgetItem (main); main_zoom->setText (0, tr ("Zooming in Editor and Documentation")); - m_level_hash["main_file"] = main_file; - m_level_hash["main_edit"] = main_edit; - m_level_hash["main_debug"] = main_debug; - m_level_hash["main_window"] = main_window; - m_level_hash["main_help"] = main_help; - m_level_hash["main_news"] = main_news; - m_level_hash["main_tabs"] = main_tabs; - m_level_hash["editor_tabs"] = main_tabs; - m_level_hash["editor_find"] = main_find; - m_level_hash["editor_zoom"] = main_zoom; + m_level_hash[sc_main_file] = main_file; + m_level_hash[sc_main_edit] = main_edit; + m_level_hash[sc_main_debug] = main_debug; + m_level_hash[sc_main_window] = main_window; + m_level_hash[sc_main_help] = main_help; + m_level_hash[sc_main_news] = main_news; + m_level_hash[sc_edit_tabs] = main_tabs; + m_level_hash[sc_edit_find] = main_find; + m_level_hash[sc_edit_zoom] = main_zoom; QTreeWidgetItem *editor = new QTreeWidgetItem (tree_view); editor->setText (0, tr ("Editor")); @@ -515,12 +417,12 @@ QTreeWidgetItem *editor_help = new QTreeWidgetItem (editor); editor_help->setText (0, tr ("Help Menu")); - m_level_hash["editor_file"] = editor_file; - m_level_hash["editor_edit"] = editor_edit; - m_level_hash["editor_view"] = editor_view; - m_level_hash["editor_debug"] = editor_debug; - m_level_hash["editor_run"] = editor_run; - m_level_hash["editor_help"] = editor_help; + m_level_hash[sc_edit_file] = editor_file; + m_level_hash[sc_edit_edit] = editor_edit; + m_level_hash[sc_edit_view] = editor_view; + m_level_hash[sc_edit_debug] = editor_debug; + m_level_hash[sc_edit_run] = editor_run; + m_level_hash[sc_edit_help] = editor_help; QTreeWidgetItem *doc = new QTreeWidgetItem (tree_view); doc->setText (0, tr ("Documentation Viewer")); @@ -529,7 +431,7 @@ QTreeWidgetItem *doc_browser = new QTreeWidgetItem (doc); doc_browser->setText (0, tr ("Browser")); - m_level_hash["doc_browser"] = doc_browser; + m_level_hash[sc_doc] = doc_browser; connect (tree_view, SIGNAL (itemDoubleClicked (QTreeWidgetItem*, int)), this, SLOT (handle_double_clicked (QTreeWidgetItem*, int))); @@ -545,19 +447,19 @@ if (section == editor_file) { // Closing tabs now in global tab handling section - if (sc.m_settings_key.contains ("editor_file:close")) + if (sc.m_settings_key.contains (sc_edit_file_cl)) section = main_tabs; } if (section == editor_edit) { // Find & replace now in global file & replace handling section - if (sc.m_settings_key.contains ("editor_edit:find")) + if (sc.m_settings_key.contains (sc_edit_edit_find)) section = main_find; } if (section == editor_view) { // Zooming now in global zoom handling section - if (sc.m_settings_key.contains ("editor_view:zoom")) + if (sc.m_settings_key.contains (sc_edit_view_zoom)) section = main_zoom; } @@ -702,32 +604,32 @@ m_edit_actual->setText (m_label_default->text ()); } - void shortcut_manager::init (const QString& description, const QString& key, - const QKeySequence& def_sc) + void shortcut_manager::init (const QString& description, const sc_pref& sc) { resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); - QKeySequence actual - = QKeySequence (settings->value ("shortcuts/" + key, def_sc).toString ()); + QKeySequence actual = QKeySequence (settings->sc_value (sc)); // append the new shortcut to the list shortcut_t shortcut_info; shortcut_info.m_description = description; - shortcut_info.m_settings_key = key; + shortcut_info.m_settings_key = sc.key; shortcut_info.m_actual_sc = actual; - shortcut_info.m_default_sc = def_sc; + shortcut_info.m_default_sc = settings->sc_def_value (sc); m_sc << shortcut_info; // insert shortcut in order check for duplicates later if (! actual.isEmpty ()) m_shortcut_hash[actual.toString ()] = m_sc.count (); - m_action_hash[key] = m_sc.count (); + m_action_hash[sc.key] = m_sc.count (); // check whether ctrl+d is used from main window, i.e. is a global shortcut - if (key.startsWith ("main_") + QString main_group_prefix + = sc_main_file.mid (0, sc_main_file.indexOf ('_') + 1); + if (sc.key.startsWith (main_group_prefix) && actual == QKeySequence (Qt::ControlModifier+Qt::Key_D)) - settings->setValue ("shortcuts/main_ctrld",true); + settings->setValue (sc_main_ctrld.key, true); } void shortcut_manager::shortcut_dialog (int index) @@ -831,7 +733,7 @@ if (settings) sc.m_actual_sc = QKeySequence ( // get new shortcut from settings - settings->value ("shortcuts/" + sc.m_settings_key,sc.m_actual_sc). + settings->value (sc_group + sc.m_settings_key,sc.m_actual_sc). toString ()); // and use the old one as default else sc.m_actual_sc = QKeySequence (sc.m_default_sc); // get default shortcut
--- a/libgui/src/shortcut-manager.h Wed Dec 11 13:00:31 2019 +0000 +++ b/libgui/src/shortcut-manager.h Fri Dec 13 21:33:28 2019 +0100 @@ -87,9 +87,9 @@ void write_shortcuts (gui_settings *settings, bool closing); - void set_shortcut (QAction *action, const QString& key); + void set_shortcut (QAction *action, const sc_pref& scpref); - void shortcut (QShortcut *sc, const QString& key); + void shortcut (QShortcut *sc, const sc_pref& scpref); void fill_treewidget (QTreeWidget *tree_view); @@ -103,7 +103,7 @@ private: - void init (const QString&, const QString&, const QKeySequence&); + void init (const QString&, const sc_pref& scpref); void shortcut_dialog (int); void import_shortcuts (gui_settings *settings); bool overwrite_all_shortcuts (void);