Mercurial > hg > octave-lojdl
changeset 16566:662a712b8fd5
partial menu bar cleanup
* file-editor-interface.h (file_editor_interface::request_new_script,
file_editor_interface::request_new_function): New functions.
* file-editor.h, file-editor.cc (file_editor::request_new_script,
file_editor::request_new_function): New functions.
* main-window.h, main-window.cc (main_window::construct_desktop_menu):
Delete function and all uses.
(main_window::handle_new_figure_request,
main_window::handle_new_variable_request,
main_window::new_figure_callback): New functions.
(main_window::construct_file_menu, main_window::construct_edit_menu):
Delete close_command_window_action, import_data_action,
page_setup_action, print_action, print_selection_action,
new_class_action, new_enumeration_action, new_gui_action,
paste_to_workspace_action, find_action. Move load_workspace_action to
file_menu.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 25 Apr 2013 02:42:45 -0400 |
parents | e4b94abfeb96 |
children | 68176102fe07 |
files | libgui/src/m-editor/file-editor-interface.h libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h libgui/src/main-window.cc libgui/src/main-window.h |
diffstat | 5 files changed, 75 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-interface.h +++ b/libgui/src/m-editor/file-editor-interface.h @@ -65,6 +65,8 @@ public slots: virtual void request_new_file (const QString& command = QString ()) = 0; + virtual void request_new_script (const QString& command = QString ()) = 0; + virtual void request_new_function (const QString& command = QString ()) = 0; virtual void request_open_file () = 0; virtual void request_open_file (const QString& openFileName, int line = -1, bool debug_pointer = false,
--- a/libgui/src/m-editor/file-editor.cc +++ b/libgui/src/m-editor/file-editor.cc @@ -151,6 +151,31 @@ } void +file_editor::request_new_script (const QString& commands) +{ + request_new_file (commands); +} + +void +file_editor::request_new_function (const QString& commands) +{ + QString text = commands; + + if (text.isEmpty ()) + text = "## Copyright (C)\n" + "\n" + "## -*- texinfo -*-\n" + "## @deftypefn {Function File} {[outputs] =} unamed_function (inputs)\n" + "## @end deftypefn\n" + "\n" + "function [outputs] = unnamed_function (inputs)\n" + "\n" + "endfunction\n"; + + request_new_file (text); +} + +void file_editor::request_open_file (void) { // Open file isn't a file_editor_tab function since the file
--- a/libgui/src/m-editor/file-editor.h +++ b/libgui/src/m-editor/file-editor.h @@ -103,6 +103,8 @@ void handle_visibility (bool visible); void request_new_file (const QString& commands); + void request_new_script (const QString& commands); + void request_new_function (const QString& commands); void request_open_file (void); void request_mru_open_file (void); void request_print_file (void);
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -196,6 +196,19 @@ } void +main_window::handle_new_figure_request (void) +{ + octave_link::post_event (this, &main_window::new_figure_callback); +} + +void +main_window::handle_new_variable_request (void) +{ + QMessageBox::about (this, tr ("New Variable"), + tr ("The new variable action is not implemented.")); +} + +void main_window::open_online_documentation_page (void) { QDesktopServices::openUrl (QUrl ("http://gnu.org/software/octave/doc/interpreter")); @@ -810,8 +823,6 @@ construct_debug_menu (menu_bar); - construct_desktop_menu (menu_bar); - construct_window_menu (menu_bar); construct_help_menu (menu_bar); @@ -834,16 +845,10 @@ file_menu->addMenu (editor_window->get_mru_menu ()); #endif - QAction *close_command_window_action - = file_menu->addAction (tr ("Close Command Window")); - close_command_window_action->setShortcut (QKeySequence::Close); - close_command_window_action->setEnabled (false); // TODO: Make this work. - file_menu->addSeparator (); - QAction *import_data_action - = file_menu->addAction (tr ("Import Data")); - import_data_action->setEnabled (false); // TODO: Make this work. + QAction *load_workspace_action + = file_menu->addAction (tr ("Load workspace")); QAction *save_workspace_action = file_menu->addAction (tr ("Save Workspace As")); @@ -856,21 +861,6 @@ file_menu->addSeparator (); - QAction *page_setup_action - = file_menu->addAction (tr ("Page Setup...")); - page_setup_action->setEnabled (false); // TODO: Make this work. - - QAction *print_action - = file_menu->addAction (tr ("Print")); - print_action->setShortcut (QKeySequence::Print); - print_action->setEnabled (false); // TODO: Make this work. - - QAction *print_selection_action - = file_menu->addAction (tr ("Print Selection...")); - print_selection_action->setEnabled (false); // TODO: Make this work. - - file_menu->addSeparator (); - QAction *exit_action = file_menu->addAction (tr ("Exit")); exit_action->setShortcut (QKeySequence::Quit); @@ -880,6 +870,9 @@ connect (_open_action, SIGNAL (triggered ()), editor_window, SLOT (request_open_file ())); + connect (load_workspace_action, SIGNAL (triggered ()), + this, SLOT (handle_load_workspace_request ())); + connect (save_workspace_action, SIGNAL (triggered ()), this, SLOT (handle_save_workspace_request ())); @@ -893,33 +886,29 @@ QMenu *new_menu = p->addMenu (tr ("New")); _new_script_action - = new_menu->addAction (QIcon (":/actions/icons/filenew.png"), tr ("Script")); - _new_script_action->setShortcut (QKeySequence::New); - _new_script_action->setShortcutContext (Qt::ApplicationShortcut); + = new_menu->addAction (QIcon (":/actions/icons/filenew.png"), + tr ("Script")); QAction *new_function_action = new_menu->addAction (tr ("Function")); - new_function_action->setEnabled (false); // TODO: Make this work. - - QAction *new_class_action = new_menu->addAction (tr ("Class")); - new_class_action->setEnabled (false); // TODO: Make this work. - - QAction *new_enumeration_action = new_menu->addAction (tr ("Enumeration")); - new_enumeration_action->setEnabled (false); // TODO: Make this work. + new_function_action->setEnabled (true); QAction *new_figure_action = new_menu->addAction (tr ("Figure")); - new_figure_action->setEnabled (false); // TODO: Make this work. + new_figure_action->setEnabled (true); QAction *new_variable_action = new_menu->addAction (tr ("Variable")); - new_variable_action->setEnabled (false); // TODO: Make this work. - - QAction *new_model_action = new_menu->addAction (tr ("Model")); - new_model_action->setEnabled (false); // TODO: Make this work. - - QAction *new_gui_action = new_menu->addAction (tr ("GUI")); - new_gui_action->setEnabled (false); // TODO: Make this work. + new_variable_action->setEnabled (true); connect (_new_script_action, SIGNAL (triggered ()), - editor_window, SLOT (request_new_file ())); + editor_window, SLOT (request_new_script ())); + + connect (new_function_action, SIGNAL (triggered ()), + editor_window, SLOT (request_new_function ())); + + connect (new_figure_action, SIGNAL (triggered ()), + this, SLOT (handle_new_figure_request ())); + + connect (new_variable_action, SIGNAL (triggered ()), + this, SLOT (handle_new_variable_request ())); } void @@ -947,12 +936,6 @@ = edit_menu->addAction (QIcon (":/actions/icons/editpaste.png"), tr ("Paste")); _paste_action->setShortcut (ctrl_shift + Qt::Key_V); - QAction *paste_to_workspace_action - = edit_menu->addAction (tr ("Paste To Workspace...")); - paste_to_workspace_action->setEnabled (false); // TODO: Make this work. - - edit_menu->addSeparator (); - QAction *select_all_action = edit_menu->addAction (tr ("Select All")); select_all_action->setEnabled (false); // TODO: Make this work. @@ -964,10 +947,6 @@ edit_menu->addSeparator (); - QAction *find_action - = edit_menu->addAction (tr ("Find...")); - find_action->setEnabled (false); // TODO: Make this work. - QAction *find_files_action = edit_menu->addAction (tr ("Find Files...")); find_files_action->setShortcut (ctrl_shift + Qt::Key_F); @@ -1063,17 +1042,6 @@ this, SLOT (debug_quit ())); } -void -main_window::construct_desktop_menu (QMenuBar *p) -{ - QMenu *desktop_menu = p->addMenu (tr ("&Desktop")); - - QAction *load_workspace_action = desktop_menu->addAction (tr ("Load workspace")); - - connect (load_workspace_action, SIGNAL (triggered ()), - this, SLOT (handle_load_workspace_request ())); -} - QAction * main_window::construct_window_menu_item (QMenu *p, const QString& item, bool checkable, @@ -1369,6 +1337,13 @@ } void +main_window::new_figure_callback (void) +{ + Fbuiltin (ovl ("figure")); + Fdrawnow (); +} + +void main_window::change_directory_callback (const std::string& directory) { Fcd (ovl (directory));
--- a/libgui/src/main-window.h +++ b/libgui/src/main-window.h @@ -111,6 +111,10 @@ void handle_command_double_clicked (const QString& command); + void handle_new_figure_request (void); + + void handle_new_variable_request (void); + void handle_enter_debugger (void); void handle_exit_debugger (void); void debug_continue (void); @@ -164,7 +168,6 @@ const QString& item, const QKeySequence& key); void construct_debug_menu (QMenuBar *p); - void construct_desktop_menu (QMenuBar *p); QAction *construct_window_menu_item (QMenu *p, const QString& item, bool checkable, const QKeySequence& key); @@ -192,6 +195,8 @@ void clear_history_callback (void); + void new_figure_callback (void); + void change_directory_callback (const std::string& directory); void debug_continue_callback (void);