diff libgui/src/main-window.h @ 23385:41639665aa34

improve opening files from gui when built without qscintilla (bug #39179) * external-editor-interface.cc/h: new class with an interface for an external editor, which is used by preference or if qscintilla is not available; (external_editor_interface): ctor, connect a signal for opening the settings; (external_editor): check for an external editor being set in the settings; (call_custom_editor): call the custom editor; (request_open_file, request_open_file, handle_edit_file_request): slots for the various ways for opening a file * file-editor-interface.h: moved request_new_function and removed request_open_file into the main window * file-editor.cc: include external-editor-interface.h; (file_editor): file encoding tracked in main window; (request_new_function): moved into main window; (request_open_file (void)): moved to main window; (request_open_files): moved to main window; (handle_combo_enc_current_index): moved to main window; (restore_create_file_setting): moved into main window; (request_new_script): moved into main window; (restore_create_file_setting): moved into main window; (call_custom_editor): use external_editor_interface; (handle_edit_mfile_request): moved into main window; (construct): moved some signal connection into the main window; (add_file_editor_tab): update signal connection to moved slots; * file-editor.h: moved request_new_function, handle_edit_mfile_request, request_open_file (void), request_open_files, handle_combo_enc_current_index, and class variable _file_encodinginto the main window; * main-window.cc (main_window): initialize _file_encoding to empty string, set external editor interface and store active editor for connecting signals; (~main_window): delete external_editor_interface; (edit_mfile): directly use slot handle_edit_mfile_request moved here; (handle_edit_mfile_request): moved from editor to here; (request_new_function): moved from editor to here; (request_open_file): moved from file editor to here; (set_file_encoding): moved from file editor to here, old name was handle_combo_enc_current_index; (request_open_files): moved from file editor to here; (restore_create_file_setting): moved from editor to here; (construct_octave_qt_link): connect signals to slots in editor or external editor interface; (construct_file_menu): connect signals to slots in editor or external editor interface, slot for opening files now in main window (construct_new_menu): connect signals to slots in editor, external editor interface, or to slots moved here; * main-window.h: update signals according to moved slots, namely request_new_function, request_new_script, handle_edit_mfile_request, restore_create_file_setting, moved request_open_file, set_file_encoding, request_open_files, and class variable _file_encoding to here * module.mk: added new files external-editor-interface.cc/h
author Torsten <mttl@mailbox.org>
date Tue, 11 Apr 2017 08:00:23 +0200
parents c319e6d737f2
children e35a5c1233d0
line wrap: on
line diff
--- a/libgui/src/main-window.h	Tue Apr 11 19:28:29 2017 +0100
+++ b/libgui/src/main-window.h	Tue Apr 11 08:00:23 2017 +0200
@@ -40,6 +40,7 @@
 
 // Editor includes
 #include "file-editor-interface.h"
+#include "external-editor-interface.h"
 
 // QTerminal includes
 #include "QTerminal.h"
@@ -124,7 +125,7 @@
   void init_terminal_size_signal (void);
   void new_file_signal (const QString&);
   void open_file_signal (const QString&);
-  void edit_mfile_request (const QString&, const QString&, const QString&, int);
+  void open_file_signal (const QString& file, const QString& enc, int line);
 
   void show_doc_signal (const QString&);
 
@@ -195,6 +196,12 @@
   void debug_step_out (void);
   void debug_quit (void);
 
+  void request_open_file (void);
+  void request_new_script (const QString& commands = QString ());
+  void request_new_function (bool triggered = true);
+  void handle_edit_mfile_request (const QString& name, const QString& file,
+                                  const QString& curr_dir, int line);
+
   void handle_insert_debugger_pointer_request (const QString& file, int line);
   void handle_delete_debugger_pointer_request (const QString& file, int line);
   void handle_update_breakpoint_marker_request (bool insert,
@@ -261,6 +268,9 @@
 private slots:
 
   void disable_menu_shortcuts (bool disable);
+  void restore_create_file_setting ();
+  void set_file_encoding (const QString& new_encoding);
+  void request_open_files (const QStringList& open_file_names);
 
 protected:
   void closeEvent (QCloseEvent * closeEvent);
@@ -345,6 +355,9 @@
   file_editor_interface *editor_window;
   workspace_view *workspace_window;
 
+  external_editor_interface *_external_editor;
+  QWidget *_active_editor;
+
   QList<octave_dock_widget *> dock_widget_list ();
 
   octave_dock_widget *_active_dock;
@@ -439,6 +452,8 @@
   bool _prevent_readline_conflicts;
   bool _suppress_dbg_location;
   bool _start_gui;
+
+  QString _file_encoding;
 };
 
 class news_reader : public QObject