Mercurial > octave
changeset 29199:0b18887bc997
simplify initialization of gui dock widgets
* file-editor.cc (handle_visibility): call common part of this slot
instead of repeating its contents here
* main-window.cc (main_window): do not connect visibility changed
signal from dock widgets since this is done in the dock widget
constructors; instead emit new signal for initialization of the
window menu and setup editor shortcuts
(connect_visibility_changed): removed obsolete method
* main-window.h: new signal init_window_menu, removed method
connect_visibility_changed
* octave-dock-widget.cc (octave_dock_widget): rename slot for
visibilityChanged signal, connect new slot for initialization of
the window menu
(connect_visibility_changed): remove obsolete method;
(init_window_menu_entry): new slot for dis/enabling related menu
window entry;
(handle_visibility): combine contents from former two slots
* octave-dock-widget.h: removed slot connect_visibility_changed,
new signal init_window_menu_entry, removed slot
handle_visibility_changed
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sat, 19 Dec 2020 10:49:43 +0100 |
parents | ec33b1617cd5 |
children | 6e0952fa5a4f |
files | libgui/src/m-editor/file-editor.cc libgui/src/main-window.cc libgui/src/main-window.h libgui/src/octave-dock-widget.cc libgui/src/octave-dock-widget.h |
diffstat | 5 files changed, 21 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor.cc Fri Dec 18 16:16:53 2020 -0800 +++ b/libgui/src/m-editor/file-editor.cc Sat Dec 19 10:49:43 2020 +0100 @@ -1408,6 +1408,8 @@ // files and is made visible. void file_editor::handle_visibility (bool visible) { + octave_dock_widget::handle_visibility (visible); + if (m_closed && visible) { m_closed = false; @@ -1417,9 +1419,6 @@ } empty_script (false, visible); - - if (visible && ! isFloating ()) - setFocus (); } // This slot is a reimplementation of the virtual slot in octave_dock_widget.
--- a/libgui/src/main-window.cc Fri Dec 18 16:16:53 2020 -0800 +++ b/libgui/src/main-window.cc Sat Dec 19 10:49:43 2020 +0100 @@ -244,10 +244,11 @@ init_terminal_size (); - // Connect signals for changes in visibility now before window is - // shown. - - connect_visibility_changed (); + emit init_window_menu (); + +#if defined (HAVE_QSCINTILLA) + m_editor_window->enable_menu_shortcuts (false); +#endif focus_command_window (); } @@ -1598,18 +1599,6 @@ settings->sync (); } - // Connecting the signals emitted when the visibility of a widget changes. - // This has to be done after the window is shown (see octave-gui.cc) - void main_window::connect_visibility_changed (void) - { - for (auto *widget : dock_widget_list ()) - widget->connect_visibility_changed (); - -#if defined (HAVE_QSCINTILLA) - m_editor_window->enable_menu_shortcuts (false); -#endif - } - void main_window::copyClipboard (void) { if (m_current_directory_combo_box->hasFocus ())
--- a/libgui/src/main-window.h Fri Dec 18 16:16:53 2020 -0800 +++ b/libgui/src/main-window.h Sat Dec 19 10:49:43 2020 +0100 @@ -99,6 +99,7 @@ void settings_changed (const gui_settings *); void init_terminal_size_signal (void); + void init_window_menu (void); void new_file_signal (const QString&); void open_file_signal (const QString&); void open_file_signal (const QString& file, const QString& enc, int line); @@ -202,7 +203,6 @@ void init_terminal_size (void); void set_window_layout (gui_settings *settings); void write_settings (void); - void connect_visibility_changed (void); void copyClipboard (void); void pasteClipboard (void);
--- a/libgui/src/octave-dock-widget.cc Fri Dec 18 16:16:53 2020 -0800 +++ b/libgui/src/octave-dock-widget.cc Sat Dec 19 10:49:43 2020 +0100 @@ -194,7 +194,10 @@ connect (this, SIGNAL (topLevelChanged (bool)), this, SLOT (toplevel_change (bool))); connect (this, SIGNAL (visibilityChanged (bool)), - this, SLOT (handle_visibility_changed (bool))); + this, SLOT (handle_visibility (bool))); + + connect (p, SIGNAL (init_window_menu (void)), + this, SLOT (init_window_menu_entry (void))); connect (p, SIGNAL (settings_changed (const gui_settings *)), this, SLOT (handle_settings (const gui_settings *))); @@ -262,12 +265,9 @@ handle_settings (rmgr.get_settings ()); } - // connect signal visibility changed to related slot (called from main-window) void - octave_dock_widget::connect_visibility_changed (void) + octave_dock_widget::init_window_menu_entry (void) { - connect (this, SIGNAL (visibilityChanged (bool)), - this, SLOT (handle_visibility (bool))); emit active_changed (isVisible ()); // emit once for init of window menu } @@ -631,8 +631,12 @@ void octave_dock_widget::handle_visibility (bool visible) { - if (visible && ! isFloating ()) - setFocus (); + if (visible) + { + emit active_changed (true); + if (! isFloating ()) + setFocus (); + } } void
--- a/libgui/src/octave-dock-widget.h Fri Dec 18 16:16:53 2020 -0800 +++ b/libgui/src/octave-dock-widget.h Sat Dec 19 10:49:43 2020 +0100 @@ -92,8 +92,6 @@ virtual ~octave_dock_widget (void) = default; - virtual void connect_visibility_changed (void); - void set_predecessor_widget (octave_dock_widget *prev_widget); signals: @@ -126,6 +124,8 @@ virtual void notice_settings (const gui_settings *) { } + void init_window_menu_entry (void); + void handle_settings (const gui_settings *); void handle_active_dock_changed (octave_dock_widget*, octave_dock_widget*); @@ -148,14 +148,6 @@ virtual void toplevel_change (bool); - //! Slot to steer changing visibility from outside. - - virtual void handle_visibility_changed (bool visible) - { - if (visible) - emit active_changed (true); - } - //! Event filter for double clicks into the window decoration elements. bool eventFilter (QObject *obj, QEvent *e);