comparison libgui/src/octave-dock-widget.h @ 16057:c3057d80cf91

Created common octave_dock_widget class * octave_dock_widget.h : New class octave_dock_widget with common dock widget methods, slots and signals * file_editor_interface.h: Now inherit from octave_dock_widget, removed common dock widget code * file_editor.h: Now inherit from octave_dock_widget, removed common dock widget code * file_editor.cc: Now inherit from octave_dock_widget, removed common dock widget code * files_dockwidget.h: Now inherit from octave_dock_widget, removed common dock widget code * files_dockwidget.cc: Now inherit from octave_dock_widget, removed common dock widget code * history_dockwidget.h: Now inherit from octave_dock_widget, removed common dock widget code * history_dockwidget.cc: Now inherit from octave_dock_widget, removed common dock widget methods * terminal_dockwidget.h: Now inherit from octave_dock_widget, removed common dock widget code * terminal_dockwidget.cc: Now inherit from octave_dock_widget, removed common dock widget code * module.mk: Added octave_dock_widget
author Richard Crozier <richard.crozier@yahoo.co.uk>
date Wed, 06 Feb 2013 21:45:04 +0000
parents
children 045ce3896e3f
comparison
equal deleted inserted replaced
16056:f4f0aea29b21 16057:c3057d80cf91
1 /*
2
3 Copyright (C) 2012-2013 Richard Crozier
4
5 This file is part of Octave.
6
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20
21 */
22
23 #ifndef OCTAVEDOCKWIDGET_H
24 #define OCTAVEDOCKWIDGET_H
25
26 #include <QDockWidget>
27 //#include <QMenu>
28 //#include <QToolBar>
29
30 class octave_dock_widget : public QDockWidget
31 {
32 Q_OBJECT
33
34 public:
35 octave_dock_widget (QWidget *p)
36 : QDockWidget (p)
37 {
38 connect (this, SIGNAL (visibilityChanged (bool)),
39 this, SLOT (handle_visibility_changed (bool)));
40
41 connect (this, SIGNAL (topLevelChanged(bool)),
42 this, SLOT(top_level_changed(bool)));
43 }
44
45 virtual ~octave_dock_widget () { }
46
47 signals:
48 /** Custom signal that tells if a user has clicked away
49 * that dock widget, i.e the active dock widget has
50 * changed. */
51 virtual void active_changed (bool active);
52
53 protected:
54 virtual void closeEvent (QCloseEvent *e)
55 {
56 emit active_changed (false);
57 QDockWidget::closeEvent (e);
58 }
59
60 protected slots:
61
62 /** Slot to steer changing visibility from outside. */
63 virtual void handle_visibility_changed (bool visible)
64 {
65 if (visible)
66 emit active_changed (true);
67 }
68
69 /** Slot when floating property changes */
70 virtual void top_level_changed (bool floating)
71 {
72 if(floating)
73 {
74 setWindowFlags(Qt::Window); // make a window from the widget when floating
75 show(); // make it visible again since setWindowFlags hides it
76 }
77 }
78
79 };
80
81 #endif // OCTAVEDOCKWIDGET_H