Mercurial > hg > octave-nkf
changeset 18830: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 | 8b566ad1f88a |
children | 86eca5d178a6 |
files | libgui/src/m-editor/file-editor.cc libgui/src/m-editor/octave-qscintilla.cc libgui/src/main-window.cc |
diffstat | 3 files changed, 53 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc +++ b/libgui/src/m-editor/file-editor.cc @@ -707,55 +707,55 @@ file_editor::request_delete_start_word (bool) { emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciCommand::DeleteWordLeft); + QsciScintillaBase::SCI_DELWORDLEFT); } void file_editor::request_delete_end_word (bool) { emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciCommand::DeleteWordRight); + QsciScintillaBase::SCI_DELWORDRIGHT); } void file_editor::request_delete_start_line (bool) { emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciCommand::DeleteLineLeft); + QsciScintillaBase::SCI_DELLINELEFT); } void file_editor::request_delete_end_line (bool) { emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciCommand::DeleteLineRight); + QsciScintillaBase::SCI_DELLINERIGHT); } void file_editor::request_delete_line (bool) { emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciCommand::LineDelete); + QsciScintillaBase::SCI_LINEDELETE); } void file_editor::request_copy_line (bool) { emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciCommand::LineCopy); + QsciScintillaBase::SCI_LINECOPY); } void file_editor::request_cut_line (bool) { emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciCommand::LineCut); + QsciScintillaBase::SCI_LINECUT); } void file_editor::request_duplicate_selection (bool) { emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciCommand::SelectionDuplicate); + QsciScintillaBase::SCI_SELECTIONDUPLICATE); } void file_editor::request_transpose_line (bool) { emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciCommand::LineTranspose); + QsciScintillaBase::SCI_LINETRANSPOSE); } void file_editor::request_comment_selected_text (bool) @@ -773,13 +773,13 @@ file_editor::request_upper_case (bool) { emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciCommand::SelectionUpperCase); + QsciScintillaBase::SCI_UPPERCASE); } void file_editor::request_lower_case (bool) { emit fetab_scintilla_command (_tab_widget->currentWidget (), - QsciCommand::SelectionLowerCase); + QsciScintillaBase::SCI_LOWERCASE); } void file_editor::request_indent_selected_text (bool)
--- a/libgui/src/m-editor/octave-qscintilla.cc +++ b/libgui/src/m-editor/octave-qscintilla.cc @@ -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 ()
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -1437,11 +1437,11 @@ tr ("Open...")); _open_action->setShortcutContext (Qt::ApplicationShortcut); +#ifdef HAVE_QSCINTILLA editor_window->insert_new_open_actions (_new_script_action, _new_function_action, _open_action); -#ifdef HAVE_QSCINTILLA file_menu->addMenu (editor_window->get_mru_menu ()); #endif