diff libgui/src/m-editor/octave-qscintilla.cc @ 18675:c199304dfb2a gui-release

handling qscintilla internal shortcuts and commands depending on qsci version * file-editor.cc (request_delete_start_word, request_delete_end_word, request_delete_start_line, request_delete_end_line, request_delete_line, request_copy_line, request_cut_line, request_duplicate_selection, request_transpose_line, request_comment_selected_text, request_lower_case): use constants from QsciScintillaBase and not from QsciCommand * octave-qscintilla.cc (constructor): if qscintilla is not version 2.6, search the commands for which the shortcuts has to be disabled by the shortcut itself, otherwise use the find () function; more shortcuts are disabled because the gui takes care of them * main-window.cc (construct_file_menu): add common menu into editor menu only when qscintilla is available
author Torsten <ttl@justmail.de>
date Fri, 25 Apr 2014 06:40:21 +0200
parents 1b289f45187f
children 86eca5d178a6
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc	Thu Apr 24 08:40:40 2014 -0700
+++ b/libgui/src/m-editor/octave-qscintilla.cc	Fri Apr 25 06:40:21 2014 +0200
@@ -40,7 +40,14 @@
   : QsciScintilla (p)
 {
   // clear scintilla edit shortcuts that are handled by the editor
-  QsciCommandSet  *cmd_set =  standardCommands ();
+  QsciCommandSet *cmd_set = standardCommands ();
+
+#ifdef HAVE_QSCI_VERSION_2_6_0
+  // find () was added in QScintilla 2.6
+  cmd_set->find (QsciCommand::SelectionCopy)->setKey (0);
+  cmd_set->find (QsciCommand::SelectionCut)->setKey (0);
+  cmd_set->find (QsciCommand::Paste)->setKey (0);
+  cmd_set->find (QsciCommand::SelectAll)->setKey (0);
   cmd_set->find (QsciCommand::SelectionDuplicate)->setKey (0);
   cmd_set->find (QsciCommand::LineTranspose)->setKey (0);
   cmd_set->find (QsciCommand::Undo)->setKey (0);
@@ -56,6 +63,39 @@
   cmd_set->find (QsciCommand::LineDelete)->setKey (0);
   cmd_set->find (QsciCommand::LineCut)->setKey (0);
   cmd_set->find (QsciCommand::LineCopy)->setKey (0);
+#else
+  // find commands via its default key (tricky way without find ())
+  QList< QsciCommand * > cmd_list = cmd_set->commands ();
+  for (int i = 0; i < cmd_list.length (); i++)
+    {
+      int cmd_key = cmd_list.at (i)->key ();
+      switch (cmd_key)
+        {
+          case Qt::Key_C | Qt::CTRL :               // SelectionCopy
+          case Qt::Key_X | Qt::CTRL :               // SelectionCut
+          case Qt::Key_V | Qt::CTRL :               // Paste
+          case Qt::Key_A | Qt::CTRL :               // SelectAll
+          case Qt::Key_D | Qt::CTRL :               // SelectionDuplicate
+          case Qt::Key_T | Qt::CTRL :               // LineTranspose
+          case Qt::Key_Z | Qt::CTRL :               // Undo
+          case Qt::Key_Y | Qt::CTRL :               // Redo
+          case Qt::Key_Z | Qt::CTRL | Qt::SHIFT :   // Redo
+          case Qt::Key_U | Qt::CTRL :               // SelectionLowerCase
+          case Qt::Key_U | Qt::CTRL | Qt::SHIFT :   // SelectionUpperCase
+          case Qt::Key_Plus | Qt::CTRL :            // ZoomIn
+          case Qt::Key_Minus | Qt::CTRL :           // ZoomOut
+          case Qt::Key_Backspace | Qt::CTRL | Qt::SHIFT :   // DeleteLineLeft
+          case Qt::Key_Delete | Qt::CTRL | Qt::SHIFT :      // DeleteLineRight
+          case Qt::Key_K | Qt::META :                       // DeleteLineRight
+          case Qt::Key_Backspace | Qt::CTRL :       // DeleteWordLeft
+          case Qt::Key_Delete | Qt::CTRL :          // DeleteWordRight
+          case Qt::Key_L | Qt::CTRL | Qt::SHIFT :   // LineDelete
+          case Qt::Key_L | Qt::CTRL :               // LineCut
+          case Qt::Key_T | Qt::CTRL | Qt::SHIFT :   // LineCopy
+            cmd_list.at (i)->setKey (0);
+        }
+    }
+#endif
 }
 
 octave_qscintilla::~octave_qscintilla ()