annotate libgui/src/octave-dock-widget.h @ 17899:14c427b5c5c1

Restore geometry of floating widgets after restart in windows (bug #40485) * main-window.cc(set_window_layout): non-window systems: restore geometry of all non-floating widgets, make widgets floating after restoring main window * octave_dock_widget.h: new class variable for floating state * octave_dock_widget.cc(constructor): initialize floating to false; (destructor): use this new state variable for saving settings; (make_window): store last docked geometry, set last floating geometry with setGeometry instead of restoreGeometry, set floating state true; (make_widget): save last geometry with geometry only, restore last docked geometry, set floating state false; (change_floating): determine necessary action from floating state;
author Torsten <ttl@justmail.de>
date Mon, 11 Nov 2013 07:32:19 +0100
parents ebb3ef964372
children b3838cedfe04
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
1 /*
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
2
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
3 Copyright (C) 2012-2013 Richard Crozier
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
4
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
5 This file is part of Octave.
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
6
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
10 option) any later version.
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
11
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
15 for more details.
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
16
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
20
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
21 */
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
22
17822
ebb3ef964372 maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents: 17790
diff changeset
23 #if !defined (octave_octave_dock_widget_h)
ebb3ef964372 maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents: 17790
diff changeset
24 #define octave_octave_dock_widget_h 1
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
25
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
26 #include <QDockWidget>
16611
999400bebe5e move more common code from dock widgets into octave-dock-widget.h
Torsten <ttl@justmail.de>
parents: 16461
diff changeset
27 #include <QSettings>
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
28 #include <QIcon>
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
29 #include <QMainWindow>
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
30 #include <QMouseEvent>
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
31
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
32 class octave_dock_widget : public QDockWidget
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
33 {
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
34 Q_OBJECT
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
35
16461
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
36 public:
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
37
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
38 octave_dock_widget (QWidget *p = 0);
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
39 virtual ~octave_dock_widget ();
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
40
16809
84505f200e05 fix checked state of window menu entries at startup (bug #39322)
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
41 virtual void connect_visibility_changed (void);
16818
caf3d2a45da0 clean up some code for undocking and docking widgets
Torsten <ttl@justmail.de>
parents: 16809
diff changeset
42 void make_window (void);
17090
1d544ac39369 show correct undock-button of widgets when window layout is resetted
Torsten <ttl@justmail.de>
parents: 16881
diff changeset
43 void make_widget (bool dock=true);
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
44 void set_title (const QString&);
16611
999400bebe5e move more common code from dock widgets into octave-dock-widget.h
Torsten <ttl@justmail.de>
parents: 16461
diff changeset
45
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
46 signals:
16461
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
47
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
48 /** Custom signal that tells whether a user has clicked away
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
49 * that dock widget, i.e the active dock widget has
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
50 * changed. */
16340
045ce3896e3f Stop compilation warning about signal function declared virtual.
Rik <rik@octave.org>
parents: 16057
diff changeset
51 void active_changed (bool active);
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
52
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
53 protected:
16461
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
54
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
55 virtual void closeEvent (QCloseEvent *e)
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
56 {
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
57 emit active_changed (false);
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
58 QDockWidget::closeEvent (e);
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
59 }
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
60
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17090
diff changeset
61 QWidget * focusWidget ();
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
62
16461
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
63 public slots:
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
64
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
65 virtual void focus (void)
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
66 {
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
67 if (! isVisible ())
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
68 setVisible (true);
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
69
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
70 setFocus ();
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
71 activateWindow ();
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
72 raise ();
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
73 }
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
74
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
75 virtual void handle_visibility (bool visible)
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
76 {
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
77 if (visible && ! isFloating ())
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
78 focus ();
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
79 }
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
80
16611
999400bebe5e move more common code from dock widgets into octave-dock-widget.h
Torsten <ttl@justmail.de>
parents: 16461
diff changeset
81 virtual void notice_settings (const QSettings*)
999400bebe5e move more common code from dock widgets into octave-dock-widget.h
Torsten <ttl@justmail.de>
parents: 16461
diff changeset
82 {
999400bebe5e move more common code from dock widgets into octave-dock-widget.h
Torsten <ttl@justmail.de>
parents: 16461
diff changeset
83 }
999400bebe5e move more common code from dock widgets into octave-dock-widget.h
Torsten <ttl@justmail.de>
parents: 16461
diff changeset
84
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
85 QMainWindow *main_win () { return _parent; }
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
86
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
87 protected slots:
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
88
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
89 /** Slot to steer changing visibility from outside. */
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
90 virtual void handle_visibility_changed (bool visible)
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
91 {
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
92 if (visible)
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
93 emit active_changed (true);
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
94 }
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
95 /** slots to handle copy & paste */
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
96 virtual void copyClipboard ()
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
97 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
98 }
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
99 virtual void pasteClipboard ()
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
100 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
101 }
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
102
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
103 private slots:
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
104
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
105 void change_floating (bool);
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
106 void change_visibility (bool);
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
107
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
108 private:
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
109
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
110 QMainWindow *_parent; // store the parent since we are reparenting to 0
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
111 QAction *_dock_action;
17899
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17822
diff changeset
112 bool _floating;
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16611
diff changeset
113
16057
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
114 };
c3057d80cf91 Created common octave_dock_widget class
Richard Crozier <richard.crozier@yahoo.co.uk>
parents:
diff changeset
115
16461
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16340
diff changeset
116 #endif