Mercurial > hg > octave-nkf
changeset 18655:26d15a57f45b gui-release
add menu entries and shortcuts for zoom functions in the editor (bug #41516)
* file-editor.cc (zoom_in): slot for zoom-in action, triggering signal for tab;
(zoom_out): slot for zoom-out action, triggering signal for tab;
(zoom_normal): slot for zoom-to-normal action, triggering signal for tab;
(construct): new View-menu with zoom-in, zoom-out and zoom-normal entries;
(add_file_editor_tab): connect zoom-signal to newly created tabs;
(set_shortcuts): set shortcuts for new zoom actions;
(check_actions): disable zoom action when no editor tab is open
* file-editor.h: zoom-in, zoom-out and zoom-normal actions, related slots
and related signals to the actual tab
* file-editor-tab.cc (zoom_in): new slot for signal from file_editor;
(zoom_out): new slot for signal from file_editor;
(zoom_normal): new slot for signal from file_editor
* file-editor-tab.h: new slots zoom_in, zoom_out, zoom_normal
* octave-qscintilla.cc (constructor): disable the shortcuts qscintilla uses
for the zoom-actions in order to be able to use own functions
author | Torsten <ttl@justmail.de> |
---|---|
date | Thu, 13 Feb 2014 20:39:09 +0100 |
parents | ca1648b2e673 |
children | 6b4f9cab88d6 |
files | libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h libgui/src/m-editor/file-editor.cc libgui/src/m-editor/file-editor.h libgui/src/m-editor/octave-qscintilla.cc |
diffstat | 5 files changed, 101 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -776,6 +776,37 @@ void +file_editor_tab::zoom_in (const QWidget *ID) +{ + if (ID != this) + return; + + _edit_area->zoomIn (1); + auto_margin_width (); +} + +void +file_editor_tab::zoom_out (const QWidget *ID) +{ + if (ID != this) + return; + + _edit_area->zoomOut (1); + auto_margin_width (); +} + +void +file_editor_tab::zoom_normal (const QWidget *ID) +{ + if (ID != this) + return; + + _edit_area->zoomTo (0); + auto_margin_width (); +} + + +void file_editor_tab::handle_find_dialog_finished (int) { // Find dialog is going to hide. Save location of window for
--- a/libgui/src/m-editor/file-editor-tab.h +++ b/libgui/src/m-editor/file-editor-tab.h @@ -98,6 +98,10 @@ void indent_selected_text (const QWidget *ID); void unindent_selected_text (const QWidget *ID); + void zoom_in (const QWidget *ID); + void zoom_out (const QWidget *ID); + void zoom_normal (const QWidget *ID); + void find (const QWidget *ID); void goto_line (const QWidget *ID, int line = -1); void show_auto_completion (const QWidget *ID);
--- a/libgui/src/m-editor/file-editor.cc +++ b/libgui/src/m-editor/file-editor.cc @@ -870,6 +870,24 @@ } void +file_editor::zoom_in (bool) +{ + emit fetab_zoom_in (_tab_widget->currentWidget ()); +} + +void +file_editor::zoom_out (bool) +{ + emit fetab_zoom_out (_tab_widget->currentWidget ()); +} + +void +file_editor::zoom_normal (bool) +{ + emit fetab_zoom_normal (_tab_widget->currentWidget ()); +} + +void file_editor::handle_editor_state_changed (bool copy_available, const QString& file_name) { @@ -1166,6 +1184,15 @@ this, SLOT (request_styles_preferences (bool))); _menu_bar->addMenu (editMenu); + QMenu *view_menu = new QMenu (tr ("&View"), _menu_bar); + _zoom_in_action = view_menu->addAction (QIcon (), tr ("Zoom &In"), + this, SLOT (zoom_in (bool))); + _zoom_out_action = view_menu->addAction (QIcon (), tr ("Zoom &Out"), + this, SLOT (zoom_out (bool))); + _zoom_normal_action = view_menu->addAction (QIcon (), tr ("&Normal Size"), + this, SLOT (zoom_normal (bool))); + _menu_bar->addMenu (view_menu); + _debug_menu = new QMenu (tr ("&Debug"), _menu_bar); _debug_menu->addAction (toggle_breakpoint_action); _debug_menu->addAction (next_breakpoint_action); @@ -1395,6 +1422,13 @@ connect (this, SIGNAL (fetab_selectall (const QWidget*)), f, SLOT (select_all (const QWidget*))); + connect (this, SIGNAL (fetab_zoom_in (const QWidget*)), + f, SLOT (zoom_in (const QWidget*))); + connect (this, SIGNAL (fetab_zoom_out (const QWidget*)), + f, SLOT (zoom_out (const QWidget*))); + connect (this, SIGNAL (fetab_zoom_normal (const QWidget*)), + f, SLOT (zoom_normal (const QWidget*))); + connect (this, SIGNAL (fetab_context_help (const QWidget*, bool)), f, SLOT (context_help (const QWidget*, bool))); @@ -1533,6 +1567,10 @@ _context_help_action->setShortcut (QKeySequence::HelpContents); _context_doc_action->setShortcut (Qt::SHIFT + Qt::Key_F1); + _zoom_in_action->setShortcuts (QKeySequence::ZoomIn); + _zoom_out_action->setShortcuts (QKeySequence::ZoomOut); + _zoom_normal_action->setShortcut (Qt::ControlModifier + Qt::Key_Slash); + _find_action->setShortcut (QKeySequence::Find); _goto_line_action->setShortcut (Qt::ControlModifier+ Qt::Key_G); _completion_action->setShortcut (Qt::ControlModifier + Qt::Key_Space); @@ -1569,6 +1607,10 @@ _selectall_action->setShortcut (no_key); _context_help_action->setShortcut (no_key); + _zoom_in_action->setShortcut (no_key); + _zoom_out_action->setShortcut (no_key); + _zoom_normal_action->setShortcut (no_key); + _find_action->setShortcut (no_key); _goto_line_action->setShortcut (no_key); _completion_action->setShortcut (no_key); @@ -1606,6 +1648,10 @@ _context_help_action->setEnabled (have_tabs); _context_doc_action->setEnabled (have_tabs); + _zoom_in_action->setEnabled (have_tabs); + _zoom_out_action->setEnabled (have_tabs); + _zoom_normal_action->setEnabled (have_tabs); + _find_action->setEnabled (have_tabs); _goto_line_action->setEnabled (have_tabs); _completion_action->setEnabled (have_tabs);
--- a/libgui/src/m-editor/file-editor.h +++ b/libgui/src/m-editor/file-editor.h @@ -104,6 +104,11 @@ void fetab_do_breakpoint_marker (bool insert, const QWidget* ID, int line = -1); void fetab_set_focus (const QWidget* ID); + + void fetab_zoom_in (const QWidget* ID); + void fetab_zoom_out (const QWidget* ID); + void fetab_zoom_normal (const QWidget* ID); + void request_settings_dialog (const QString&); void execute_command_in_terminal_signal (const QString&); void file_loaded_signal (); @@ -196,6 +201,10 @@ void request_styles_preferences (bool); void restore_create_file_setting (); + void zoom_in (bool); + void zoom_out (bool); + void zoom_normal (bool); + private: bool is_editor_console_tabbed (); @@ -228,6 +237,10 @@ QAction *_context_help_action; QAction *_context_doc_action; + QAction *_zoom_in_action; + QAction *_zoom_out_action; + QAction *_zoom_normal_action; + QAction *_find_action; QAction *_goto_line_action; QAction *_completion_action;
--- a/libgui/src/m-editor/octave-qscintilla.cc +++ b/libgui/src/m-editor/octave-qscintilla.cc @@ -29,13 +29,19 @@ #ifdef HAVE_QSCINTILLA #include <Qsci/qscilexer.h> +#include <QShortcut> #include "octave-qscintilla.h" #include "file-editor-tab.h" octave_qscintilla::octave_qscintilla (QWidget *p) : QsciScintilla (p) -{ } +{ + // disable zoom-in/out shortcuts, these are handled by octave + SendScintilla (QsciScintillaBase::SCI_CLEARCMDKEY, '+' + (QsciScintillaBase::SCMOD_CTRL << 16) ); + SendScintilla (QsciScintillaBase::SCI_CLEARCMDKEY, '-' + (QsciScintillaBase::SCMOD_CTRL << 16) ); + SendScintilla (QsciScintillaBase::SCI_CLEARCMDKEY, '/' + (QsciScintillaBase::SCMOD_CTRL << 16) ); +} octave_qscintilla::~octave_qscintilla () { }