comparison libgui/src/m-editor/file-editor.cc @ 18767:095fdef3d67c gui-release

use editors run selection action for the context menu * file-editor-tab.cc (constructor): initialize flag for octave file; (update_lexer): set flag for octave file; (set_file_name, handle_copy_available, change_editor_state): editor_state_changed signal uses flag for octave file; * file-editor-tab.h: flag for octave file, also used in editor_state_changed * file-editor.cc (create_context_menu): add action for running selection; (handle_editor_state_changed): gets flag whether file is an octave script, enable run action and run selection action depending on selection and file type; (add_file_editor_tab): connect editor_state_changed to handle_editor_state_changedwith new third parameter; * file-editor.h: handle_editor_state_changed has a new third parameter * octave-qscintilla.cc (contextMenuEvent): run selection is added by the edtior
author Torsten <ttl@justmail.de>
date Fri, 16 May 2014 20:01:27 +0200
parents 64bd9afac22c
children b2c4d6d461f0
comparison
equal deleted inserted replaced
18760:be569698970c 18767:095fdef3d67c
963 menu->addAction (_cut_action); 963 menu->addAction (_cut_action);
964 menu->addAction (_copy_action); 964 menu->addAction (_copy_action);
965 menu->addAction (_paste_action); 965 menu->addAction (_paste_action);
966 menu->addSeparator (); 966 menu->addSeparator ();
967 menu->addAction (_selectall_action); 967 menu->addAction (_selectall_action);
968 menu->addSeparator ();
969 menu->addAction (_run_selection_action);
968 } 970 }
969 971
970 void 972 void
971 file_editor::zoom_in (bool) 973 file_editor::zoom_in (bool)
972 { 974 {
992 _redo_action->setEnabled (redo); 994 _redo_action->setEnabled (redo);
993 } 995 }
994 996
995 void 997 void
996 file_editor::handle_editor_state_changed (bool copy_available, 998 file_editor::handle_editor_state_changed (bool copy_available,
997 const QString& file_name) 999 const QString& file_name,
1000 bool is_octave_file)
998 { 1001 {
999 // In case there is some scenario where traffic could be coming from 1002 // In case there is some scenario where traffic could be coming from
1000 // all the file editor tabs, just process info from the current active tab. 1003 // all the file editor tabs, just process info from the current active tab.
1001 if (sender () == _tab_widget->currentWidget ()) 1004 if (sender () == _tab_widget->currentWidget ())
1002 { 1005 {
1003 _copy_action->setEnabled (copy_available); 1006 _copy_action->setEnabled (copy_available);
1004 _cut_action->setEnabled (copy_available); 1007 _cut_action->setEnabled (copy_available);
1005 _run_selection_action->setEnabled (copy_available); 1008 _run_selection_action->setEnabled (copy_available && is_octave_file);
1009 _run_action->setEnabled (is_octave_file);
1006 1010
1007 if (!file_name.isEmpty ()) 1011 if (!file_name.isEmpty ())
1008 { 1012 {
1009 ced = QDir::cleanPath (file_name); 1013 ced = QDir::cleanPath (file_name);
1010 int lastslash = ced.lastIndexOf ('/'); 1014 int lastslash = ced.lastIndexOf ('/');
1408 // Signals from the file editor_tab 1412 // Signals from the file editor_tab
1409 connect (f, SIGNAL (file_name_changed (const QString&, const QString&)), 1413 connect (f, SIGNAL (file_name_changed (const QString&, const QString&)),
1410 this, SLOT (handle_file_name_changed (const QString&, 1414 this, SLOT (handle_file_name_changed (const QString&,
1411 const QString&))); 1415 const QString&)));
1412 1416
1413 connect (f, SIGNAL (editor_state_changed (bool, const QString&)), 1417 connect (f, SIGNAL (editor_state_changed (bool, const QString&, bool)),
1414 this, SLOT (handle_editor_state_changed (bool, const QString&))); 1418 this, SLOT (handle_editor_state_changed (bool, const QString&, bool)));
1415 1419
1416 connect (f, SIGNAL (tab_remove_request ()), 1420 connect (f, SIGNAL (tab_remove_request ()),
1417 this, SLOT (handle_tab_remove_request ())); 1421 this, SLOT (handle_tab_remove_request ()));
1418 1422
1419 connect (f, SIGNAL (add_filename_to_list (const QString&, QWidget*)), 1423 connect (f, SIGNAL (add_filename_to_list (const QString&, QWidget*)),