comparison 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
comparison
equal deleted inserted replaced
18670:8b566ad1f88a 18675:c199304dfb2a
38 38
39 octave_qscintilla::octave_qscintilla (QWidget *p) 39 octave_qscintilla::octave_qscintilla (QWidget *p)
40 : QsciScintilla (p) 40 : QsciScintilla (p)
41 { 41 {
42 // clear scintilla edit shortcuts that are handled by the editor 42 // clear scintilla edit shortcuts that are handled by the editor
43 QsciCommandSet *cmd_set = standardCommands (); 43 QsciCommandSet *cmd_set = standardCommands ();
44
45 #ifdef HAVE_QSCI_VERSION_2_6_0
46 // find () was added in QScintilla 2.6
47 cmd_set->find (QsciCommand::SelectionCopy)->setKey (0);
48 cmd_set->find (QsciCommand::SelectionCut)->setKey (0);
49 cmd_set->find (QsciCommand::Paste)->setKey (0);
50 cmd_set->find (QsciCommand::SelectAll)->setKey (0);
44 cmd_set->find (QsciCommand::SelectionDuplicate)->setKey (0); 51 cmd_set->find (QsciCommand::SelectionDuplicate)->setKey (0);
45 cmd_set->find (QsciCommand::LineTranspose)->setKey (0); 52 cmd_set->find (QsciCommand::LineTranspose)->setKey (0);
46 cmd_set->find (QsciCommand::Undo)->setKey (0); 53 cmd_set->find (QsciCommand::Undo)->setKey (0);
47 cmd_set->find (QsciCommand::Redo)->setKey (0); 54 cmd_set->find (QsciCommand::Redo)->setKey (0);
48 cmd_set->find (QsciCommand::SelectionUpperCase)->setKey (0); 55 cmd_set->find (QsciCommand::SelectionUpperCase)->setKey (0);
54 cmd_set->find (QsciCommand::DeleteLineLeft)->setKey (0); 61 cmd_set->find (QsciCommand::DeleteLineLeft)->setKey (0);
55 cmd_set->find (QsciCommand::DeleteLineRight)->setKey (0); 62 cmd_set->find (QsciCommand::DeleteLineRight)->setKey (0);
56 cmd_set->find (QsciCommand::LineDelete)->setKey (0); 63 cmd_set->find (QsciCommand::LineDelete)->setKey (0);
57 cmd_set->find (QsciCommand::LineCut)->setKey (0); 64 cmd_set->find (QsciCommand::LineCut)->setKey (0);
58 cmd_set->find (QsciCommand::LineCopy)->setKey (0); 65 cmd_set->find (QsciCommand::LineCopy)->setKey (0);
66 #else
67 // find commands via its default key (tricky way without find ())
68 QList< QsciCommand * > cmd_list = cmd_set->commands ();
69 for (int i = 0; i < cmd_list.length (); i++)
70 {
71 int cmd_key = cmd_list.at (i)->key ();
72 switch (cmd_key)
73 {
74 case Qt::Key_C | Qt::CTRL : // SelectionCopy
75 case Qt::Key_X | Qt::CTRL : // SelectionCut
76 case Qt::Key_V | Qt::CTRL : // Paste
77 case Qt::Key_A | Qt::CTRL : // SelectAll
78 case Qt::Key_D | Qt::CTRL : // SelectionDuplicate
79 case Qt::Key_T | Qt::CTRL : // LineTranspose
80 case Qt::Key_Z | Qt::CTRL : // Undo
81 case Qt::Key_Y | Qt::CTRL : // Redo
82 case Qt::Key_Z | Qt::CTRL | Qt::SHIFT : // Redo
83 case Qt::Key_U | Qt::CTRL : // SelectionLowerCase
84 case Qt::Key_U | Qt::CTRL | Qt::SHIFT : // SelectionUpperCase
85 case Qt::Key_Plus | Qt::CTRL : // ZoomIn
86 case Qt::Key_Minus | Qt::CTRL : // ZoomOut
87 case Qt::Key_Backspace | Qt::CTRL | Qt::SHIFT : // DeleteLineLeft
88 case Qt::Key_Delete | Qt::CTRL | Qt::SHIFT : // DeleteLineRight
89 case Qt::Key_K | Qt::META : // DeleteLineRight
90 case Qt::Key_Backspace | Qt::CTRL : // DeleteWordLeft
91 case Qt::Key_Delete | Qt::CTRL : // DeleteWordRight
92 case Qt::Key_L | Qt::CTRL | Qt::SHIFT : // LineDelete
93 case Qt::Key_L | Qt::CTRL : // LineCut
94 case Qt::Key_T | Qt::CTRL | Qt::SHIFT : // LineCopy
95 cmd_list.at (i)->setKey (0);
96 }
97 }
98 #endif
59 } 99 }
60 100
61 octave_qscintilla::~octave_qscintilla () 101 octave_qscintilla::~octave_qscintilla ()
62 { } 102 { }
63 103