comparison libgui/src/documentation-dockwidget.cc @ 16453:2e3c652c89d1

improve encapsulation of documentation browser window object * documentation-dockwidget.h, documentation-dockwidget.cc (documentation_dock_widget): Derive from octave_dock_widget, not QDockWidget. (documentation_dock_widget::documentation_dock_widget): Don't connect documentation_dock_widget::visibilityChanged signal to documentation_dock_widget::handle_visibility_changed. Don't connect documentation_dock_widget::topLevelChanged signal to documentation_dock_widget::top_level_changed. Set status tip. (documentation_dock_widget::connect_visibility_changed): New function. (documentation_dock_widget::closeEvent): Delete. (documentation_dock_widget::focus, (documentation_dock_widget::handle_visibility): New functions. (documentation_dock_widget::active_changed): Delete signal. * main-window.h, main-window.cc (main_window::file_browser_window): Rename from documentation_dock_widget. Change all uses. (main_window::main_window): Initialize it. (main_window::focus_documentation, main_window::handle_documentation_visible): Delete. (main_window::connect_visibility_changed): Call doc_browser_window->connect_visibility_changed. (main_window::construct): Don't create _documentation_dock_widget.
author John W. Eaton <jwe@octave.org>
date Sun, 07 Apr 2013 00:43:36 -0400
parents bbbb89cc338f
children
comparison
equal deleted inserted replaced
16452:744ff2fe11ce 16453:2e3c652c89d1
25 #endif 25 #endif
26 26
27 #include "documentation-dockwidget.h" 27 #include "documentation-dockwidget.h"
28 28
29 documentation_dock_widget::documentation_dock_widget (QWidget *p) 29 documentation_dock_widget::documentation_dock_widget (QWidget *p)
30 : QDockWidget (p) 30 : octave_dock_widget (p)
31 { 31 {
32 setObjectName ("DocumentationDockWidget"); 32 setObjectName ("DocumentationDockWidget");
33 setWindowIcon (QIcon(":/actions/icons/logo.png")); 33 setWindowIcon (QIcon (":/actions/icons/logo.png"));
34 setWindowTitle (tr ("Documentation")); 34 setWindowTitle (tr ("Documentation"));
35 35 setStatusTip (tr ("See the documentation for help."));
36 connect (this, SIGNAL (visibilityChanged (bool)),
37 this, SLOT (handle_visibility_changed (bool)));
38 // topLevelChanged is emitted when floating property changes (floating = true)
39 connect (this, SIGNAL (topLevelChanged(bool)), this, SLOT(top_level_changed(bool)));
40 36
41 _webinfo = new webinfo (this); 37 _webinfo = new webinfo (this);
42 setWidget (_webinfo); 38 setWidget (_webinfo);
43 } 39 }
44 40
45 void 41 void
46 documentation_dock_widget::handle_visibility_changed (bool visible) 42 documentation_dock_widget::connect_visibility_changed (void)
47 { 43 {
48 if (visible) 44 connect (this, SIGNAL (visibilityChanged (bool)),
49 emit active_changed (true); 45 this, SLOT (handle_visibility (bool)));
50 } 46 }
51 47
52 void 48 void
53 documentation_dock_widget::closeEvent (QCloseEvent *e) 49 documentation_dock_widget::focus (void)
54 { 50 {
55 emit active_changed (false); 51 if (! isVisible ())
56 QDockWidget::closeEvent (e); 52 setVisible (true);
53
54 setFocus ();
55 activateWindow ();
56 raise ();
57 } 57 }
58 58
59 // slot for signal that is emitted when floating property changes
60 void 59 void
61 documentation_dock_widget::top_level_changed (bool floating) 60 documentation_dock_widget::handle_visibility (bool visible)
62 { 61 {
63 if(floating) 62 if (visible && ! isFloating ())
64 { 63 focus ();
65 setWindowFlags(Qt::Window); // make a window from the widget when floating
66 show(); // make it visible again since setWindowFlags hides it
67 }
68 } 64 }