annotate libgui/src/terminal-dock-widget.cc @ 16611:999400bebe5e

move more common code from dock widgets into octave-dock-widget.h * terminal-dock-widget.cc, file-editor.cc, files-dock-widget.cc, workspace-view.cc (constructor): remove connectiong changed_settings signal * files-dock-widget.cc/.h, file-editor.h: do not include QSettings here * octave-dock-widget.h(constructor): connect changed_settings signal * octave-dock-widget.h: include QSettings, empty virtual slot notice-settings
author Torsten <ttl@justmail.de>
date Sat, 04 May 2013 23:37:27 +0200
parents 2754c5fd6ae0
children ba808cd9d86c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
1 /*
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
2
16446
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
3 Copyright (C) 2013 John W. Eaton
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
4 Copyright (C) 2011-2012 Jacob Dawid
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
5
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
6 This file is part of Octave.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
7
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
9 under the terms of the GNU General Public License as published by the
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
11 option) any later version.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
12
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
16 for more details.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
17
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
18 You should have received a copy of the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
19 along with Octave; see the file COPYING. If not, see
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
20 <http://www.gnu.org/licenses/>.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
21
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
22 */
14692
d6d250812c01 Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
23
15286
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15204
diff changeset
24 #ifdef HAVE_CONFIG_H
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15204
diff changeset
25 #include <config.h>
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15204
diff changeset
26 #endif
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15204
diff changeset
27
16460
4d4e7c6f839d use consistent names for dock-widget files
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
28 #include "terminal-dock-widget.h"
14692
d6d250812c01 Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
29
16446
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
30 terminal_dock_widget::terminal_dock_widget (QWidget *p)
16470
7369b210dbd0 use pointer for terminal inside terminal_dock_widget
John W. Eaton <jwe@octave.org>
parents: 16461
diff changeset
31 : octave_dock_widget (p), terminal (new QTerminal (p))
14692
d6d250812c01 Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
32 {
16470
7369b210dbd0 use pointer for terminal inside terminal_dock_widget
John W. Eaton <jwe@octave.org>
parents: 16461
diff changeset
33 terminal->setObjectName ("OctaveTerminal");
7369b210dbd0 use pointer for terminal inside terminal_dock_widget
John W. Eaton <jwe@octave.org>
parents: 16461
diff changeset
34 terminal->setFocusPolicy (Qt::StrongFocus);
16446
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
35
14692
d6d250812c01 Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
36 setObjectName ("TerminalDockWidget");
15552
bbbb89cc338f make a floating widget behave like a normal window (bug #37190)
Torsten <ttl@justmail.de>
parents: 15368
diff changeset
37 setWindowIcon (QIcon(":/actions/icons/logo.png"));
14692
d6d250812c01 Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
38 setWindowTitle (tr ("Command Window"));
16470
7369b210dbd0 use pointer for terminal inside terminal_dock_widget
John W. Eaton <jwe@octave.org>
parents: 16461
diff changeset
39 setWidget (terminal);
16446
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
40
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
41 connect (this, SIGNAL (visibilityChanged (bool)),
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
42 this, SLOT (handle_visibility (bool)));
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
43
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
44 // Forward signals to QTerminal widget.
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
45
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
46 connect (this, SIGNAL (notice_settings_signal (const QSettings *)),
16470
7369b210dbd0 use pointer for terminal inside terminal_dock_widget
John W. Eaton <jwe@octave.org>
parents: 16461
diff changeset
47 terminal, SLOT (notice_settings (const QSettings *)));
14692
d6d250812c01 Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
48
16446
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
49 connect (this, SIGNAL (copyClipboard_signal (void)),
16470
7369b210dbd0 use pointer for terminal inside terminal_dock_widget
John W. Eaton <jwe@octave.org>
parents: 16461
diff changeset
50 terminal, SLOT (copyClipboard (void)));
16446
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
51
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
52 connect (this, SIGNAL (pasteClipboard_signal (void)),
16470
7369b210dbd0 use pointer for terminal inside terminal_dock_widget
John W. Eaton <jwe@octave.org>
parents: 16461
diff changeset
53 terminal, SLOT (pasteClipboard (void)));
16446
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
54 }
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
55
16576
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
56 bool
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
57 terminal_dock_widget::has_focus (void) const
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
58 {
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
59 QWidget *w = widget ();
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
60
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
61 return w->hasFocus ();
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
62 }
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
63
16446
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
64 void
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
65 terminal_dock_widget::notice_settings (const QSettings *settings)
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
66 {
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
67 emit notice_settings_signal (settings);
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
68 }
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
69
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
70 void
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
71 terminal_dock_widget::copyClipboard (void)
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
72 {
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
73 emit copyClipboard_signal ();
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
74 }
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
75
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
76 void
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
77 terminal_dock_widget::pasteClipboard (void)
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
78 {
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
79 emit pasteClipboard_signal ();
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
80 }
16461
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
81
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
82 void
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
83 terminal_dock_widget::focus (void)
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
84 {
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
85 octave_dock_widget::focus ();
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
86
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
87 QWidget *w = widget ();
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
88
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
89 w->setFocus ();
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
90 w->activateWindow ();
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
91 w->raise ();
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
92 }