Mercurial > hg > octave-lojdl
changeset 15581:5649e84ea3ce
GUI: add toolbar to editor when undocked
* file_editor_interface.h
(file_editor_interface::file_editor_interface): Added
dockWidget_topLevelChanged slot to capture topLevelChanged signal
when undocking editor window.
author | Richard Crozier <richard.crozier@yahoo.co.uk> |
---|---|
date | Sat, 20 Oct 2012 11:36:09 +0100 |
parents | 673889d49256 |
children | 52df2e7baabe |
files | libgui/src/m-editor/file-editor-interface.h |
diffstat | 1 files changed, 31 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-interface.h +++ b/libgui/src/m-editor/file-editor-interface.h @@ -44,6 +44,16 @@ connect (this, SIGNAL (visibilityChanged (bool)), this, SLOT (handle_visibility_changed (bool))); + + // connect the editor dockWidget's topLevelChanged signal, which + // is emitted when its floating property changes, to a + // user-defined slot. We do this so than when the editor is popped + // out we can turn it into a proper window with all the normal + // toolbar buttons for a window, i.e. minimise, maximise, close + connect (this, + SIGNAL(topLevelChanged(bool)), this, + SLOT(dockWidget_topLevelChanged(bool))); + } virtual ~file_editor_interface () { } @@ -78,6 +88,27 @@ if (visible) emit active_changed (true); } + + // when the floating property of a dockWidget is changed from docked + // to floating we make it a top level window (with minmize, + // maximize, and close button in the title bar) by calling + // setWindowFlags(Qt::Window) + // + // The dockWidget will automatically regain it's Qt::widget flag + // when it becomes docked again (by dragging it to the right place + // or double clicking the title bar) + void dockWidget_topLevelChanged (bool isFloating) + { + if (isFloating) + { + //file_editor.setWindowFlags(Qt::Window); + this->setWindowFlags(Qt::Window); + // setWindowFlags calls setParent() when changing the flags + // for a window, causing the widget to be hidden. We must + // call show() to make the widget visible again + this->show(); + } + } }; #endif // FILEEDITORINTERFACE_H