diff libgui/qterminal/libqterminal/QTerminal.h @ 20995:aab7a3c7168e

edit a file from an error message in the terminal (bug #35619) * QTerminal.cc (handleCustomContextMenuRequested): move slot for the context menu from header file, detect an error location by regular expressions; (edit_file): slot context menu entry for editing a file in an error message * QTerminal.h: new signal for editing a file from an error message, slot handleCustomContextMenuRequested moved into QTerminal.cc, new edit action in the context menu, new slot for context menu entry, connect new edit signal to related slot in the main window * file-editor-tab.cc (handle_context_menu_edit): only keep searching for an embedded function, move the rest of the search into the editor, called via a new signal; (goto_line): center the new line in all cases * file-editor-tab.h: new signal for editing an m-file * file-editor.cc (handle_edit_mfile_request): partly moved from file-editor-tab; (construct): connect new signals from file-editor-tab and from main window to the new slot for searching and editing an m-file * file-editor.h: new slot for searching and editing an m-file * main-window.cc (edit_mfile): new slot for editing an m-file, just emitting the signal for the editor * main-window.h: new slot and new signal for editing an m-file
author Torsten <ttl@justmail.de>
date Mon, 28 Dec 2015 16:44:10 +0100
parents dd1dcef1ee33
children bac0d6f07a3e
line wrap: on
line diff
--- a/libgui/qterminal/libqterminal/QTerminal.h	Mon Dec 28 12:10:05 2015 +0100
+++ b/libgui/qterminal/libqterminal/QTerminal.h	Mon Dec 28 16:44:10 2015 +0100
@@ -94,6 +94,8 @@
 
   void interrupt_signal (void);
 
+  void edit_mfile_request (const QString&, int);
+
 public slots:
 
   virtual void copyClipboard (void) = 0;
@@ -102,15 +104,7 @@
 
   virtual void selectAll (void) = 0;
 
-  virtual void handleCustomContextMenuRequested (const QPoint& at)
-  {
-    QClipboard * cb = QApplication::clipboard ();
-
-    _paste_action->setEnabled (cb->text().length() > 0);
-    _copy_action->setEnabled (selectedText().length() > 0);
-
-    _contextMenu->exec (mapToGlobal (at));
-  }
+  virtual void handleCustomContextMenuRequested (const QPoint& at);
 
   void notice_settings (const QSettings *settings);
 
@@ -120,6 +114,8 @@
 
   void set_global_shortcuts (bool focus_out);
 
+  void edit_file (void);
+
 protected:
 
   QTerminal (QWidget *xparent = 0) : QWidget (xparent)
@@ -142,6 +138,8 @@
     _selectall_action = _contextMenu->addAction (
                       tr ("Select All"), this, SLOT (selectAll ()));
 
+    _edit_action = _contextMenu->addAction (
+                      tr (""), this, SLOT (edit_file ()));
 
     _contextMenu->addSeparator ();
 
@@ -154,6 +152,9 @@
     connect (this, SIGNAL (report_status_message (const QString&)),
              xparent, SLOT (report_status_message (const QString&)));
 
+    connect (this, SIGNAL (edit_mfile_request (const QString&, int)),
+             xparent, SLOT (edit_mfile (const QString&, int)));
+
     connect (xparent, SIGNAL (settings_changed (const QSettings *)),
              this, SLOT (notice_settings (const QSettings *)));
 
@@ -193,6 +194,7 @@
   QAction * _copy_action;
   QAction * _paste_action;
   QAction * _selectall_action;
+  QAction * _edit_action;
 
   QAction *_interrupt_action;
   QAction *_nop_action;