annotate libgui/src/terminal-dock-widget.cc @ 25054:6652d3823428 stable

maint: Update copyright dates in all source files.
author John W. Eaton <jwe@octave.org>
date Fri, 30 Mar 2018 09:19:05 -0400
parents 9421e891294e
children 4adeabc1bbfe
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
25054
6652d3823428 maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 24791
diff changeset
3 Copyright (C) 2013-2018 John W. Eaton
6652d3823428 maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 24791
diff changeset
4 Copyright (C) 2011-2018 Jacob Dawid
15204
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
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24011
diff changeset
8 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
9 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24011
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
11 (at your option) any later version.
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
12
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
14 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
16 GNU General Public License for more details.
15204
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
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24011
diff changeset
20 <https://www.gnu.org/licenses/>.
15204
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
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
24 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
25 # include "config.h"
15286
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
24791
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
28 #include <QDesktopWidget>
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
29
16460
4d4e7c6f839d use consistent names for dock-widget files
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
30 #include "terminal-dock-widget.h"
24791
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
31 #include "resource-manager.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
32
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
33 namespace octave
14692
d6d250812c01 Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
34 {
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
35 terminal_dock_widget::terminal_dock_widget (QWidget *p)
24768
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
36 : octave_dock_widget (p), m_terminal (QTerminal::create (p))
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
37 {
24768
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
38 m_terminal->setObjectName ("OctaveTerminal");
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
39 m_terminal->setFocusPolicy (Qt::StrongFocus);
17920
5c3f22dd0bbb raise SIGINT in octave_interpreter instead of in QTerminal
John W. Eaton <jwe@octave.org>
parents: 17790
diff changeset
40
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
41 setObjectName ("TerminalDockWidget");
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
42 setWindowIcon (QIcon (":/actions/icons/logo.png"));
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
43 set_title (tr ("Command Window"));
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
44
24768
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
45 setWidget (m_terminal);
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
46 setFocusProxy (m_terminal);
23808
2b1b2a795ba6 update clickable urls in terminal also when visible terminal has no focus
Torsten <mttl@mailbox.org>
parents: 23220
diff changeset
47
24768
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
48 connect (m_terminal, SIGNAL (interrupt_signal (void)),
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
49 this, SLOT (terminal_interrupt (void)));
16446
4b3a4bf8569b improve encapsulation of command window object
John W. Eaton <jwe@octave.org>
parents: 16057
diff changeset
50
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
51 // Connect the visibility signal to the terminal for dis-/enabling timers
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
52 connect (this, SIGNAL (visibilityChanged (bool)),
24768
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
53 m_terminal, SLOT (handle_visibility_changed (bool)));
24791
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
54
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
55 // Chose a reasonable size at startup in order to avoid truncated
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
56 // startup messages
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
57 QSettings *settings = resource_manager::get_settings ();
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
58
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
59 QFont font = QFont ();
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
60 font.setStyleHint (QFont::TypeWriter);
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
61 font.setFamily
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
62 (settings->value ("terminal/fontName", "Courier New").toString ());
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
63 font.setPointSize (settings->value ("terminal/fontSize", 10).toInt ());
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
64
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
65 QFontMetrics metrics(font);
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
66
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
67 int win_x = metrics.maxWidth()*80;
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
68 int win_y = metrics.height()*25;
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
69
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
70 int max_x = QApplication::desktop ()->screenGeometry (this).width ();
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
71 int max_y = QApplication::desktop ()->screenGeometry (this).height ();
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
72
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
73 if (win_x > max_x)
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
74 win_x = max_x;
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
75 if (win_y > max_y)
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
76 win_y = max_y;
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
77
9421e891294e fix truncated startup message in terminal widget on windows (bug #53189)
Torsten <mttl@mailbox.org>
parents: 24768
diff changeset
78 setGeometry (0, 0, win_x, win_y);
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
79 }
24011
9107bae20480 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23808
diff changeset
80
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
81 terminal_dock_widget::~terminal_dock_widget (void)
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
82 {
24768
11cc3973381b use "m_" prefix for member variable in terminal dock widget class
John W. Eaton <jwe@octave.org>
parents: 24733
diff changeset
83 delete m_terminal;
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
84 }
16576
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
85
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
86 bool terminal_dock_widget::has_focus (void) const
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
87 {
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
88 QWidget *w = widget ();
16576
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16570
diff changeset
89
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
90 return w->hasFocus ();
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
91 }
16461
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
92
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
93 void terminal_dock_widget::focus (void)
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
94 {
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
95 octave_dock_widget::focus ();
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
96
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
97 QWidget *w = widget ();
16461
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
98
24733
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
99 w->setFocus ();
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
100 w->activateWindow ();
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
101 w->raise ();
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
102 }
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
103
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
104 void terminal_dock_widget::terminal_interrupt (void)
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
105 {
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
106 emit interrupt_signal ();
e15d53d2de1e move more GUI classse inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
107 }
16461
094bd3627ead move common functionality to octave_dock_widget base class
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
108 }