Mercurial > octave
diff libgui/src/octave-dock-widget.h @ 29613:9367cba2a6d5
allow most dock widgets to be used from command line
This change is an initial attempt to allow the documentation, file,
history, variable editor, and workspace widgets to be opened from the
command line. While running in command line mode, some connections
between those widgets and the interpreter or between two widgets may
be missing. The aim is to eventually make those work but this is a
good start.
These dock widgets are now owned by the base_qobject object and shared
with the main_window object. If they exist when the main_window is
created (possible if using the new terminal widget) then a pointer to
the main_window object is passed to the dock_widget so that they may
be docked there. If the desktop is closed and control returns to the
command line, undocked widgets remain available.
* octave-qobject.h, octave-qobject.cc
(base_qobject::m_documentation_widget,
base_qobject::m_file_browser_widget, base_qobject::m_history_widget,
base_qobject::m_workspace_widget, base_qobject::m_editor_widget,
base_qobject::m_variable_editor_widget): New data members.
(base_qobject::documentation_widget, base_qobject::file_browser_widget,
base_qobject::history_widget, base_qobject::workspace_widget,
base_qobject::editor_widget, base_qobject::variable_editor_widget):
New functions to create dock widgets as needed.
(base_qobject::show_documentation_window,
base_qobject::show_file_browser_window,
base_qobject::show_command_history_window,
base_qobject::show_workspace_window, base_qobject::edit_variable,
base_qobject::handle_variable_editor_update): New functions. Make
signal slot connections that do not require the main window here, not
in main_window::construct_octave_qt_link.
* files-dock-widget.cc (files_dock_widget::files_dock_widget):
If no parent, call make_window.
* documentation-dock-widget.cc
(documentation_dock_widget::documentation_dock_widget): Likewise.
* history-dock-widget.cc (history_dock_widget::history_dock_widget):
Likewise.
* workspace-view.cc (workspace_view::workspace_view): Likewise.
* doc.m: Always give the event manager a chance to display the
documentation, not just if the GUI is running.
* documentation.cc (documentation::documentation): Make sub-objects
children of the documentation object, not children of the parent of
the documentation object.
* main-window.h, main-window.cc (main_window::m_command_window,
main_window::m_history_window, main_window::m_file_browser_window,
main_window::m_doc_browser_window, main_window::m_editor_window,
main_window::m_workspace_window,
main_window::m_variable_editor_window): Manage objects with QPointer.
(main_window::main_window): Acquire m_doc_browser_window,
m_history_window, m_workspace_window, and m_variable_editor_window
from octave_qobj.
* octave-dock-widget.cc (octave_dock_widget::octave_dock_widget):
Don't reference m_parent if it is nullptr.
(octave_dock_widget::handle_settings): Likewise. Return immediately
if settings is nullptr.
(octave_dock_widget::set_main_window): New function.
* variable-editor.h, variable-editor.cc
(variable_editor::~variable_editor): Explicitly delete m_tool_bar and
set it to nullptr.
(variable_editor::edit_variable, variable_editor::notice_settings,
variable_editor::variable_destroyed): Avoid referencing m_tool_bar if
it is nullptr.
* qt-interpreter-events.h, qt-interpreter-events.cc
(qt_interpreter_events::show_documentation): Rename from show_doc.
Change all uses.
(qt_interpreter_events::register_documentation): Rename from
register_doc. Change all uses.
(qt_interpreter_events::unregister_documentation): Rename from
unregister_doc. Change all uses.
(qt_interpreter_events::show_file_browser,
qt_interpreter_events::show_command_history,
qt_interpreter_events::show_workspace): New functions.
(qt_interpreter_events::show_documentation_signal):
Rename from show_doc_signal. Change all uses.
qt_interpreter_events::register_documentation_signal):
Rename from register_doc_signal. Change all uses.
qt_interpreter_events::unregister_documentation_signal):
Rename from unregister_doc_signal. Change all uses.
(qt_interpreter_events::show_file_browser_signal,
qt_interpreter_events::show_command_history_signal,
qt_interpreter_events::show_workspace_signal): New signals.
* event-manager.h, event-manager.cc
(F__event_manager_show_file_browser__,
F__event_manager_show_command_history__,
F__event_manager_show_workspace__): New functions.
(F__event_manager_show_documentation__): Rename from
__event_manager_show_doc__. Change all uses.
(F__event_manager_register_documentation__): Rename from
F__event_manager_register_doc__. Change all uses.
(F__event_manager_unregister_documentation__): Rename from
F__event_manager_unregister_doc__. Change all uses.
(Fopenvar): Don't require GUI to be running.
(interpreter_events::show_documentation): Rename from show_doc.
Change all uses.
(interpreter_events::register_documentation): Rename from
register_doc. Change all uses.
(interpreter_events::unregister_documentation): Rename from
unregister_doc. Change all uses.
(interpreter_events::show_file_browser,
interpreter_events::show_command_history,
interpreter_events::show_workspace): New functions.
(event_manager::show_documentation): Rename from show_doc. Change all
uses.
(event_manager::register_documentation): Rename from
register_doc. Change all uses.
(event_manager::register_documentation): Rename from unregister_doc.
Change all uses.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 29 Apr 2021 11:12:40 -0400 |
parents | c7b104ebed4d |
children | b16748c8aa4d |
line wrap: on
line diff
--- a/libgui/src/octave-dock-widget.h Tue May 04 15:33:58 2021 -0400 +++ b/libgui/src/octave-dock-widget.h Thu Apr 29 11:12:40 2021 -0400 @@ -28,7 +28,6 @@ #include <QDockWidget> #include <QIcon> -#include <QMainWindow> #include <QMouseEvent> #include <QToolButton> @@ -38,6 +37,7 @@ namespace octave { class base_qobject; + class main_window; // The few decoration items common to both main window and variable editor. @@ -49,6 +49,8 @@ label_dock_widget (QWidget *p, base_qobject& oct_qobj); + ~label_dock_widget (void) = default; + // set_title() uses the custom title bar while setWindowTitle() uses // the default title bar (with style sheets) void set_title (const QString&); @@ -90,10 +92,12 @@ octave_dock_widget (const QString& obj_name, QWidget *p, base_qobject& oct_qobj); - virtual ~octave_dock_widget (void) = default; + ~octave_dock_widget (void) = default; void set_predecessor_widget (octave_dock_widget *prev_widget); + void set_main_window (main_window *mw); + signals: //! Custom signal that tells whether a user has clicked away that dock @@ -162,7 +166,7 @@ //! Stores the parent, since we are reparenting to 0. - QMainWindow *m_parent; + main_window *m_main_window; bool m_custom_style; bool m_focus_follows_mouse;