diff libgui/src/m-editor/file-editor.cc @ 19439:9582fad68730 gui-release

add actions for converting the eol characters of the editor file * file-editor-tab.cc (convert_eol): new slot for converting the line endings * file-editor-tab.h: new slot convert_eol * file-editor.cc (request_conv_eol_windows, request_conv_eol_unix, request_conv_eol_mac): new slots for converting the line ending, emitting new signal for activating the slot convert_eol in file_editor_tab; (constructor): add separators to the edit/format menu, add new actions for converting the line endings; (set_shortcuts): set the shortcuts for the new actions * file-editor.h: new function, new actions, and new signal * shortcut_manager.cc (do_init_data): set the initial shortcuts for new actions
author Torsten <ttl@justmail.de>
date Sat, 11 Oct 2014 11:15:59 +0200
parents 62756ba9e4e5
children 2b708273548d
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc
+++ b/libgui/src/m-editor/file-editor.cc
@@ -812,6 +812,25 @@
   emit fetab_unindent_selected_text (_tab_widget->currentWidget ());
 }
 
+void
+file_editor::request_conv_eol_windows (bool)
+{
+  emit fetab_convert_eol (_tab_widget->currentWidget (),
+                          QsciScintilla::EolWindows);
+}
+void
+file_editor::request_conv_eol_unix (bool)
+{
+  emit fetab_convert_eol (_tab_widget->currentWidget (),
+                          QsciScintilla::EolUnix);
+}
+void
+file_editor::request_conv_eol_mac (bool)
+{
+  emit fetab_convert_eol (_tab_widget->currentWidget (),
+                          QsciScintilla::EolMac);
+}
+
 
 void
 file_editor::request_find (bool)
@@ -1325,15 +1344,33 @@
           tr ("&Uppercase Selection"), SLOT (request_upper_case (bool)));
   _lower_case_action = add_action (_edit_fmt_menu, QIcon (),
           tr ("&Lowercase Selection"), SLOT (request_lower_case (bool)));
+
+  _edit_fmt_menu->addSeparator ();
+
   _comment_selection_action = add_action (_edit_fmt_menu, QIcon (),
           tr ("&Comment"), SLOT (request_comment_selected_text (bool)));
   _uncomment_selection_action = add_action (_edit_fmt_menu, QIcon (),
           tr ("&Uncomment"), SLOT (request_uncomment_selected_text (bool)));
+
+  _edit_fmt_menu->addSeparator ();
+
   _indent_selection_action = add_action (_edit_fmt_menu, QIcon (),
           tr ("&Indent"), SLOT (request_indent_selected_text (bool)));
   _unindent_selection_action = add_action (_edit_fmt_menu, QIcon (),
           tr ("&Unindent"), SLOT (request_unindent_selected_text (bool)));
 
+  _edit_fmt_menu->addSeparator ();
+
+  _conv_eol_windows_action = add_action (_edit_fmt_menu, QIcon (),
+          tr ("Convert Line Endings to &Windows (CRLF)"),
+          SLOT (request_conv_eol_windows (bool)));
+  _conv_eol_unix_action = add_action (_edit_fmt_menu, QIcon (),
+          tr ("Convert Line Endings to &Unix (LF)"),
+          SLOT (request_conv_eol_unix (bool)));
+  _conv_eol_mac_action = add_action (_edit_fmt_menu, QIcon (),
+          tr ("Convert Line Endings to &Mac (CR)"),
+          SLOT (request_conv_eol_mac (bool)));
+
   _edit_nav_menu = editMenu->addMenu (tr ("Navi&gation"));
 
   _goto_line_action = add_action (_edit_nav_menu, QIcon (),
@@ -1636,6 +1673,9 @@
   connect (this, SIGNAL (fetab_unindent_selected_text (const QWidget*)),
            f, SLOT (unindent_selected_text (const QWidget*)));
 
+  connect (this, SIGNAL (fetab_convert_eol (const QWidget*, QsciScintilla::EolMode)),
+           f, SLOT (convert_eol (const QWidget*, QsciScintilla::EolMode)));
+
   connect (this, SIGNAL (fetab_find (const QWidget*)),
            f, SLOT (find (const QWidget*)));
 
@@ -1740,6 +1780,10 @@
   shortcut_manager::set_shortcut (_preferences_action, "editor_edit:preferences");
   shortcut_manager::set_shortcut (_styles_preferences_action, "editor_edit:styles_preferences");
 
+  shortcut_manager::set_shortcut (_conv_eol_windows_action, "editor_edit:conv_eol_winows");
+  shortcut_manager::set_shortcut (_conv_eol_unix_action,    "editor_edit:conv_eol_unix");
+  shortcut_manager::set_shortcut (_conv_eol_mac_action,     "editor_edit:conv_eol_mac");
+
   // View menu
   shortcut_manager::set_shortcut (_show_linenum_action, "editor_view:show_line_numbers");
   shortcut_manager::set_shortcut (_show_whitespace_action, "editor_view:show_white_spaces");