Making dockable widgets (except command window) available in command-line version of Octave

I’d like to make (most of) the dockable widgets available when running Octave in command line mode[*]. I think this would be useful for people who prefer the CLI interface but may occasionally want to pop up the documentation browser, the code editor, or the variable editor. I imagine that the file, workspace, and history browser widgets could even be useful for some users.

The CLI version already allows Qt graphics windows to be opened, so it seems this should be a fairly easy change. I experimented with making the base_octave_qobject object own the documentation browser window when Octave doesn’t start the GUI (and thus doesn’t create a main_window object). But with these widgets built on top of QDockWidget it wasn’t quite as simple as I’d hoped. The octave_dock_widget class and the underlying QDockWidget seem to really want to be attached to a parent where they can be docked.

I’m sure we could create separate widgets for these windows that don’t use the dock widget. I tried another experiment writing a simple documentation widget simply derived from QWidget and it sort of worked, but would need layout and geometry hints to really work correctly. Since the existing dockable widgets alread have all of that, I’d rather avoid the duplication. And it just seems that it would be nice to have a single widget that has the option of being dockable. It would be even better if that could all be done in the octave_dock_widget class because then the problem could be solved once for all these windows. Any insight into doing that would be greatly appreciated.

[*] By “command-line mode”, I mean starting octave without the --gui flag, but still running the version linked with Qt libraries, not the octave-cli binary (that one doesn’t link with Qt).

Cannot comment on how to make it happen but just to say that it would be a great feature. I am someone who would prefer to use the CLI interface but with the code editor, so end up using the full GUI.

As a comparison point, I use Matlab with matlab -nodesktop but use the code editor edit and documentation browser doc. I don’t think there is a way to display the other widgets (variable editor, file and history browser) but that’s not something that appeals to me. From the CLI, you can start the GUI interface with desktop and when closing it, it returns to the CLI; not that I have ever used this.

I cannot provide any help either but encourage the effort. I am a cli user and I only start the GUI when I want to browse the html doc, so I would be very interested to have that feature.

Once the new command window widget is finished, we will also be able to start the full GUI interface from the command line and return to the CLI when it is closed.

See also this topic: I’ll try to make the changes described there optional with a configure switch (or, better, command line option) so I can push them but allow others to more easily experiment with them.

I’m attaching a (very) preliminary patch just as a proof of concept that allowing dock widgets to be launched as separate windows should be possible.

If I have some more time to work on this, I plan to do something like

  1. Store all dock widgets in a separate object that is owned by the base_octave_qobject object instead of the main_window object.
  2. Allow dock widgets stored in that object to be created on demand.
  3. Allow dock widgets to be adopted by the main_window object. The main_window object will simply acquire references to them.
  4. If the GUI is started from the command line after some of these dock widgets are created, then they will continue to exist (as undocked windows, of course) after the main_window object is closed.

Some care may be needed to disconnect signals when the dock widgets are adopted by the main_window object and then reconnect them when the main_window object is closed and deleted.

doc-browser-diffs.txt (10.4 KB)