Mercurial > octave
comparison libgui/src/main-window.cc @ 27298:1805f8586179
new gui dialog for modifying octaves load path (bug #43549)
Originally submitted by JunWang,
Edited by Rik, jwe, and Torsten.
* main-window.cc (main_window): initialize new m_settings_dlg class variable;
(~main_window): delete set path dialog;
(handle_set_path_dialog_request): new slot for opening the path dialog;
(set_global_shortcuts): set shortcut for opening new path dialog;
(construct_edit_menu): add and connect related action to the edit menu;
(configure_shortcuts): read the shortcut from the preferences file
* main-window.h: include path dialog header, new path variable and new action
for dialog
* module.mk: add new files
* set-path-dialog.cc: new file
(set_path_dialog): constructing the dialog with widgets and buttons,
connecting all action signals, adding model object;
(add_dir): open file dailog to select directory to be added to the path;
(rm_dir): call rm_dir method in model object for removing selected dirs;
(move_dir_up, move_dir_bottom, move_dir_top, move_dir_bottom):
call related model object for moving selected dirs and update selection
and view accordingly;
* set-path-dialog.h: new header for path dialog
* set-path-model.cc: new file for path dialog model
(set_path_model): data signal connections and calling construct method;
(to_string): make a string from the current list of directories;
(model_to_path): set the octave path to the current model data;
(clear): clear the current model data;
(save): save current model data using savepath;
(revert) reset the model data to the state from dialog start;
(revert_last): Reset the model data to the state before the latest change;
(add_dir): add a directory to the current model data and path;
(rm_dir): remoce a directory from current model data and path;
(move_dir_up, move_dir_down, move_dir_top, move_dir_bottom): move one ore
more directory entries wihtin the path;
(rowCount): retiurn the size if the current model data;
(data): reimplemeneted method for returning data from the model;
(construct): loading the current path into the model;
(update_data): slot for update data signal
* set-path-model.h: model header file
* shortcut-manager.cc (do_init_data): initialize shortcut for path dialog
with empty key sequence
author | JunWang <jstzwj@aliyun.com> |
---|---|
date | Mon, 22 Jul 2019 23:51:01 -0400 |
parents | 871313d4b948 |
children | 5f170ea12fa1 |
comparison
equal
deleted
inserted
replaced
27297:6ac42f6615bb | 27298:1805f8586179 |
---|---|
101 m_status_bar (nullptr), m_command_window (nullptr), | 101 m_status_bar (nullptr), m_command_window (nullptr), |
102 m_history_window (nullptr), m_file_browser_window (nullptr), | 102 m_history_window (nullptr), m_file_browser_window (nullptr), |
103 m_doc_browser_window (nullptr), m_editor_window (nullptr), | 103 m_doc_browser_window (nullptr), m_editor_window (nullptr), |
104 m_workspace_window (nullptr), m_variable_editor_window (nullptr), | 104 m_workspace_window (nullptr), m_variable_editor_window (nullptr), |
105 m_external_editor (new external_editor_interface (this)), | 105 m_external_editor (new external_editor_interface (this)), |
106 m_active_editor (m_external_editor), | 106 m_active_editor (m_external_editor), m_settings_dlg (nullptr), |
107 m_settings_dlg (nullptr), m_find_files_dlg (nullptr), | 107 m_find_files_dlg (nullptr), m_set_path_dlg (nullptr), |
108 m_release_notes_window (nullptr), m_community_news_window (nullptr), | 108 m_release_notes_window (nullptr), m_community_news_window (nullptr), |
109 m_clipboard (QApplication::clipboard ()), | 109 m_clipboard (QApplication::clipboard ()), |
110 m_prevent_readline_conflicts (true), m_suppress_dbg_location (true), | 110 m_prevent_readline_conflicts (true), m_suppress_dbg_location (true), |
111 m_closing (false), m_file_encoding (QString ()) | 111 m_closing (false), m_file_encoding (QString ()) |
112 { | 112 { |
234 delete m_workspace_model; | 234 delete m_workspace_model; |
235 delete m_variable_editor_window; | 235 delete m_variable_editor_window; |
236 | 236 |
237 delete m_find_files_dlg; | 237 delete m_find_files_dlg; |
238 delete m_release_notes_window; | 238 delete m_release_notes_window; |
239 delete m_settings_dlg; | 239 delete m_community_news_window; |
240 delete m_community_news_window; | 240 delete m_community_news_window; |
241 } | 241 } |
242 | 242 |
243 bool main_window::command_window_has_focus (void) const | 243 bool main_window::command_window_has_focus (void) const |
244 { | 244 { |
1705 } | 1705 } |
1706 | 1706 |
1707 focus_command_window (); // make sure that the command window has focus | 1707 focus_command_window (); // make sure that the command window has focus |
1708 } | 1708 } |
1709 | 1709 |
1710 void main_window::handle_set_path_dialog_request (void) | |
1711 { | |
1712 if (m_set_path_dlg) // m_set_path_dlg is a guarded pointer! | |
1713 return; | |
1714 | |
1715 m_set_path_dlg = new set_path_dialog (this); | |
1716 | |
1717 m_set_path_dlg->setModal (false); | |
1718 m_set_path_dlg->setAttribute (Qt::WA_DeleteOnClose); | |
1719 m_set_path_dlg->show (); | |
1720 } | |
1721 | |
1710 void main_window::find_files (const QString& start_dir) | 1722 void main_window::find_files (const QString& start_dir) |
1711 { | 1723 { |
1712 | 1724 |
1713 if (! m_find_files_dlg) | 1725 if (! m_find_files_dlg) |
1714 { | 1726 { |
1762 m_new_function_action->setShortcut (no_key); | 1774 m_new_function_action->setShortcut (no_key); |
1763 m_new_function_action->setShortcut (no_key); | 1775 m_new_function_action->setShortcut (no_key); |
1764 m_load_workspace_action->setShortcut (no_key); | 1776 m_load_workspace_action->setShortcut (no_key); |
1765 m_save_workspace_action->setShortcut (no_key); | 1777 m_save_workspace_action->setShortcut (no_key); |
1766 m_preferences_action->setShortcut (no_key); | 1778 m_preferences_action->setShortcut (no_key); |
1779 m_set_path_action->setShortcut (no_key); | |
1767 m_exit_action->setShortcut (no_key); | 1780 m_exit_action->setShortcut (no_key); |
1768 | 1781 |
1769 // edit menu | 1782 // edit menu |
1770 m_select_all_action->setShortcut (no_key); | 1783 m_select_all_action->setShortcut (no_key); |
1771 m_clear_clipboard_action->setShortcut (no_key); | 1784 m_clear_clipboard_action->setShortcut (no_key); |
2405 m_clear_workspace_action | 2418 m_clear_workspace_action |
2406 = edit_menu->addAction (tr ("Clear Workspace")); | 2419 = edit_menu->addAction (tr ("Clear Workspace")); |
2407 | 2420 |
2408 edit_menu->addSeparator (); | 2421 edit_menu->addSeparator (); |
2409 | 2422 |
2423 m_set_path_action | |
2424 = edit_menu->addAction (tr ("Set Path")); | |
2425 | |
2410 m_preferences_action | 2426 m_preferences_action |
2411 = edit_menu->addAction (resource_manager::icon ("preferences-system"), | 2427 = edit_menu->addAction (resource_manager::icon ("preferences-system"), |
2412 tr ("Preferences...")); | 2428 tr ("Preferences...")); |
2413 | 2429 |
2414 connect (m_find_files_action, SIGNAL (triggered (void)), | 2430 connect (m_find_files_action, SIGNAL (triggered (void)), |
2434 m_clear_clipboard_action->setEnabled (true); | 2450 m_clear_clipboard_action->setEnabled (true); |
2435 #endif | 2451 #endif |
2436 | 2452 |
2437 connect (m_preferences_action, SIGNAL (triggered (void)), | 2453 connect (m_preferences_action, SIGNAL (triggered (void)), |
2438 this, SLOT (process_settings_dialog_request (void))); | 2454 this, SLOT (process_settings_dialog_request (void))); |
2455 | |
2456 connect (m_set_path_action, SIGNAL (triggered (void)), | |
2457 this, SLOT (handle_set_path_dialog_request (void))); | |
2458 | |
2439 } | 2459 } |
2440 | 2460 |
2441 QAction * main_window::construct_debug_menu_item (const char *icon, | 2461 QAction * main_window::construct_debug_menu_item (const char *icon, |
2442 const QString& item, | 2462 const QString& item, |
2443 const char *member) | 2463 const char *member) |
2767 shortcut_manager::set_shortcut (m_new_function_action, "main_file:new_figure"); | 2787 shortcut_manager::set_shortcut (m_new_function_action, "main_file:new_figure"); |
2768 shortcut_manager::set_shortcut (m_load_workspace_action, | 2788 shortcut_manager::set_shortcut (m_load_workspace_action, |
2769 "main_file:load_workspace"); | 2789 "main_file:load_workspace"); |
2770 shortcut_manager::set_shortcut (m_save_workspace_action, | 2790 shortcut_manager::set_shortcut (m_save_workspace_action, |
2771 "main_file:save_workspace"); | 2791 "main_file:save_workspace"); |
2772 shortcut_manager::set_shortcut (m_preferences_action, "main_file:preferences"); | |
2773 shortcut_manager::set_shortcut (m_exit_action,"main_file:exit"); | 2792 shortcut_manager::set_shortcut (m_exit_action,"main_file:exit"); |
2774 | 2793 |
2775 // edit menu | 2794 // edit menu |
2776 shortcut_manager::set_shortcut (m_copy_action, "main_edit:copy"); | 2795 shortcut_manager::set_shortcut (m_copy_action, "main_edit:copy"); |
2777 shortcut_manager::set_shortcut (m_paste_action, "main_edit:paste"); | 2796 shortcut_manager::set_shortcut (m_paste_action, "main_edit:paste"); |
2784 "main_edit:clear_history"); | 2803 "main_edit:clear_history"); |
2785 shortcut_manager::set_shortcut (m_clear_command_window_action, | 2804 shortcut_manager::set_shortcut (m_clear_command_window_action, |
2786 "main_edit:clear_command_window"); | 2805 "main_edit:clear_command_window"); |
2787 shortcut_manager::set_shortcut (m_clear_workspace_action, | 2806 shortcut_manager::set_shortcut (m_clear_workspace_action, |
2788 "main_edit:clear_workspace"); | 2807 "main_edit:clear_workspace"); |
2808 shortcut_manager::set_shortcut (m_set_path_action, "main_edit:set_path"); | |
2809 shortcut_manager::set_shortcut (m_preferences_action, "main_edit:preferences"); | |
2789 | 2810 |
2790 // debug menu | 2811 // debug menu |
2791 shortcut_manager::set_shortcut (m_debug_step_over, "main_debug:step_over"); | 2812 shortcut_manager::set_shortcut (m_debug_step_over, "main_debug:step_over"); |
2792 shortcut_manager::set_shortcut (m_debug_step_into, "main_debug:step_into"); | 2813 shortcut_manager::set_shortcut (m_debug_step_into, "main_debug:step_into"); |
2793 shortcut_manager::set_shortcut (m_debug_step_out, "main_debug:step_out"); | 2814 shortcut_manager::set_shortcut (m_debug_step_out, "main_debug:step_out"); |