Mercurial > octave
diff 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 |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Sun Jul 28 21:51:26 2019 -0700 +++ b/libgui/src/main-window.cc Mon Jul 22 23:51:01 2019 -0400 @@ -103,8 +103,8 @@ m_doc_browser_window (nullptr), m_editor_window (nullptr), m_workspace_window (nullptr), m_variable_editor_window (nullptr), m_external_editor (new external_editor_interface (this)), - m_active_editor (m_external_editor), - m_settings_dlg (nullptr), m_find_files_dlg (nullptr), + m_active_editor (m_external_editor), m_settings_dlg (nullptr), + m_find_files_dlg (nullptr), m_set_path_dlg (nullptr), m_release_notes_window (nullptr), m_community_news_window (nullptr), m_clipboard (QApplication::clipboard ()), m_prevent_readline_conflicts (true), m_suppress_dbg_location (true), @@ -236,7 +236,7 @@ delete m_find_files_dlg; delete m_release_notes_window; - delete m_settings_dlg; + delete m_community_news_window; delete m_community_news_window; } @@ -1707,6 +1707,18 @@ focus_command_window (); // make sure that the command window has focus } + void main_window::handle_set_path_dialog_request (void) + { + if (m_set_path_dlg) // m_set_path_dlg is a guarded pointer! + return; + + m_set_path_dlg = new set_path_dialog (this); + + m_set_path_dlg->setModal (false); + m_set_path_dlg->setAttribute (Qt::WA_DeleteOnClose); + m_set_path_dlg->show (); + } + void main_window::find_files (const QString& start_dir) { @@ -1764,6 +1776,7 @@ m_load_workspace_action->setShortcut (no_key); m_save_workspace_action->setShortcut (no_key); m_preferences_action->setShortcut (no_key); + m_set_path_action->setShortcut (no_key); m_exit_action->setShortcut (no_key); // edit menu @@ -2407,6 +2420,9 @@ edit_menu->addSeparator (); + m_set_path_action + = edit_menu->addAction (tr ("Set Path")); + m_preferences_action = edit_menu->addAction (resource_manager::icon ("preferences-system"), tr ("Preferences...")); @@ -2436,6 +2452,10 @@ connect (m_preferences_action, SIGNAL (triggered (void)), this, SLOT (process_settings_dialog_request (void))); + + connect (m_set_path_action, SIGNAL (triggered (void)), + this, SLOT (handle_set_path_dialog_request (void))); + } QAction * main_window::construct_debug_menu_item (const char *icon, @@ -2769,7 +2789,6 @@ "main_file:load_workspace"); shortcut_manager::set_shortcut (m_save_workspace_action, "main_file:save_workspace"); - shortcut_manager::set_shortcut (m_preferences_action, "main_file:preferences"); shortcut_manager::set_shortcut (m_exit_action,"main_file:exit"); // edit menu @@ -2786,6 +2805,8 @@ "main_edit:clear_command_window"); shortcut_manager::set_shortcut (m_clear_workspace_action, "main_edit:clear_workspace"); + shortcut_manager::set_shortcut (m_set_path_action, "main_edit:set_path"); + shortcut_manager::set_shortcut (m_preferences_action, "main_edit:preferences"); // debug menu shortcut_manager::set_shortcut (m_debug_step_over, "main_debug:step_over");