changeset 18684:86eca5d178a6 gui-release

disable some global shortcuts when editor gets focus to prevent conflicts * file-editor-tab.cc (constructor): connect signal from the qscintilla edit area about focus with the related new slot; (edit_area_has_focus): new slot for the focus signal from qscintilla edit area emitting a signal for enabling/disabling the common edit shortcuts * file-editor-tab.h: new slot edit_area_has_focus, new signal set_global_edit_shortcuts_signal * file-editor.cc (add_file_editor_tab ): connect new tab signal set_global_edit_shortcuts_signal with the related slot in main_window; (copyClipboard, pasteClipboard, selectAll): removed these functions because the related actions are triggered editor shortcuts * file-editor.h: remove copyClipboard, pasteClipboard, selectAll * octave-qscintilla.cc (focusInEvent, focusOutEvent): handlers emitting the signal about the focus state of the edit area * octave-qscintilla.h: new focus signal qsci_has_focus_signal, focus event handlers * main-window.cc (set_global_edit_shortcuts): new slot dis-/enabling the common edit shortcuts depending on focus of edit area * main-window.h: new slot set_global_edit_shortcuts
author Torsten <ttl@justmail.de>
date Sun, 27 Apr 2014 13:03:08 +0200
parents c199304dfb2a
children 03edfcd943db
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 libgui/src/m-editor/octave-qscintilla.h libgui/src/main-window.cc libgui/src/main-window.h
diffstat 8 files changed, 55 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Fri Apr 25 06:40:21 2014 +0200
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sun Apr 27 13:03:08 2014 +0200
@@ -154,6 +154,9 @@
   connect (_edit_area, SIGNAL (copyAvailable (bool)),
            this, SLOT (handle_copy_available (bool)));
 
+  connect (_edit_area, SIGNAL (qsci_has_focus_signal (bool)),
+           this, SLOT (edit_area_has_focus (bool)));
+
   connect (&_file_system_watcher, SIGNAL (fileChanged (const QString&)),
            this, SLOT (file_has_changed (const QString&)));
 
@@ -1664,4 +1667,10 @@
   _col_indicator->setNum (col+1);
 }
 
+void
+file_editor_tab::edit_area_has_focus (bool focus)
+{
+  emit set_global_edit_shortcuts_signal (! focus);
+}
+
 #endif
--- a/libgui/src/m-editor/file-editor-tab.h	Fri Apr 25 06:40:21 2014 +0200
+++ b/libgui/src/m-editor/file-editor-tab.h	Sun Apr 27 13:03:08 2014 +0200
@@ -121,6 +121,7 @@
   void file_has_changed (const QString& fileName);
 
   void execute_command_in_terminal (const QString& command);
+  void edit_area_has_focus (bool foucs);
 
 signals:
 
@@ -133,6 +134,7 @@
                                    bool remove_on_success);
   void run_file_signal (const QFileInfo& info);
   void execute_command_in_terminal_signal (const QString&);
+  void set_global_edit_shortcuts_signal (bool);
 
 protected:
 
--- a/libgui/src/m-editor/file-editor.cc	Fri Apr 25 06:40:21 2014 +0200
+++ b/libgui/src/m-editor/file-editor.cc	Sun Apr 27 13:03:08 2014 +0200
@@ -1396,6 +1396,9 @@
   connect (f, SIGNAL (execute_command_in_terminal_signal (const QString&)),
            main_win (), SLOT (execute_command_in_terminal (const QString&)));
 
+  connect (f, SIGNAL (set_global_edit_shortcuts_signal (bool)),
+           main_win (), SLOT (set_global_edit_shortcuts (bool)));
+
   // Signals from the file_editor non-trivial operations
   connect (this, SIGNAL (fetab_settings_changed (const QSettings *)),
            f, SLOT (notice_settings (const QSettings *)));
@@ -1527,38 +1530,6 @@
 }
 
 void
