# HG changeset patch # User Richard Crozier # Date 1350729369 -3600 # Node ID 5649e84ea3ce3c667154d69a390004fd1057d52d # Parent 673889d492563428fa9da7ee5c1c88ba002d22e4 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. diff --git a/libgui/src/m-editor/file-editor-interface.h b/libgui/src/m-editor/file-editor-interface.h --- 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