diff libgui/src/m-editor/file-editor.cc @ 24484:abb075ada761

Allow commenting with manually selected comment strings (bug #52695): * file-editor-tab.cc (comment_selected_text, do_comment_selected_text): new boolean parameter for comment string from settings or from input dialog * file-editor-tab.h (comment_selected_text, do_comment_selected_text): new boolean parameter for comment string from settings or from input dialog * file-editor.cc (check_actions): enable new action depending on tabs; (request_comment_selected_text): emit signal for commenting with string from preferences; (request_comment_var_selected_text): new slot emitting the signal for commenting with manually selected string; (set_shortcuts): set the shortcut for the new action; (construct): add new action to the edit menu of the editor; (add_file_editor_tab): signal for commenting and related slot in editor tab now have an additional boolean parameter * file-editor.h: new action with new slot, signal for commenting now have an additional boolean parameter * shortcut-manager.cc (do_init_data): initialize the shortcut for the new action
author Torsten <mttl@mailbox.org>
date Thu, 28 Dec 2017 21:13:49 +0100
parents e0bcd17ac070
children 194eb4bd202b
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc	Thu Dec 28 10:17:01 2017 -0500
+++ b/libgui/src/m-editor/file-editor.cc	Thu Dec 28 21:13:49 2017 +0100
@@ -261,6 +261,7 @@
 
   m_comment_selection_action->setEnabled (have_tabs);
   m_uncomment_selection_action->setEnabled (have_tabs);
+  m_comment_var_selection_action->setEnabled (have_tabs);
   m_indent_selection_action->setEnabled (have_tabs);
   m_unindent_selection_action->setEnabled (have_tabs);
   m_smart_indent_line_or_selection_action->setEnabled (have_tabs);
@@ -763,7 +764,7 @@
 void
 file_editor::request_comment_selected_text (bool)
 {
-  emit fetab_comment_selected_text (m_tab_widget->currentWidget ());
+  emit fetab_comment_selected_text (m_tab_widget->currentWidget (), false);
 }
 
 void
@@ -772,6 +773,12 @@
   emit fetab_uncomment_selected_text (m_tab_widget->currentWidget ());
 }
 
+void
+file_editor::request_comment_var_selected_text (bool)
+{
+  emit fetab_comment_selected_text (m_tab_widget->currentWidget (), true);
+}
+
 // slots for Edit->Format actions
 void
 file_editor::request_upper_case (bool)
@@ -1211,6 +1218,7 @@
   shortcut_manager::set_shortcut (m_transpose_line_action, "editor_edit:transpose_line");
   shortcut_manager::set_shortcut (m_comment_selection_action, "editor_edit:comment_selection");
   shortcut_manager::set_shortcut (m_uncomment_selection_action, "editor_edit:uncomment_selection");
+  shortcut_manager::set_shortcut (m_comment_var_selection_action, "editor_edit:comment_var_selection");
 
   shortcut_manager::set_shortcut (m_upper_case_action, "editor_edit:upper_case");
   shortcut_manager::set_shortcut (m_lower_case_action, "editor_edit:lower_case");
@@ -1848,6 +1856,8 @@
           tr ("&Comment"), SLOT (request_comment_selected_text (bool)));
   m_uncomment_selection_action = add_action (m_edit_fmt_menu, QIcon (),
           tr ("&Uncomment"), SLOT (request_uncomment_selected_text (bool)));
+  m_comment_var_selection_action = add_action (m_edit_fmt_menu, QIcon (),
+          tr ("Comment (Choosing String)"), SLOT (request_comment_var_selected_text (bool)));
 
   m_edit_fmt_menu->addSeparator ();
 
@@ -2219,8 +2229,8 @@
                                                   unsigned int)),
            f, SLOT (scintilla_command (const QWidget *, unsigned int)));
 
-  connect (this, SIGNAL (fetab_comment_selected_text (const QWidget*)),
-           f, SLOT (comment_selected_text (const QWidget*)));
+  connect (this, SIGNAL (fetab_comment_selected_text (const QWidget*, bool)),
+           f, SLOT (comment_selected_text (const QWidget*, bool)));
 
   connect (this, SIGNAL (fetab_uncomment_selected_text (const QWidget*)),
            f, SLOT (uncomment_selected_text (const QWidget*)));