-file_editor::copyClipboard ()
-{
-  QWidget * foc_w = focusWidget ();
-
-  if (foc_w && foc_w->inherits ("octave_qscintilla"))
-    {
-      request_copy (true);
-    }
-}
-void
-file_editor::pasteClipboard ()
-{
-  QWidget * foc_w = focusWidget ();
-
-  if (foc_w && foc_w->inherits ("octave_qscintilla"))
-    {
-      request_paste (true);
-    }
-}
-void
-file_editor::selectAll ()
-{
-  QWidget * foc_w = focusWidget ();
-
-  if (foc_w && foc_w->inherits ("octave_qscintilla"))
-    {
-      request_selectall (true);
-    }
-}
-
-
-void
 file_editor::set_shortcuts ()
 {
   // File menu
--- a/libgui/src/m-editor/file-editor.h	Fri Apr 25 06:40:21 2014 +0200
+++ b/libgui/src/m-editor/file-editor.h	Sun Apr 27 13:03:08 2014 +0200
@@ -204,9 +204,6 @@
 
 
 protected slots:
-  void copyClipboard ();
-  void pasteClipboard ();
-  void selectAll ();
 
 private slots:
 
--- a/libgui/src/m-editor/octave-qscintilla.cc	Fri Apr 25 06:40:21 2014 +0200
+++ b/libgui/src/m-editor/octave-qscintilla.cc	Sun Apr 27 13:03:08 2014 +0200
@@ -247,4 +247,18 @@
     emit execute_command_in_terminal_signal (commands.at (i));
 }
 
+void
+octave_qscintilla::focusInEvent (QFocusEvent *focusEvent)
+{
+  emit qsci_has_focus_signal (true);
+  QsciScintilla::focusInEvent(focusEvent);
+}
+
+void
+octave_qscintilla::focusOutEvent (QFocusEvent *focusEvent)
+{
+  emit qsci_has_focus_signal (false);
+  QsciScintilla::focusOutEvent(focusEvent);
+}
+
 #endif
--- a/libgui/src/m-editor/octave-qscintilla.h	Fri Apr 25 06:40:21 2014 +0200
+++ b/libgui/src/m-editor/octave-qscintilla.h	Sun Apr 27 13:03:08 2014 +0200
@@ -50,6 +50,7 @@
 signals:
 
   void execute_command_in_terminal_signal (const QString&);
+  void qsci_has_focus_signal (bool);
 
 private slots:
 
@@ -59,6 +60,11 @@
   void contextmenu_edit (bool);
   void contextmenu_run (bool);
 
+protected:
+
+  void focusInEvent (QFocusEvent *focusEvent);
+  void focusOutEvent (QFocusEvent *focusEvent);
+
 private:
 
   QString _word_at_cursor;
--- a/libgui/src/main-window.cc	Fri Apr 25 06:40:21 2014 +0200
+++ b/libgui/src/main-window.cc	Sun Apr 27 13:03:08 2014 +0200
@@ -2278,6 +2278,26 @@
 }
 
 void
+main_window::set_global_edit_shortcuts (bool enable)
+{
+  if (enable)
+    {
+      shortcut_manager::set_shortcut (_copy_action, "main_edit:copy");
+      shortcut_manager::set_shortcut (_paste_action, "main_edit:paste");
+      shortcut_manager::set_shortcut (_undo_action, "main_edit:undo");
+      shortcut_manager::set_shortcut (_select_all_action, "main_edit:select_all");
+    }
+  else
+    {
+      QKeySequence no_key = QKeySequence ();
+      _copy_action->setShortcut (no_key);
+      _paste_action->setShortcut (no_key);
+      _undo_action->setShortcut (no_key);
+      _select_all_action->setShortcut (no_key);
+    }
+}
+
+void
 main_window::set_global_shortcuts (bool set_shortcuts)
 {
   if (set_shortcuts)
--- a/libgui/src/main-window.h	Fri Apr 25 06:40:21 2014 +0200
+++ b/libgui/src/main-window.h	Sun Apr 27 13:03:08 2014 +0200
@@ -194,6 +194,7 @@
 
   // setting global shortcuts
   void set_global_shortcuts (bool enable);
+  void set_global_edit_shortcuts (bool enable);
 
   // handling the clipboard
   void clipboard_has_changed (QClipboard::Mode);