diff libgui/src/m-editor/file-editor.h @ 27787:5169ed0ff0f0

only one find dialog for all editor tabs (bug #57238) This changeset essentially move the handling of the find dialog from the file editor tab(s) to the editor itself. * gui-preferences-ed.h: added enum with find dialog options and preferecens of the find dialog that are stored in the preferences file * file-editor-tab.cc (file_editor_tab): remove initialization of find dialog; (~file_editor_tab): remove removal of find dialog; (handle_toplevel_changed): remove slot, which only handled the find dialog (set_focus): emit new signal for updating the find dialog with edit area; (handle_find_dialog_finished, find, finde_create): removed; (change_editor_state): remove find dialog updates * file-editor-tab.h: do not include find-dialog.h, new signal edit_area_changed, removed slots request_find_next, request_find_previous, handle_toplevel_changed, find, find_next, find_previous, handle_find_dialog_finished, removed method find_create as well as class variables m_find_dialog and m_find_dlg_data * file-editor.cc (file_editor) initialize protexted pointer to find dialog, no more list of actions that are also required in the find dialog (enable_menu_shortcuts): make find dialog visible or not depending on the editors focus; (handle_tab_ready_to_close): close find dialog, when editor is closed; (request_find): do not emit a signal for the editor tabs but create and activate the find dialog here; (request_find_next, request_find_previous): no more teb signal, call the related method of the find dialog directly; (find_create): new method for creating the find dialog with appropriate icon and position; (notice_settings): update window icon of the find dialog (toplevel_change): do not emit signal for editor tabs but close and recreate the find dialog with the appropriate parent (make_file_editor_tab): connect new signal for changed edit area to find dialog slot, remove other find related connections * file-editor.h: include find-dialog.h, removed signal fetab_toplevel_changed, fetab_find, fetab_find_next, fetab_find_previous, added signal edit_area_changed, added method find_create, removed m_fetab_actions, added QPointer m_find_dialog * find-dialog.cc include required include file, (find_dialog): ctor with base_qobject, editor widget and parent, new window title, remove obsolete signal connection and add connections for new signals; (update_edit_area): slot when a new edit area gets focus and becomes the target for the find dialog (save_settings): moved from save_data, data is saved int he preferences file, not in struct (restore_settings): moved from restore data, load settings from preferences file, not from a given struct (reject): reimplemented reject method for calling close on ESC; (closeEvent): reimplemented close event for saving settings before close (set_visible): method for hiding and showing the dialog depending on the focus state of the editor, remember last position because otherwise the dialog would be slightly shifted each time it is re-shown * find-dialog.h: remove data structure for settings and enum with options, new methods find_next, find_prev, set_visible, moved save_data and restore_data to save_settings and restore_settings resp., new slot update_edit_area, reimplemented reject and closeEvent, class variables for editor, qobject and last position
author Torsten Lilge <ttl-octave@mailbox.org>
date Sun, 08 Dec 2019 21:39:57 +0100
parents c9ebcb9050b4
children 3fada47cc58a
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.h	Sun Dec 08 11:11:00 2019 -0800
+++ b/libgui/src/m-editor/file-editor.h	Sun Dec 08 21:39:57 2019 +0100
@@ -38,6 +38,7 @@
 
 #include "file-editor-interface.h"
 #include "file-editor-tab.h"
+#include "find-dialog.h"
 #include "tab-bar.h"
 
 namespace octave
@@ -117,7 +118,6 @@
 
   signals:
 
-    void fetab_toplevel_changed (bool);
     void fetab_settings_changed (const gui_settings *settings);
     void fetab_change_request (const QWidget *ID);
     // Save is a ping-pong type of communication
@@ -146,9 +146,6 @@
     void fetab_unindent_selected_text (const QWidget *ID);
     void fetab_smart_indent_line_or_selected_text (const QWidget *ID);
     void fetab_convert_eol (const QWidget *ID, QsciScintilla::EolMode eol_mode);
-    void fetab_find (const QWidget *ID, QList<QAction *>);
-    void fetab_find_next (const QWidget *ID);
-    void fetab_find_previous (const QWidget *ID);
     void fetab_goto_line (const QWidget *ID, int line = -1);
     void fetab_move_match_brace (const QWidget *ID, bool select);
     void fetab_completion (const QWidget*);
@@ -166,6 +163,8 @@
     void fetab_set_directory (const QString& dir);
     void fetab_recover_from_exit (void);
 
+    void edit_area_changed (octave_qscintilla *edit_area);
+
     void request_settings_dialog (const QString&);
     void request_open_file_external (const QString& file_name, int line);
     void file_loaded_signal (void);
@@ -175,8 +174,6 @@
 
   public slots:
 
-    void toplevel_change (bool);
-
     void activate (void);
     void set_focus (QWidget *fet);
     void enable_menu_shortcuts (bool);
@@ -272,6 +269,8 @@
 
     void update_octave_directory (const QString& dir);
 
+    void toplevel_change (bool toplevel);
+
   protected slots:
 
     void copyClipboard (void);
@@ -327,6 +326,8 @@
 
     bool editor_tab_has_focus (void);
 
+    void find_create (void);
+
     file_editor_tab * find_tab_widget (const QString& openFileName);
     QAction * add_action (QMenu *menu, const QString& text,
                           const char *member, QWidget *receiver = nullptr);
@@ -442,8 +443,6 @@
     QMenu *m_fileMenu;
     QMenu *m_view_editor_menu;
 
-    QList<QAction*> m_fetab_actions;
-
     file_editor_tab_widget *m_tab_widget;
 
     int m_marker_breakpoint;
@@ -458,6 +457,8 @@
     QStringList m_mru_files;
     QStringList m_mru_files_encodings;
 
+    QPointer<find_dialog> m_find_dialog;
+
     // List of data on temporarily closed files for later reloading.
     QList<session_data> m_tmp_closed_files;
   };