GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
terminal-dock-widget.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2011-2022 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if defined (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include <QDesktopWidget>
31
32// This header is only needed for the new terminal widget.
33#include "command-widget.h"
34
35// This header is only needed for the old terminal widget.
36#include "QTerminal.h"
37
38#include "gui-preferences-cs.h"
40
41#include "octave-qobject.h"
43
44namespace octave
45{
47 base_qobject& oct_qobj)
48 : octave_dock_widget ("TerminalDockWidget", p, oct_qobj),
49 m_experimental_terminal_widget (oct_qobj.experimental_terminal_widget ())
50 {
51 // FIXME: we could do this in a better way, but improving it doesn't
52 // matter much if we will eventually be removing the old terminal.
54 {
55 command_widget *widget = new command_widget (oct_qobj, this);
56
59
62
65
66 m_terminal = widget;
67 }
68 else
69 {
70 QTerminal *widget = QTerminal::create (oct_qobj, this);
71
74
75 // Connect the visibility signal to the terminal for
76 // dis-/enabling timers.
77 connect (this, &terminal_dock_widget::visibilityChanged,
79
80 m_terminal = widget;
81 }
82
83 m_terminal->setObjectName ("OctaveTerminal");
84 m_terminal->setFocusPolicy (Qt::StrongFocus);
85
86 setWindowIcon (QIcon (":/actions/icons/logo.png"));
87 set_title (tr ("Command Window"));
88
89 setWidget (m_terminal);
90 setFocusProxy (m_terminal);
91
92 // Chose a reasonable size at startup in order to avoid truncated
93 // startup messages
96
97 QFont font = QFont ();
98 font.setStyleHint (QFont::TypeWriter);
99 QString default_font = settings->value (global_mono_font).toString ();
100 font.setFamily
101 (settings->value (cs_font.key, default_font).toString ());
102 font.setPointSize
103 (settings->value (cs_font_size).toInt ());
104
105 QFontMetrics metrics(font);
106
107 int win_x = metrics.maxWidth()*80;
108 int win_y = metrics.height()*25;
109
110 int max_x = QApplication::desktop ()->screenGeometry (this).width ();
111 int max_y = QApplication::desktop ()->screenGeometry (this).height ();
112
113 if (win_x > max_x)
114 win_x = max_x;
115 if (win_y > max_y)
116 win_y = max_y;
117
118 setGeometry (0, 0, win_x, win_y);
119
120 if (! p)
121 make_window ();
122 }
123
125 {
126 QWidget *w = widget ();
127 return w->hasFocus ();
128 }
129
131 {
133 ? nullptr : dynamic_cast<QTerminal *> (m_terminal));
134 }
135
137 {
139 ? dynamic_cast<command_widget *> (m_terminal) : nullptr);
140 }
141
143 {
145 }
146
148 {
150 emit interpreter_output_signal (msg);
151 }
152
153 void terminal_dock_widget::update_prompt (const QString& prompt)
154 {
156 emit update_prompt_signal (prompt);
157 }
158
159}
virtual void handle_visibility_changed(bool)
Definition: QTerminal.h:145
void notice_settings(const gui_settings *settings)
Definition: QTerminal.cc:202
static QTerminal * create(octave::base_qobject &oct_qobj, QWidget *xparent)
Definition: QTerminal.cc:52
Base class for Octave interfaces that use Qt.
resource_manager & get_resource_manager(void)
void update_prompt(const QString &prompt)
void insert_interpreter_output(const QString &msg)
void notice_settings(const gui_settings *settings)
void set_title(const QString &)
void make_window(bool widget_was_dragged=false)
gui_settings * get_settings(void) const
void settings_changed(const gui_settings *settings)
command_widget * get_command_widget(void)
void interpreter_output_signal(const QString &)
void notice_settings(const gui_settings *settings)
void update_prompt_signal(const QString &)
void interpreter_output(const QString &)
void update_prompt(const QString &)
terminal_dock_widget(QWidget *parent, base_qobject &oct_qobj)
const gui_pref cs_font_size("terminal/fontSize", QVariant(10))
const gui_pref cs_font("terminal/fontName", QVariant())
const gui_pref global_mono_font("monospace_font", global_font_family)
std::complex< double > w(std::complex< double > z, double relerr=0)
const QString key