diff libgui/src/m-editor/file-editor.cc @ 18459:f01ac1bb8a5d 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 (eventFilter): event filter for overriding qscintilla internal shortcuts; (constructor): install event filter * octave-qscintilla.h: event filter
author Torsten <ttl@justmail.de>
date Thu, 13 Feb 2014 20:39:09 +0100
parents 2ea741d22554
children f959c63934e6
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc	Thu Feb 13 12:15:14 2014 -0500
+++ b/libgui/src/m-editor/file-editor.cc	Thu Feb 13 20:39:09 2014 +0100
@@ -825,6 +825,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)
 {
@@ -1113,6 +1131,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);
@@ -1333,6 +1360,13 @@
   connect (this, SIGNAL (fetab_paste (const QWidget*)),
            f, SLOT (paste (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)));
 
@@ -1456,6 +1490,11 @@
       _context_help_action->setShortcut (QKeySequence::HelpContents);
       _context_doc_action->setShortcut (Qt::SHIFT + Qt::Key_F1);
 
+      _zoom_in_action->setShortcut (QKeySequence::ZoomIn);
+      _zoom_out_action->setShortcut (QKeySequence::ZoomOut);
+      _zoom_normal_action->setShortcut (Qt::ControlModifier
+                                         + Qt::AltModifier + Qt::Key_0);
+
       _find_action->setShortcut (QKeySequence::Find);
       _goto_line_action->setShortcut (Qt::ControlModifier+ Qt::Key_G);
 
@@ -1490,6 +1529,10 @@
       _paste_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);
 
@@ -1526,6 +1569,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);