Mercurial > octave-nkf
comparison libgui/src/m-editor/file-editor.cc @ 18723:fac35875f6eb gui-release
update enabled status of undo/redo actions in the editor
* file-editor-tab.h: new inline function returning the qscintilla edit area
* octave-qscintilla.cc (constructor): connect textChanged signal to new private
slot text_changed;
(text_changed): new slot emitting a signal on undo/redo availability
* octave-qscintilla.h: new slot and new signal
* file-editor.cc (edit_status_update): new slot for updating undo/redo actions;
(construct): undo/redo actions disabled at the beginning;
(add_new_edit_tab): connect new slot to the signal from the qscintilla edit
area indicating undo/redo availability
* file-editor.h: new slot
author | Torsten <ttl@justmail.de> |
---|---|
date | Sun, 27 Apr 2014 19:36:54 +0200 |
parents | 02b75b57ed80 |
children | 834f6e604dc3 |
comparison
equal
deleted
inserted
replaced
18722:02b75b57ed80 | 18723:fac35875f6eb |
---|---|
984 { | 984 { |
985 emit fetab_zoom_normal (_tab_widget->currentWidget ()); | 985 emit fetab_zoom_normal (_tab_widget->currentWidget ()); |
986 } | 986 } |
987 | 987 |
988 void | 988 void |
989 file_editor::edit_status_update (bool undo, bool redo) | |
990 { | |
991 _undo_action->setEnabled (undo); | |
992 _redo_action->setEnabled (redo); | |
993 } | |
994 | |
995 void | |
989 file_editor::handle_editor_state_changed (bool copy_available, | 996 file_editor::handle_editor_state_changed (bool copy_available, |
990 const QString& file_name) | 997 const QString& file_name) |
991 { | 998 { |
992 // In case there is some scenario where traffic could be coming from | 999 // In case there is some scenario where traffic could be coming from |
993 // all the file editor tabs, just process info from the current active tab. | 1000 // all the file editor tabs, just process info from the current active tab. |
1156 | 1163 |
1157 QMenu *editMenu = new QMenu (tr ("&Edit"), _menu_bar); | 1164 QMenu *editMenu = new QMenu (tr ("&Edit"), _menu_bar); |
1158 | 1165 |
1159 _undo_action = add_action (editMenu, QIcon (":/actions/icons/undo.png"), | 1166 _undo_action = add_action (editMenu, QIcon (":/actions/icons/undo.png"), |
1160 tr ("&Undo"), SLOT (request_undo (bool))); | 1167 tr ("&Undo"), SLOT (request_undo (bool))); |
1168 _undo_action->setEnabled (false); | |
1161 _redo_action = add_action (editMenu, QIcon (":/actions/icons/redo.png"), | 1169 _redo_action = add_action (editMenu, QIcon (":/actions/icons/redo.png"), |
1162 tr ("&Redo"), SLOT (request_redo (bool))); | 1170 tr ("&Redo"), SLOT (request_redo (bool))); |
1171 _redo_action->setEnabled (false); | |
1163 | 1172 |
1164 editMenu->addSeparator (); | 1173 editMenu->addSeparator (); |
1165 | 1174 |
1166 _copy_action = add_action (editMenu, QIcon (":/actions/icons/editcopy.png"), | 1175 _copy_action = add_action (editMenu, QIcon (":/actions/icons/editcopy.png"), |
1167 tr ("&Copy"), SLOT (request_copy (bool))); | 1176 tr ("&Copy"), SLOT (request_copy (bool))); |
1394 void | 1403 void |
1395 file_editor::add_file_editor_tab (file_editor_tab *f, const QString& fn) | 1404 file_editor::add_file_editor_tab (file_editor_tab *f, const QString& fn) |
1396 { | 1405 { |
1397 _tab_widget->addTab (f, fn); | 1406 _tab_widget->addTab (f, fn); |
1398 | 1407 |
1408 // signals from the qscintilla edit area | |
1409 connect (f->qsci_edit_area (), SIGNAL (status_update (bool, bool)), | |
1410 this, SLOT (edit_status_update (bool, bool))); | |
1411 | |
1399 // Signals from the file editor_tab | 1412 // Signals from the file editor_tab |
1400 connect (f, SIGNAL (file_name_changed (const QString&, const QString&)), | 1413 connect (f, SIGNAL (file_name_changed (const QString&, const QString&)), |
1401 this, SLOT (handle_file_name_changed (const QString&, | 1414 this, SLOT (handle_file_name_changed (const QString&, |
1402 const QString&))); | 1415 const QString&))); |
1403 | 1416 |
1638 _save_as_action->setEnabled (have_tabs); | 1651 _save_as_action->setEnabled (have_tabs); |
1639 _close_action->setEnabled (have_tabs); | 1652 _close_action->setEnabled (have_tabs); |
1640 _close_all_action->setEnabled (have_tabs); | 1653 _close_all_action->setEnabled (have_tabs); |
1641 _close_others_action->setEnabled (have_tabs && _tab_widget->count () > 1); | 1654 _close_others_action->setEnabled (have_tabs && _tab_widget->count () > 1); |
1642 | 1655 |
1643 _undo_action->setEnabled (have_tabs); | |
1644 _redo_action->setEnabled (have_tabs); | |
1645 _selectall_action->setEnabled (have_tabs); | 1656 _selectall_action->setEnabled (have_tabs); |
1646 } | 1657 } |
1647 | 1658 |
1648 // empty_script determines whether we have to create an empty script | 1659 // empty_script determines whether we have to create an empty script |
1649 // 1. At startup, when the editor has to be (really) visible | 1660 // 1. At startup, when the editor has to be (really) visible |