Mercurial > octave-nkf
diff libgui/src/m-editor/file-editor.cc @ 18303:106da7544504 gui-release
gui: Add indent/unindent edit menu to editor (Bug #41223)
* libgui/src/m-editor/file-editor.h
(file_editor::private): Add _indent_selection_action, _unindent_selection_action menus.
(file_editor::request_indent_selected_text): New function.
(file_editor::request_indent_selected_text): New function.
(file_editor::fetab_indent_selected_text): New signal.
(file_editor::fetab_indent_selected_text): New signal.
* libgui/src/m-editor/file-editor.cc
(file_editor::request_indent_selected_text): New function.
(file_editor::request_unindent_selected_text): New function.
(file_editor::contruct: Create indent menus and connect signals.
(file_editor::set_shortcuts): Enable/disable indent menus and shortcuts.
(file_editor::check_actions): Enable indent menus if have editor tabs.
* libgui/src/m-editor/file-editor-tab.h
(file-editor-tab::indent_selected_text): New function.
(file-editor-tab::unindent_selected_text): New function.
(file-editor-tab::do_indent_selected_text): New function.
* libgui/src/m-editor/file-editor-tab.cc
(file-editor-tab::indent_selected_text): New function.
(file-editor-tab::unindent_selected_text): New function.
(file-editor-tab::do_indent_selected_text): New function.
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Sat, 18 Jan 2014 08:50:03 -0500 |
parents | 01646e48a650 |
children | 3df71e1d3b24 |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc Sat Jan 18 09:25:33 2014 +0100 +++ b/libgui/src/m-editor/file-editor.cc Sat Jan 18 08:50:03 2014 -0500 @@ -670,6 +670,19 @@ } void +file_editor::request_indent_selected_text (void) +{ + emit fetab_indent_selected_text (_tab_widget->currentWidget ()); +} + +void +file_editor::request_unindent_selected_text (void) +{ + emit fetab_unindent_selected_text (_tab_widget->currentWidget ()); +} + + +void file_editor::request_find (void) { emit fetab_find (_tab_widget->currentWidget ()); @@ -945,6 +958,11 @@ _uncomment_selection_action = new QAction (tr ("&Uncomment"), _tool_bar); + _indent_selection_action + = new QAction (tr ("&Indent"), _tool_bar); + _unindent_selection_action + = new QAction (tr ("&Unindent"), _tool_bar); + _find_action = new QAction (QIcon (":/actions/icons/find.png"), tr ("&Find and Replace..."), _tool_bar); @@ -978,6 +996,8 @@ _toggle_bookmark_action->setShortcutContext (Qt::WindowShortcut); _comment_selection_action->setShortcutContext (Qt::WindowShortcut); _uncomment_selection_action->setShortcutContext (Qt::WindowShortcut); + _indent_selection_action->setShortcutContext (Qt::WindowShortcut); + _unindent_selection_action->setShortcutContext (Qt::WindowShortcut); _find_action->setShortcutContext (Qt::WindowShortcut); _goto_line_action->setShortcutContext (Qt::WindowShortcut); @@ -1058,6 +1078,9 @@ editMenu->addAction (_comment_selection_action); editMenu->addAction (_uncomment_selection_action); editMenu->addSeparator (); + editMenu->addAction (_indent_selection_action); + editMenu->addAction (_unindent_selection_action); + editMenu->addSeparator (); editMenu->addAction (_toggle_bookmark_action); editMenu->addAction (_next_bookmark_action); editMenu->addAction (_previous_bookmark_action); @@ -1187,6 +1210,12 @@ connect (_uncomment_selection_action, SIGNAL (triggered ()), this, SLOT (request_uncomment_selected_text ())); + connect (_indent_selection_action, SIGNAL (triggered ()), + this, SLOT (request_indent_selected_text ())); + + connect (_unindent_selection_action, SIGNAL (triggered ()), + this, SLOT (request_unindent_selected_text ())); + connect (_find_action, SIGNAL (triggered ()), this, SLOT (request_find ())); @@ -1340,6 +1369,12 @@ connect (this, SIGNAL (fetab_uncomment_selected_text (const QWidget*)), f, SLOT (uncomment_selected_text (const QWidget*))); + connect (this, SIGNAL (fetab_indent_selected_text (const QWidget*)), + f, SLOT (indent_selected_text (const QWidget*))); + + connect (this, SIGNAL (fetab_unindent_selected_text (const QWidget*)), + f, SLOT (unindent_selected_text (const QWidget*))); + connect (this, SIGNAL (fetab_find (const QWidget*)), f, SLOT (find (const QWidget*))); @@ -1395,6 +1430,11 @@ + Qt::ControlModifier + Qt::Key_R); + _indent_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_Tab); + _unindent_selection_action->setShortcut (Qt::SHIFT + + Qt::ControlModifier + + Qt::Key_Tab); + _copy_action->setShortcut (QKeySequence::Copy); _cut_action->setShortcut (QKeySequence::Cut); _paste_action->setShortcut (QKeySequence::Paste); @@ -1427,6 +1467,9 @@ _comment_selection_action->setShortcut (no_key); _uncomment_selection_action->setShortcut (no_key); + _indent_selection_action->setShortcut (no_key); + _unindent_selection_action->setShortcut (no_key); + _copy_action->setShortcut (no_key); _cut_action->setShortcut (no_key); _paste_action->setShortcut (no_key); @@ -1461,6 +1504,9 @@ _comment_selection_action->setEnabled (have_tabs); _uncomment_selection_action->setEnabled (have_tabs); + _indent_selection_action->setEnabled (have_tabs); + _unindent_selection_action->setEnabled (have_tabs); + _paste_action->setEnabled (have_tabs); _context_help_action->setEnabled (have_tabs); _context_doc_action->setEnabled (have_tabs);