GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
main-window.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2011-2023 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 <utility>
31 
32 #include <QAction>
33 #include <QApplication>
34 #include <QClipboard>
35 #include <QDateTime>
36 #include <QDebug>
37 #include <QDesktopServices>
38 #include <QFileDialog>
39 #include <QIcon>
40 #include <QInputDialog>
41 #include <QKeySequence>
42 #include <QLabel>
43 #include <QMenu>
44 #include <QMenuBar>
45 #include <QMessageBox>
46 #include <QScreen>
47 #include <QStyle>
48 #include <QStyleFactory>
49 #include <QTextBrowser>
50 #include <QTextStream>
51 #include <QThread>
52 #include <QTimer>
53 #include <QToolBar>
54 #include <QWindow>
55 
56 // QTerminal includes
57 #include "QTerminal.h"
58 
59 #if defined (HAVE_QSCINTILLA)
60 # include "file-editor.h"
61 # include "command-widget.h"
62 #endif
63 #include "gui-preferences-cs.h"
64 #include "gui-preferences-dw.h"
65 #include "gui-preferences-ed.h"
66 #include "gui-preferences-global.h"
67 #include "gui-preferences-mw.h"
68 #include "gui-preferences-nr.h"
69 #include "gui-preferences-sc.h"
70 #include "gui-settings.h"
71 #include "gui-utils.h"
72 #include "interpreter-qobject.h"
73 #include "main-window.h"
74 #include "news-reader.h"
75 #include "octave-qobject.h"
76 #include "octave-qtutils.h"
77 #include "settings-dialog.h"
78 #include "shortcut-manager.h"
79 #include "welcome-wizard.h"
80 
81 #include "cmd-edit.h"
82 #include "oct-env.h"
83 #include "url-transfer.h"
84 
85 #include "builtin-defun-decls.h"
86 #include "defaults.h"
87 #include "interpreter.h"
88 #include "load-path.h"
89 #include "utils.h"
90 #include "syminfo.h"
91 #include "version.h"
92 
94 
96 : QMainWindow (), m_octave_qobj (oct_qobj),
97  m_status_bar (nullptr),
98  m_command_window (nullptr),
99  m_history_window (nullptr),
100  m_file_browser_window (nullptr),
101  m_editor_window (nullptr),
102  m_workspace_window (nullptr),
103  m_external_editor (new external_editor_interface (this, m_octave_qobj)),
104  m_active_editor (m_external_editor), m_settings_dlg (nullptr),
105  m_find_files_dlg (nullptr), m_set_path_dlg (nullptr),
106  m_clipboard (QApplication::clipboard ()),
107  m_prevent_readline_conflicts (true),
108  m_prevent_readline_conflicts_menu (false),
109  m_suppress_dbg_location (true),
110  m_closing (false), m_file_encoding (QString ())
111 {
112  resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
113 
114  if (rmgr.is_first_run ())
115  {
116  // Before wizard.
117  m_octave_qobj.config_translators ();
118 
119  welcome_wizard welcomeWizard (m_octave_qobj);
120 
121  if (welcomeWizard.exec () == QDialog::Rejected)
122  exit (1);
123 
124  // Install settings file.
125  rmgr.reload_settings ();
126  }
127  else
128  {
129  // Get settings file.
130  rmgr.reload_settings ();
131 
132  // After settings.
133  m_octave_qobj.config_translators ();
134  }
135 
136  setObjectName (gui_obj_name_main_window);
137 
138  rmgr.config_icon_theme ();
139 
140  rmgr.update_network_settings ();
141 
142  // We provide specific terminal capabilities, so ensure that
143  // TERM is always set appropriately.
144 
145 #if defined (OCTAVE_USE_WINDOWS_API)
146  sys::env::putenv ("TERM", "cygwin");
147 #else
148  sys::env::putenv ("TERM", "xterm");
149 #endif
150 
151  // FIXME: can we do this job when creating the shortcut manager?
152  // A quick look shows that it may require some coordination with the
153  // resource manager. Startup is complicated, but maybe we can make
154  // it simpler?
155  shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager ();
156  scmgr.init_data ();
157 
158  construct_central_widget ();
159 
160  m_status_bar = new QStatusBar (this);
161  m_profiler_status_indicator = new led_indicator ();
162  QLabel *text = new QLabel (tr ("Profiler"));
163  m_status_bar->addPermanentWidget (text);
164  m_status_bar->addPermanentWidget (m_profiler_status_indicator);
165 
166  adopt_dock_widgets ();
167 
168 #if defined (HAVE_QGUIAPPLICATION_SETDESKTOPFILENAME)
169  QGuiApplication::setDesktopFileName ("org.octave.Octave.desktop");
170 #endif
171 
172  QApplication *qapp = m_octave_qobj.qapplication ();
173 
174  m_default_style = qapp->style ()->objectName ();
175  m_default_palette = qapp->palette ();
176 
178 
179  bool connect_to_web = true;
180  QDateTime last_checked;
181  int serial = 0;
182  m_active_dock = nullptr;
183 
184  if (settings)
185  {
186  connect_to_web
187  = settings->value (nr_allow_connection).toBool ();
188 
189  last_checked
190  = settings->value (nr_last_time).toDateTime ();
191 
192  serial = settings->value (nr_last_news).toInt ();
193  m_default_encoding = settings->value (ed_default_enc).toString ();
194  }
195 
196  QDateTime current = QDateTime::currentDateTime ();
197  QDateTime one_day_ago = current.addDays (-1);
198 
199  if (connect_to_web
200  && (! last_checked.isValid () || one_day_ago > last_checked))
201  emit show_community_news_signal (serial);
202 
203  construct_octave_qt_link ();
204 
205  // We have to set up all our windows, before we finally launch
206  // octave.
207 
208  construct ();
209 
210  read_settings ();
211 
212  init_terminal_size ();
213 
214  emit init_window_menu ();
215 
216  focus_command_window ();
217 }
218 
220 
222 {
230 
232 }
233 
235 {
237 
239 
240  connect (this, &main_window::settings_changed,
242 
244  {
245  QTerminal *cmd_widget = m_command_window->get_qterminal ();
246 
247  // The following connections were previously made in
248  // QTerminal::construct, QWinTerminalImpl::QWinTerminalImpl, and
249  // QUnixTerminalImpl::QUnixTerminalImpl. Similar actions should
250  // probably be possible for the new command widget.
251 
252  connect (cmd_widget, &QTerminal::report_status_message,
254 
255  connect (cmd_widget, &QTerminal::edit_mfile_request,
256  this, &main_window::edit_mfile);
257 
258  connect (cmd_widget, &QTerminal::execute_command_in_terminal_signal,
260 
262  cmd_widget, &QTerminal::init_terminal_size);
263 
264  connect (this, &main_window::copyClipboard_signal,
265  cmd_widget, &QTerminal::copyClipboard);
266 
267  connect (this, &main_window::pasteClipboard_signal,
268  cmd_widget, &QTerminal::pasteClipboard);
269 
270  connect (this, &main_window::selectAll_signal,
271  cmd_widget, &QTerminal::selectAll);
272 
273  connect (cmd_widget, &QTerminal::request_edit_mfile_signal,
274  this, &main_window::edit_mfile);
275 
276  connect (cmd_widget, &QTerminal::request_open_file_signal,
278 
279  connect (cmd_widget, &QTerminal::set_screen_size_signal,
281 
282  connect (cmd_widget, &QTerminal::clear_command_window_request,
284  }
285  else
286  {
287  connect (this, &main_window::execute_command_signal,
289  }
290 }
291 
293 {
295 
297 }
298 
300 {
302 
304 
307  connect (m_file_browser_window,
310 
312  this, &main_window::modify_path);
313 
316 
319 
322 
324  this, &main_window::find_files);
325 }
326 
328 {
330 
332 
335 
338 }
339 
341 {
343 
345 
348 }
349 
351 {
353 
354  qt_interpreter_events *qt_link = interp_qobj->qt_link ();
355 
356 #if defined (HAVE_QSCINTILLA)
357  file_editor *editor = new file_editor (this, m_octave_qobj);
358 
360 
361  // The editor is currently different from other dock widgets. Until
362  // those differences are resolved, make interpreter_event
363  // connections here instead of in base_qobject::editor_widget.
365 
366  connect (editor, &file_editor::request_settings_dialog,
368 
369  connect (editor, &file_editor::request_dbcont_signal,
371 
372  connect (this, &main_window::update_gui_lexer_signal,
374 
377 
380 
381  connect (editor, &file_editor::run_file_signal,
383 
384  connect (editor, &file_editor::edit_mfile_request,
386 
387  connect (editor, &file_editor::debug_quit_signal,
388  this, &main_window::debug_quit);
389 
390  connect (this, &main_window::editor_focus_changed,
392 
393  connect (this, &main_window::step_into_file_signal,
395 
396  connect (editor, &file_editor::editor_tabs_changed_signal,
398 
399  connect (editor, &file_editor::request_open_file_external,
401 
404 
407 
410 
413 
414  // Signals for removing/renaming files/dirs in the file browser
417 
420 
421  // Signals for removing/renaming files/dirs in the terminal window
424 
425  // Signals for entering/exiting debug mode
428 
431 
434 
435  m_editor_window = editor;
436 
437  m_editor_menubar = m_editor_window->menubar ();
438 
440 
441  m_editor_window->enable_menu_shortcuts (false);
442 #else
443  m_editor_window = nullptr;
444 
445  m_editor_menubar = nullptr;
446 
448 #endif
449 
450  connect (qt_link, SIGNAL (edit_file_signal (const QString&)),
451  m_active_editor, SLOT (handle_edit_file_request (const QString&)));
452 }
453 
455 {
457 
459 }
460 
462 {
463  connect (this, &main_window::init_window_menu,
465 
466  connect (this, &main_window::settings_changed,
468 
469  connect (this, &main_window::active_dock_changed,
471 
472  // FIXME: shouldn't this action should be associated with closing
473  // the main window, not with exiting the application? At one time,
474  // those two actions happened together, but now it is possible to
475  // close the main window without exiting the application.
476  connect (qApp, &QApplication::aboutToQuit,
478 
479  // The following is required when the exp. terminal widget is used
480  // and the main window is closed (no exit via interpreter)
481  connect (this, &main_window::close_gui_signal,
483 }
484 
486 {
487  return m_command_window->has_focus ();
488 }
489 
491 {
492  m_command_window->activate ();
493 }
494 
495 void main_window::focus_window (const QString& win_name)
496 {
497  if (win_name == "command")
498  m_command_window->activate ();
499  else if (win_name == "history")
500  m_history_window->activate ();
501  else if (win_name == "workspace")
502  m_workspace_window->activate ();
503  else if (win_name == "filebrowser")
504  m_file_browser_window->activate ();
505 }
506 
508 {
509  bool closenow = true;
510 
513 
514  if (settings->value (global_prompt_to_exit.key,
515  global_prompt_to_exit.def).toBool ())
516  {
517  int ans = QMessageBox::question (this, tr ("Octave"),
518  tr ("Are you sure you want to exit Octave?"),
519  (QMessageBox::Ok
520  | QMessageBox::Cancel),
521  QMessageBox::Ok);
522 
523  if (ans != QMessageBox::Ok)
524  closenow = false;
525  }
526 
527 #if defined (HAVE_QSCINTILLA)
528  if (closenow)
529  closenow = m_editor_window->check_closing ();
530 #endif
531 
532  return closenow;
533 }
534 
535 // catch focus changes and determine the active dock widget
537 {
538  // If there is no new widget or the new widget is a menu bar
539  // (when pressing <alt>), we can return immediately and reset the
540  // focus to the previous widget
541  if (! new_widget
542  || (new_widget == menuBar ())
543  || (new_widget == m_editor_menubar))
544  {
545  if (m_active_dock)
546  m_active_dock->setFocus ();
547 
548  return;
549  }
550 
551  octave_dock_widget *dock = nullptr;
552  QWidget *w_new = new_widget; // get a copy of new focus widget
553  QWidget *start = w_new; // Save it as start of our search
554  int count = 0; // fallback to prevent endless loop
555 
557 
558  while (w_new && w_new != m_main_tool_bar && count < 100)
559  {
560  // Go through all dock widgets and check whether the current widget
561  // with focus is a child of one of them.
562  for (auto w : w_list)
563  {
564  if (w->isAncestorOf (w_new))
565  dock = w;
566  }
567 
568  if (dock)
569  break;
570 
571  // If not yet found (in case w_new is not a child of its dock widget),
572  // test next widget in the focus chain
573  w_new = qobject_cast<QWidget *> (w_new->previousInFocusChain ());
574 
575  // Measures preventing an endless loop
576  if (w_new == start)
577  break; // We have arrived where we began ==> exit loop
578  count++; // Limited number of trials
579  }
580 
581  // editor and terminal needs extra handling
582  octave_dock_widget *edit_dock_widget
583  = static_cast<octave_dock_widget *> (m_editor_window);
584  octave_dock_widget *cmd_dock_widget
585  = static_cast<octave_dock_widget *> (m_command_window);
586 
587  // if new dock has focus, emit signal and store active focus
588  // except editor changes to a dialog (dock=0)
589  if ((dock || m_active_dock != edit_dock_widget) && (dock != m_active_dock))
590  {
591  // signal to all dock widgets for updating the style
592  emit active_dock_changed (m_active_dock, dock);
593 
594  if (dock)
595  {
596  QList<QDockWidget *> tabbed = tabifiedDockWidgets (dock);
597  if (tabbed.contains (m_active_dock))
599  }
600 
601  // Check whether editor loses or gains focus
602  int editor = 0;
603  if (edit_dock_widget == dock)
604  {
605  emit editor_focus_changed (true);
606  editor = 1;
607  }
608  else if (edit_dock_widget == m_active_dock)
609  {
610  emit editor_focus_changed (false);
611  editor = -1;
612  }
613 
614  // Check whether terminal loses or gains focus
615  int cmd_involved = 0;
616  if (cmd_dock_widget == dock)
617  cmd_involved = 1;
618  else if (cmd_dock_widget == m_active_dock)
619  cmd_involved = -1;
620 
621  // If we have to take care of Alt+? accelerators of the main
622  // window, take result of test for terminal widget above
623  int command = 0;
625  command = cmd_involved;
626 
627  // If editor or command gets/looses focus, disable/enable
628  // main menu accelerators (Alt + ?)
629  if (editor || command)
630  {
631  int sum = editor + command;
632  if (sum > 0)
633  disable_menu_shortcuts (true);
634  else if (sum < 0)
635  disable_menu_shortcuts (false);
636  }
637 
638  if (m_active_dock)
640  m_active_dock = dock;
641 
642  // En-/disable global shortcuts (preventing conflicts with
643  // readline. Do it here because it relies on m_active_dock
644  if (cmd_involved)
646  }
647 }
648 
650 {
653 
654  if (settings)
655  emit settings_changed (settings);
656 }
657 
658 void main_window::report_status_message (const QString& statusMessage)
659 {
660  m_status_bar->showMessage (statusMessage, 1000);
661 }
662 
664 {
665  // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved.
666  int opts = 0; // No options by default.
669  if (! settings->value (global_use_native_dialogs).toBool ())
670  opts = QFileDialog::DontUseNativeDialog;
671 
672  QString file
673  = QFileDialog::getSaveFileName (this, tr ("Save Workspace As"), ".",
674  nullptr, nullptr, QFileDialog::Option (opts));
675 
676  if (! file.isEmpty ())
677  {
678  emit interpreter_event
679  ([=] (interpreter& interp)
680  {
681  // INTERPRETER THREAD
682 
683  Fsave (interp, ovl (file.toStdString ()));
684  });
685  }
686 }
687 
688 void main_window::handle_load_workspace_request (const QString& file_arg)
689 {
690  // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved.
691  int opts = 0; // No options by default.
694  if (! settings->value (global_use_native_dialogs).toBool ())
695  opts = QFileDialog::DontUseNativeDialog;
696 
697  QString file = file_arg;
698 
699  if (file.isEmpty ())
700  file = QFileDialog::getOpenFileName (this, tr ("Load Workspace"), ".",
701  nullptr, nullptr, QFileDialog::Option (opts));
702 
703  if (! file.isEmpty ())
704  {
705  emit interpreter_event
706  ([=] (interpreter& interp)
707  {
708  // INTERPRETER THREAD
709 
710  Fload (interp, ovl (file.toStdString ()));
711 
712  tree_evaluator& tw = interp.get_evaluator ();
713 
714  event_manager& xevmgr = interp.get_event_manager ();
715 
716  xevmgr.set_workspace (true, tw.get_symbol_info ());
717  });
718  }
719 }
720 
721 void main_window::handle_open_any_request (const QString& file_arg)
722 {
723  if (! file_arg.isEmpty ())
724  {
725  std::string file = file_arg.toStdString ();
726 
727  emit interpreter_event
728  ([=] (interpreter& interp)
729  {
730  // INTERPRETER THREAD
731 
732  interp.feval ("open", ovl (file));
733 
734  // Update the workspace since open.m may have loaded new
735  // variables.
736  tree_evaluator& tw = interp.get_evaluator ();
737 
738  event_manager& xevmgr = interp.get_event_manager ();
739 
740  xevmgr.set_workspace (true, tw.get_symbol_info ());
741  });
742  }
743 }
744 
746 {
747  emit interpreter_event
748  ([] (interpreter& interp)
749  {
750  // INTERPRETER THREAD
751 
752  Fclear (interp);
753  });
754 }
755 
757 {
758  emit interpreter_event
759  ([] (void)
760  {
761  // INTERPRETER THREAD
762 
765  });
766 }
767 
769 {
770  emit interpreter_event
771  ([] (interpreter& interp)
772  {
773  // INTERPRETER THREAD
774 
775  history_system& history_sys = interp.get_history_system ();
776 
777  history_sys.do_history (ovl ("-c"));
778  });
779 }
780 
782 {
784  {
785  emit interpreter_event
786  ([] (void)
787  {
788  // INTERPRETER THREAD
789 
792  });
793  }
794  else
795  emit undo_signal ();
796 }
797 
798 void main_window::modify_path (const QStringList& dir_list,
799  bool rm, bool subdirs)
800 {
801  emit interpreter_event
802  ([=] (interpreter& interp)
803  {
804  // INTERPRETER THREAD
805 
806  octave_value_list paths;
807 
808  // Loop over all directories in order to get all subdirs
809  for (octave_idx_type i = 0; i < dir_list.length (); i++)
810  {
811  std::string dir = dir_list.at(i).toStdString ();
812 
813  if (subdirs)
814  paths.append (Fgenpath (ovl (dir)));
815  else
816  paths.append (dir);
817  }
818 
819  if (rm)
820  Frmpath (interp, paths);
821  else
822  Faddpath (interp, paths);
823  });
824 }
825 
826 void main_window::edit_mfile (const QString& name, int line)
827 {
828  handle_edit_mfile_request (name, QString (), QString (), line);
829 }
830 
831 void main_window::file_remove_proxy (const QString& o, const QString& n)
832 {
834 
835  qt_interpreter_events *qt_link = interp_qobj->qt_link ();
836 
837  // Wait for worker to suspend
838  qt_link->lock ();
839  // Close the file if opened
840 #if defined (HAVE_QSCINTILLA)
841  m_editor_window->handle_file_remove (o, n);
842 #else
843  octave_unused_parameter (o);
844  octave_unused_parameter (n);
845 #endif
846 
847  // We are done: Unlock and wake the worker thread
848  qt_link->unlock ();
849  qt_link->wake_all ();
850 }
851 
853 {
854  QDesktopServices::openUrl
855  (QUrl ("https://octave.org/doc/interpreter/index.html"));
856 }
857 
859 {
860  QDesktopServices::openUrl (QUrl ("https://octave.org/bugs.html"));
861 }
862 
864 {
865  QDesktopServices::openUrl (QUrl ("https://packages.octave.org/index.html"));
866 }
867 
869 {
870  QDesktopServices::openUrl (QUrl ("https://octave.org/contribute.html"));
871 }
872 
874 {
875  QDesktopServices::openUrl (QUrl ("https://octave.org/donate.html"));
876 }
877 
878 void main_window::process_settings_dialog_request (const QString& desired_tab)
879 {
880  if (m_settings_dlg) // m_settings_dlg is a guarded pointer!
881  {
882  // here the dialog is still open and called once again
883  if (! desired_tab.isEmpty ())
884  m_settings_dlg->show_tab (desired_tab);
885  return;
886  }
887 
888  m_settings_dlg = new settings_dialog (this, m_octave_qobj, desired_tab);
889 
892 
893  m_settings_dlg->setModal (false);
894  m_settings_dlg->setAttribute (Qt::WA_DeleteOnClose);
895  m_settings_dlg->show ();
896 }
897 
899 {
900  std::string message
902 
903  QMessageBox::about (this, tr ("About Octave"),
905 }
906 
908  bool update_by_worker)
909 {
910  if (! settings)
911  return;
912 
913  // Get desired style from preferences or take the default one if
914  // the desired one is not found
915  QString preferred_style = settings->value (global_style).toString ();
916 
917  if (preferred_style == global_style.def.toString ())
918  preferred_style = m_default_style;
919 
921 
922  if (preferred_style == global_extra_styles.at (EXTRA_STYLE_FUSION_DARK))
923  {
924  QStyle *new_style = QStyleFactory::create (QStringLiteral("Fusion"));
925  if (new_style)
926  qapp->setStyle (new_style);
927  qapp->setPalette (getFusionDarkPalette());
928  qapp->setStyleSheet ("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
929  }
930  else
931  {
932  QStyle *new_style = QStyleFactory::create (preferred_style);
933  if (new_style)
934  {
935  qapp->setPalette (m_default_palette);
936  qapp->setStyle (new_style);
937  }
938  }
939 
940  // the widget's icons (when floating)
941  QString icon_set = settings->value (dw_icon_set).toString ();
942 
943  QString icon;
944  for (auto *widget : dock_widget_list ())
945  {
946  QString name = widget->objectName ();
947  if (! name.isEmpty ())
948  {
949  // if child has a name
950  icon = dw_icon_set_names[icon_set];
951  if (icon_set != "NONE")
952  icon += name + ".png"; // add widget name and ext.
953  widget->setWindowIcon (QIcon (icon));
954  }
955  }
956 
957  int size_idx = settings->value (global_icon_size).toInt ();
958  size_idx = (size_idx > 0) - (size_idx < 0) + 1; // Make valid index from 0 to 2
959 
960  QStyle *st = style ();
961  int icon_size = st->pixelMetric (global_icon_sizes[size_idx]);
962  m_main_tool_bar->setIconSize (QSize (icon_size, icon_size));
963 
964  if (settings->value (global_status_bar).toBool ())
965  m_status_bar->show ();
966  else
967  m_status_bar->hide ();
968 
970  = settings->value (sc_prevent_rl_conflicts).toBool ();
971 
973  = settings->value (sc_prevent_rl_conflicts_menu).toBool ();
974 
976  = ! settings->value (cs_dbg_location).toBool ();
977 
979  rmgr.update_network_settings ();
980 
981  emit active_dock_changed (nullptr, m_active_dock); // update dock widget styles
982 
984 
985  bool do_disable_main_menu_shortcuts
989 
990  disable_menu_shortcuts (do_disable_main_menu_shortcuts);
991 
992  // Check whether some octave internal preferences have to be updated
993  QString new_default_encoding
994  = settings->value (ed_default_enc).toString ();
995  // Do not update internal pref only if a) this update was not initiated
996  // by the worker and b) the pref has really changes
997  if (! update_by_worker && (new_default_encoding != m_default_encoding))
998  update_default_encoding (new_default_encoding);
999 
1000  // Set cursor blinking depending on the settings
1001  // Cursor blinking: consider old terminal related setting if not yet set
1002  // TODO: This pref. can be deprecated / removed if Qt adds support for
1003  // getting the cursor blink preferences from all OS environments
1004  bool cursor_blinking;
1005 
1006  if (settings->contains (global_cursor_blinking.key))
1007  cursor_blinking = settings->value (global_cursor_blinking).toBool ();
1008  else
1009  cursor_blinking = settings->value (cs_cursor_blinking).toBool ();
1010 
1011  if (cursor_blinking)
1012  QApplication::setCursorFlashTime (1000); // 1000 ms flash time
1013  else
1014  QApplication::setCursorFlashTime (0); // no flashing
1015 
1016 }
1017 
1019 {
1020  QPalette darkPalette;
1021  darkPalette.setColor(QPalette::Window, QColor(53, 53, 53));
1022  darkPalette.setColor(QPalette::WindowText, Qt::white);
1023  darkPalette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(127, 127, 127));
1024  darkPalette.setColor(QPalette::Base, QColor(42, 42, 42));
1025  darkPalette.setColor(QPalette::AlternateBase, QColor(66, 66, 66));
1026  darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
1027  darkPalette.setColor(QPalette::ToolTipText, Qt::white);
1028  darkPalette.setColor(QPalette::Text, Qt::white);
1029  darkPalette.setColor(QPalette::Disabled, QPalette::Text, QColor(127, 127, 127));
1030  darkPalette.setColor(QPalette::Dark, QColor(35, 35, 35));
1031  darkPalette.setColor(QPalette::Shadow, QColor(20, 20, 20));
1032  darkPalette.setColor(QPalette::Button, QColor(53, 53, 53));
1033  darkPalette.setColor(QPalette::ButtonText, Qt::white);
1034  darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(127, 127, 127));
1035  darkPalette.setColor(QPalette::BrightText, Qt::red);
1036  darkPalette.setColor(QPalette::Link, QColor(42, 130, 218));
1037  darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218));
1038  darkPalette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(80, 80, 80));
1039  darkPalette.setColor(QPalette::HighlightedText, Qt::white);
1040  darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(127, 127, 127));
1041 
1042  return darkPalette;
1043 }
1044 
1046 {
1047  // Find files dialog is constructed dynamically, not at time of main_window
1048  // construction. Connecting it to qApp aboutToQuit signal would have
1049  // caused it to run after gui_settings is deleted.
1050  if (m_find_files_dlg)
1052 
1053  if (m_set_path_dlg)
1054  m_set_path_dlg->save_settings ();
1055 
1056  write_settings ();
1057 
1058  // No more active dock, otherwise, focus_changed would try to set
1059  // the focus to a dock widget that might not exist anymore
1060  m_active_dock = nullptr;
1061 }
1062 
1064 {
1066 }
1067 
1068 void main_window::update_octave_directory (const QString& dir)
1069 {
1070  // Remove existing entry, if any, then add new directory at top and
1071  // mark it as the current directory. Finally, update the file list
1072  // widget.
1073 
1074  int index = m_current_directory_combo_box->findText (dir);
1075 
1076  if (index >= 0)
1077  m_current_directory_combo_box->removeItem (index);
1078 
1079  m_current_directory_combo_box->insertItem (0, dir);
1080  m_current_directory_combo_box->setCurrentIndex (0);
1081 }
1082 
1084 {
1085  // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved.
1086  int opts = QFileDialog::ShowDirsOnly;
1088  gui_settings *settings = rmgr.get_settings ();
1089  if (! settings->value (global_use_native_dialogs).toBool ())
1090  opts = QFileDialog::DontUseNativeDialog;
1091 
1092  QString dir
1093  = QFileDialog::getExistingDirectory (this, tr ("Browse directories"), nullptr,
1094  QFileDialog::Option (opts));
1095 
1097 
1098  // FIXME: on Windows systems, the command window freezes after the
1099  // previous actions. Forcing the focus appears to unstick it.
1100 
1102 }
1103 
1105 {
1106  // Change to dir if it is an existing directory.
1107 
1108  QString xdir = (dir.isEmpty () ? "." : dir);
1109 
1110  QFileInfo fileInfo (xdir);
1111 
1112  if (fileInfo.exists () && fileInfo.isDir ())
1113  {
1114  emit interpreter_event
1115  ([=] (interpreter& interp)
1116  {
1117  // INTERPRETER THREAD
1118 
1119  interp.chdir (xdir.toStdString ());
1120  });
1121  }
1122 }
1123 
1125 {
1127 }
1128 
1129 // Slot that is called if return is pressed in the line edit of the
1130 // combobox to change to a new directory or a directory that is already
1131 // in the drop down list.
1132 
1134 {
1135  // Get new directory name, and change to it if it is new. Otherwise,
1136  // the combo box will trigger the "activated" signal to change to the
1137  // directory.
1138 
1139  QString dir = m_current_directory_combo_box->currentText ();
1140 
1141  int index = m_current_directory_combo_box->findText (dir);
1142 
1143  if (index < 0)
1145 }
1146 
1147 void main_window::execute_command_in_terminal (const QString& command)
1148 {
1150  {
1151  emit execute_command_signal (command);
1152  }
1153  else
1154  {
1155  emit interpreter_event
1156  ([=] (void)
1157  {
1158  // INTERPRETER THREAD
1159 
1160  std::string pending_input = command_editor::get_current_line ();
1161 
1162  command_editor::set_initial_input (pending_input);
1163  command_editor::replace_line (command.toStdString ());
1167  });
1168  }
1169 
1171 }
1172 
1173 void main_window::run_file_in_terminal (const QFileInfo& info)
1174 {
1175  emit interpreter_event
1176  ([=] (interpreter& interp)
1177  {
1178  // INTERPRETER THREAD
1179 
1180  QString function_name = info.fileName ();
1181  function_name.chop (info.suffix ().length () + 1);
1182  std::string file_path = info.absoluteFilePath ().toStdString ();
1183 
1184  std::string pending_input = command_editor::get_current_line ();
1185 
1186  if (valid_identifier (function_name.toStdString ()))
1187  {
1188  // Valid identifier: call as function with possibility to
1189  // debug.
1190 
1191  load_path& lp = interp.get_load_path ();
1192 
1193  std::string path = info.absolutePath ().toStdString ();
1194 
1195  if (lp.contains_file_in_dir (file_path, path))
1196  command_editor::replace_line (function_name.toStdString ());
1197  }
1198  else
1199  {
1200  // No valid identifier: use equivalent of Fsource (), no
1201  // debug possible.
1202 
1203  interp.source_file (file_path);
1204 
1205  command_editor::replace_line ("");
1206  }
1207 
1208  command_editor::set_initial_input (pending_input);
1212  });
1213 
1215 }
1216 
1218 {
1219  emit interpreter_event
1220  ([] (interpreter& interp)
1221  {
1222  // INTERPRETER THREAD
1223 
1224  Fbuiltin (interp, ovl ("figure"));
1225  Fdrawnow (interp);
1226  });
1227 }
1228 
1230 {
1231  setWindowTitle ("Octave (Debugging)");
1232 
1233  m_debug_continue->setEnabled (true);
1234  m_debug_step_into->setEnabled (true);
1235  m_debug_step_over->setEnabled (true);
1236  m_debug_step_out->setEnabled (true);
1237  m_debug_quit->setEnabled (true);
1238 }
1239 
1241 {
1242  setWindowTitle ("Octave");
1243 
1244  m_debug_continue->setEnabled (false);
1245  m_debug_step_into->setEnabled (false);
1247  m_debug_step_out->setEnabled (false);
1248  m_debug_quit->setEnabled (false);
1249 }
1250 
1252 {
1253  emit interpreter_event
1254  ([=] (interpreter& interp)
1255  {
1256  // INTERPRETER THREAD
1257 
1259  Fdbcont (interp);
1260 
1262  });
1263 }
1264 
1266 {
1267  emit interpreter_event
1268  ([=] (interpreter& interp)
1269  {
1270  // INTERPRETER THREAD
1271 
1273  Fdbstep (interp, ovl ("in"));
1274 
1276  });
1277 }
1278 
1280 {
1281  if (m_debug_quit->isEnabled ())
1282  {
1283  // We are in debug mode, just call dbstep.
1284 
1285  emit interpreter_event
1286  ([=] (interpreter& interp)
1287  {
1288  // INTERPRETER THREAD
1289 
1292  Fdbstep (interp);
1293 
1295  });
1296  }
1297  else
1298  {
1299  // Not in debug mode: "step into" the current editor file
1300  emit step_into_file_signal ();
1301  }
1302 }
1303 
1305 {
1306  emit interpreter_event
1307  ([=] (interpreter& interp)
1308  {
1309  // INTERPRETER THREAD
1310 
1312  Fdbstep (interp, ovl ("out"));
1313 
1315  });
1316 }
1317 
1319 {
1320  emit interpreter_event
1321  ([] (interpreter& interp)
1322  {
1323  // INTERPRETER THREAD
1324 
1325  Fdbquit (interp);
1326 
1328  });
1329 }
1330 
1331 //
1332 // Functions related to file editing
1333 //
1334 // These are moved from editor to here for also using them when octave
1335 // is built without qscintilla
1336 //
1338 {
1339  // Open file isn't a file_editor_tab or editor function since the file
1340  // might be opened in an external editor. Hence, functionality is here.
1341 
1343  gui_settings *settings = rmgr.get_settings ();
1344  bool is_internal = m_editor_window
1345  && ! settings->value (global_use_custom_editor.key,
1346  global_use_custom_editor.def).toBool ();
1347 
1348  // Create a NonModal message.
1349  QWidget *p = this;
1350  if (is_internal)
1351  p = m_editor_window;
1352  QFileDialog *fileDialog = new QFileDialog (p);
1353  fileDialog->setNameFilter (tr ("Octave Files (*.m);;All Files (*)"));
1354 
1355  fileDialog->setAcceptMode (QFileDialog::AcceptOpen);
1356  fileDialog->setViewMode (QFileDialog::Detail);
1357  fileDialog->setFileMode (QFileDialog::ExistingFiles);
1358  fileDialog->setDirectory (m_current_directory_combo_box->itemText (0));
1359 
1360  // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved.
1361  if (! settings->value (global_use_native_dialogs).toBool ())
1362  fileDialog->setOption(QFileDialog::DontUseNativeDialog);
1363 
1364  connect (fileDialog, &QFileDialog::filesSelected,
1366 
1367  fileDialog->setWindowModality (Qt::NonModal);
1368  fileDialog->setAttribute (Qt::WA_DeleteOnClose);
1369  fileDialog->show ();
1370 }
1371 
1372 // Create a new script
1373 void main_window::request_new_script (const QString& commands)
1374 {
1375  emit new_file_signal (commands);
1376 }
1377 
1378 // Create a new function and open it
1380 {
1381  bool ok;
1382  // Get the name of the new function: Parent of the input dialog is the
1383  // editor window or the main window. The latter is chosen, if a custom
1384  // editor is used or qscintilla is not available
1385  QWidget *p = m_editor_window;
1387  gui_settings *settings = rmgr.get_settings ();
1388  if (! p || settings->value (global_use_custom_editor.key,
1389  global_use_custom_editor.def).toBool ())
1390  p = this;
1391  QString new_name = QInputDialog::getText (p, tr ("New Function"),
1392  tr ("New function name:\n"), QLineEdit::Normal, "", &ok);
1393 
1394  if (ok && new_name.length () > 0)
1395  {
1396  // append suffix if it does not already exist
1397  if (new_name.rightRef (2) != ".m")
1398  new_name.append (".m");
1399  // check whether new files are created without prompt
1400  if (! settings->value (ed_create_new_file).toBool ())
1401  {
1402  // no, so enable this settings and wait for end of new file loading
1403  settings->setValue (ed_create_new_file.key, true);
1404  connect (m_editor_window, SIGNAL (file_loaded_signal (void)),
1405  this, SLOT (restore_create_file_setting (void)));
1406  }
1407  // start the edit command
1408  execute_command_in_terminal ("edit " + new_name);
1409  }
1410 }
1411 
1412 void main_window::handle_edit_mfile_request (const QString& fname,
1413  const QString& ffile,
1414  const QString& curr_dir,
1415  int line)
1416 {
1417  // The interpreter_event callback function below emits a signal.
1418  // Because we don't control when that happens, use a guarded pointer
1419  // so that the callback can abort if this object is no longer valid.
1420 
1421  QPointer<main_window> this_mw (this);
1422 
1423  emit interpreter_event
1424  ([=] (interpreter& interp)
1425  {
1426  // INTERPRETER THREAD
1427 
1428  // We can skip the entire callback function because it does not
1429  // make any changes to the interpreter state.
1430 
1431  if (this_mw.isNull ())
1432  return;
1433 
1434  // Split possible subfunctions
1435  QStringList fcn_list = fname.split ('>');
1436  QString fcn_name = fcn_list.at (0) + ".m";
1437 
1438  // FIXME: could use symbol_exist directly, but we may also want
1439  // to fix that to be a member function in the interpreter
1440  // class?
1441 
1442  // Is it a regular function within the search path? (Call Fexist)
1443  octave_value_list fct = Fexist (interp, ovl (fname.toStdString ()),0);
1444  int type = fct (0).int_value ();
1445 
1446  QString message = QString ();
1447  QString filename = QString ();
1448 
1449  switch (type)
1450  {
1451  case 3:
1452  case 5:
1453  case 103:
1454  message = tr ("%1 is a built-in, compiled or inline\n"
1455  "function and can not be edited.");
1456  break;
1457 
1458  case 2:
1459  // FIXME: could use a load_path function directly.
1460  octave_value_list file_path
1461  = Ffile_in_loadpath (interp, ovl (fcn_name.toStdString ()), 0);
1462  if (file_path.length () > 0)
1463  filename = QString::fromStdString (file_path (0).string_value ());
1464  break;
1465  }
1466 
1467  if (filename.isEmpty () && message.isEmpty ())
1468  {
1469  // No error so far, but function still not known
1470  // -> try directory of edited file
1471  // get directory
1472  QDir dir;
1473  if (ffile.isEmpty ())
1474  {
1475  if (curr_dir.isEmpty ())
1476  dir = QDir (m_current_directory_combo_box->itemText (0));
1477  else
1478  dir = QDir (curr_dir);
1479  }
1480  else
1481  dir = QDir (QFileInfo (ffile).canonicalPath ());
1482 
1483  QFileInfo file = QFileInfo (dir, fcn_name);
1484  if (file.exists ())
1485  filename = file.canonicalFilePath (); // local file exists
1486  else
1487  {
1488  // local file does not exist -> try private directory
1489  file = QFileInfo (ffile);
1490  file = QFileInfo (QDir (file.canonicalPath () + "/private"),
1491  fcn_name);
1492  if (file.exists ())
1493  filename = file.canonicalFilePath (); // private function exists
1494  else
1495  message = tr ("Can not find function %1"); // no file found
1496  }
1497  }
1498 
1499  if (! message.isEmpty ())
1500  {
1501  emit warning_function_not_found_signal (message.arg (fname));
1502  return;
1503  }
1504 
1505  if (! filename.endsWith (".m"))
1506  filename.append (".m");
1507 
1508  // default encoding
1509  emit open_file_signal (filename, QString (), line);
1510  });
1511 }
1512 
1514 {
1515  QMessageBox *msgBox = new QMessageBox (QMessageBox::Critical,
1516  tr ("Octave Editor"),
1517  message, QMessageBox::Ok, this);
1518  msgBox->setWindowModality (Qt::NonModal);
1519  msgBox->setAttribute (Qt::WA_DeleteOnClose);
1520  msgBox->show ();
1521 }
1522 
1524  int line)
1525 {
1526  bool cmd_focus = command_window_has_focus ();
1527 
1528  emit insert_debugger_pointer_signal (file, line);
1529 
1530  if (cmd_focus)
1532 }
1533 
1535  int line)
1536 {
1537  bool cmd_focus = command_window_has_focus ();
1538 
1539  emit delete_debugger_pointer_signal (file, line);
1540 
1541  if (cmd_focus)
1543 }
1544 
1546  const QString& file,
1547  int line,
1548  const QString& cond)
1549 {
1550  bool cmd_focus = command_window_has_focus ();
1551 
1552  emit update_breakpoint_marker_signal (insert, file, line, cond);
1553 
1554  if (cmd_focus)
1556 }
1557 
1559 {
1561  gui_settings *settings = rmgr.get_settings ();
1562 
1563  if (! settings)
1564  {
1565  qDebug ("Error: gui_settings pointer from resource manager is NULL.");
1566  return;
1567  }
1568 
1570 
1571  // restore the list of the last directories
1572  QStringList curr_dirs = settings->value (mw_dir_list).toStringList ();
1573  for (int i=0; i < curr_dirs.size (); i++)
1574  {
1575  m_current_directory_combo_box->addItem (curr_dirs.at (i));
1576  }
1577  emit settings_changed (settings);
1578 }
1579 
1581 {
1582  emit init_terminal_size_signal ();
1583 }
1584 
1586 {
1587  // For resetting from some inconsistent state, first reset layout
1588  // without saving or showing it
1589  do_reset_windows (true, false);
1590 
1591  // Restore main window state and geometry from settings file or, in case
1592  // of an error (no pref values yet), from the default layout.
1593  if (! restoreGeometry (settings->value (mw_geometry).toByteArray ()))
1594  {
1595  do_reset_windows (true);
1596  return;
1597  }
1598 
1599  if (isMaximized())
1600  {
1601  // If the window state is restored to maximized layout, the
1602  // horizontal layout is not preserved. This cann be avoided by
1603  // setting the geometry to the max. available geometry. However, on
1604  // X11, the available geometry (excluding task bar etc.) is equal to
1605  // the total geometry leading to a full screen mode without window
1606  // decorations. This in turn can be avoided by explicitly adding
1607  // a title bar in the window flags.
1608 
1609  // Get available geometry for current screen and set this
1610  // window's geometry to it.
1611  QScreen *s = windowHandle ()->screen ();
1612  QRect av_geom = s->availableGeometry ();
1613  setGeometry (av_geom); // Set (correct) available geometry
1614 
1615  // Force full title bar
1616  setWindowFlags(Qt::WindowTitleHint
1617  | Qt::WindowMinMaxButtonsHint
1618  | Qt::WindowSystemMenuHint
1619  | Qt::WindowCloseButtonHint);
1620  }
1621 
1622  if (! restoreState (settings->value (mw_state).toByteArray ()))
1623  {
1624  do_reset_windows (true);
1625  return;
1626  }
1627 
1628  // Restore the geometry of all dock-widgets
1629 
1630  for (auto *widget : dock_widget_list ())
1631  {
1632  // Leave any widgets that existed before main_window was created
1633  // as they were.
1634 
1635  if (widget->adopted ())
1636  continue;
1637 
1638  QString name = widget->objectName ();
1639 
1640  if (! name.isEmpty ())
1641  {
1642  bool floating = false;
1643  bool visible = true;
1644 
1645  floating = settings->value
1646  (dw_is_floating.key.arg (name), dw_is_floating.def).toBool ();
1647  visible = settings->value
1648  (dw_is_visible.key.arg (name), dw_is_visible.def).toBool ();
1649 
1650  // If floating, make window from widget.
1651  if (floating)
1652  {
1653  widget->make_window ();
1654 
1655  if (visible)
1656  {
1657  if (settings->value (dw_is_minimized.key.arg (name),
1658  dw_is_minimized.def).toBool ())
1659  widget->showMinimized ();
1660  else
1661  widget->setVisible (true);
1662  }
1663  else
1664  widget->setVisible (false);
1665  }
1666  else // not floating
1667  {
1668  if (! widget->parent ()) // should not be floating but is
1669  widget->make_widget (false); // no docking, just reparent
1670 
1671  widget->make_widget ();
1672  widget->setVisible (visible); // not floating -> show
1673  }
1674  }
1675  }
1676 
1677  show ();
1678 }
1679 
1681 {
1683  gui_settings *settings = rmgr.get_settings ();
1684  if (! settings)
1685  {
1686  qDebug ("Error: gui_settings pointer from resource manager is NULL.");
1687  return;
1688  }
1689 
1690  settings->setValue (mw_geometry.key, saveGeometry ());
1691  settings->setValue (mw_state.key, saveState ());
1692  // write the list of recently used directories
1693  QStringList curr_dirs;
1694  for (int i=0; i<m_current_directory_combo_box->count (); i++)
1695  {
1696  curr_dirs.append (m_current_directory_combo_box->itemText (i));
1697  }
1698  settings->setValue (mw_dir_list.key, curr_dirs);
1699  settings->sync ();
1700 }
1701 
1703 {
1704  if (m_current_directory_combo_box->hasFocus ())
1705  {
1706  QLineEdit *edit = m_current_directory_combo_box->lineEdit ();
1707  if (edit && edit->hasSelectedText ())
1708  {
1709  QClipboard *clipboard = QApplication::clipboard ();
1710  clipboard->setText (edit->selectedText ());
1711  }
1712  }
1713  else
1714  emit copyClipboard_signal ();
1715 }
1716 
1718 {
1719  if (m_current_directory_combo_box->hasFocus ())
1720  {
1721  QLineEdit *edit = m_current_directory_combo_box->lineEdit ();
1722  QClipboard *clipboard = QApplication::clipboard ();
1723  QString str = clipboard->text ();
1724  if (edit && str.length () > 0)
1725  {
1726  edit->insert (str);
1727  }
1728  }
1729  else
1730  emit pasteClipboard_signal ();
1731 }
1732 
1734 {
1735  if (m_current_directory_combo_box->hasFocus ())
1736  {
1737  QLineEdit *edit = m_current_directory_combo_box->lineEdit ();
1738  if (edit)
1739  {
1740  edit->selectAll ();
1741  }
1742  }
1743  else
1744  emit selectAll_signal ();
1745 }
1746 
1747 void main_window::handle_gui_status_update (const QString& feature,
1748  const QString& status)
1749 {
1750  // Put actions that are required for updating a gui features here
1751 
1752  // Profiler on/off
1753  if (! feature.compare ("profiler"))
1754  {
1755  if (! status.compare ("on", Qt::CaseInsensitive))
1757  else if (! status.compare ("off", Qt::CaseInsensitive))
1759  }
1760 }
1761 
1763 {
1764  // actions after the startup files are executed
1766  gui_settings *settings = rmgr.get_settings ();
1767 
1768  QDir startup_dir = QDir (); // current octave dir after startup
1769 
1770  if (settings)
1771  {
1772  if (settings->value (global_restore_ov_dir).toBool ())
1773  {
1774  // restore last dir from previous session
1775  QStringList curr_dirs
1776  = settings->value (mw_dir_list).toStringList ();
1777  if (curr_dirs.length () > 0)
1778  startup_dir = QDir (curr_dirs.at (0)); // last dir prev. session
1779  }
1780  else if (! settings->value (global_ov_startup_dir).toString ().isEmpty ())
1781  {
1782  // do not restore but there is a startup dir configured
1783  startup_dir
1784  = QDir (settings->value (global_ov_startup_dir).toString ());
1785  }
1786 
1787  update_default_encoding (settings->value (ed_default_enc).toString ());
1788  }
1789 
1790  if (! startup_dir.exists ())
1791  {
1792  // the configured startup dir does not exist, take actual one
1793  startup_dir = QDir ();
1794  }
1795 
1796  set_current_working_directory (startup_dir.absolutePath ());
1797 
1798  if (m_editor_window)
1799  {
1800 #if defined (HAVE_QSCINTILLA)
1801  // Octave ready, determine whether to create an empty script.
1802  // This can not be done when the editor is created because all functions
1803  // must be known for the lexer's auto completion information
1804  m_editor_window->empty_script (true, false);
1805  m_editor_window->restore_session (settings);
1806 #endif
1807  }
1808 
1810  {
1811  // Set initial prompt.
1812 
1813  emit interpreter_event
1814  ([] (interpreter& interp)
1815  {
1816  // INTERPRETER_THREAD
1817 
1818  event_manager& evmgr = interp.get_event_manager ();
1819  input_system& input_sys = interp.get_input_system ();
1820 
1821  input_sys.PS1 (">> ");
1822  std::string prompt = input_sys.PS1 ();
1823 
1825  });
1826  }
1827 
1828  m_command_window->init_command_prompt ();
1829  focus_command_window (); // make sure that the command window has focus
1830 }
1831 
1833 {
1834  if (m_set_path_dlg) // m_set_path_dlg is a guarded pointer!
1835  return;
1836 
1838 
1839  m_set_path_dlg->setModal (false);
1840  m_set_path_dlg->setAttribute (Qt::WA_DeleteOnClose);
1841  m_set_path_dlg->show ();
1842 
1843  // Any interpreter_event signal from a set_path_dialog object is
1844  // handled the same as for the main_window object.
1845 
1848 
1851 
1853  this, &main_window::modify_path);
1854 
1856 
1857  qt_interpreter_events *qt_link = interp_qobj->qt_link ();
1858 
1861 
1862  // Now that all the signal connections are in place for the dialog
1863  // we can set the initial value of the path in the model.
1864 
1865  m_set_path_dlg->update_model ();
1866 }
1867 
1868 void main_window::find_files (const QString& start_dir)
1869 {
1870 
1871  if (! m_find_files_dlg)
1872  {
1874 
1875  connect (m_find_files_dlg, &find_files_dialog::finished,
1877 
1880 
1883 
1884  m_find_files_dlg->setWindowModality (Qt::NonModal);
1885  }
1886 
1887  if (! m_find_files_dlg->isVisible ())
1888  {
1889  m_find_files_dlg->show ();
1890  }
1891 
1892  m_find_files_dlg->set_search_dir (start_dir);
1893 
1894  m_find_files_dlg->activateWindow ();
1895 
1896 }
1897 
1898 void main_window::set_screen_size (int ht, int wd)
1899 {
1900  emit interpreter_event
1901  ([=] (void)
1902  {
1903  // INTERPRETER THREAD
1904 
1906  });
1907 }
1908 
1910 {
1911  if (m_clipboard->text ().isEmpty ())
1912  {
1913  m_paste_action->setEnabled (false);
1914  m_clear_clipboard_action->setEnabled (false);
1915  }
1916  else
1917  {
1918  m_paste_action->setEnabled (true);
1919  m_clear_clipboard_action->setEnabled (true);
1920  }
1921 }
1922 
1924 {
1925  m_clipboard->clear (QClipboard::Clipboard);
1926 }
1927 
1929 {
1930  QHash<QMenu *, QStringList>::const_iterator i = m_hash_menu_text.constBegin ();
1931 
1932  while (i != m_hash_menu_text.constEnd ())
1933  {
1934  i.key ()->setTitle (i.value ().at (disable));
1935  ++i;
1936  }
1937 }
1938 
1940 {
1941  // restore the new files creation setting
1943  gui_settings *settings = rmgr.get_settings ();
1944  settings->setValue (ed_create_new_file.key, false);
1945  disconnect (m_editor_window, SIGNAL (file_loaded_signal (void)),
1946  this, SLOT (restore_create_file_setting (void)));
1947 }
1948 
1949 void main_window::set_file_encoding (const QString& new_encoding)
1950 {
1951  m_file_encoding = new_encoding;
1952 }
1953 
1954 // The following slot is called after files have been selected in the
1955 // open file dialog, possibly with a new selected encoding stored in
1956 // m_file_encoding
1957 void main_window::request_open_files (const QStringList& open_file_names)
1958 {
1959  for (int i = 0; i < open_file_names.count (); i++)
1960  emit open_file_signal (open_file_names.at (i), m_file_encoding, -1);
1961 }
1962 
1964 {
1965  emit interpreter_event
1966  ([=] (interpreter& interp)
1967  {
1968  // INTERPRETER THREAD
1969 
1970  Ffeval (interp, ovl ("profile","on"));
1971  });
1972 }
1973 
1975 {
1976  emit interpreter_event
1977  ([=] (interpreter& interp)
1978  {
1979  // INTERPRETER THREAD
1980 
1981  Ffeval (interp, ovl ("profile","resume"));
1982  });
1983 }
1984 
1986 {
1987  emit interpreter_event
1988  ([=] (interpreter& interp)
1989  {
1990  // INTERPRETER THREAD
1991 
1992  Ffeval (interp, ovl ("profile","off"));
1993  });
1994 }
1995 
1997 {
1998  m_profiler_start->setEnabled (! active);
1999  m_profiler_resume->setEnabled (! active);
2000  m_profiler_stop->setEnabled (active);
2001 
2003  if (active)
2006 }
2007 
2009 {
2010  // Do not use a separate interpreter event as in the other
2011  // profiler slots since the output of the command "profshow"
2012  // would obscure the prompt and we do not need to emimt a signal
2013  // for action that is required in the gui after rhe command
2014  execute_command_in_terminal ("profshow");
2015 }
2016 
2017 void main_window::closeEvent (QCloseEvent *e)
2018 {
2019  write_settings ();
2020 
2021  if (confirm_shutdown ())
2022  {
2023  // FIXME: Instead of ignoring the event and posting an
2024  // interpreter event, should we just accept the event and
2025  // shutdown and clean up the interpreter as part of closing the
2026  // GUI? Going that route might make it easier to close the GUI
2027  // without having to stop the interpreter, for example, if the
2028  // GUI is started from the interpreter command line.
2029 
2030  e->ignore ();
2031 
2033  && ! m_octave_qobj.is_gui_app ())
2034  emit close_gui_signal ();
2035  else
2036  {
2037  emit interpreter_event
2038  ([] (interpreter& interp)
2039  {
2040  // INTERPRETER THREAD
2041 
2042  interp.quit (0, false, false);
2043  });
2044  }
2045  }
2046  else
2047  e->ignore ();
2048 }
2049 
2051 {
2052  // Create and set the central widget. QMainWindow takes ownership of
2053  // the widget (pointer) so there is no need to delete the object upon
2054  // destroying this main_window.
2055 
2056  QWidget *dummyWidget = new QWidget ();
2057  dummyWidget->setObjectName ("CentralDummyWidget");
2058  dummyWidget->resize (10, 10);
2059  dummyWidget->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
2060  dummyWidget->hide ();
2061  setCentralWidget (dummyWidget);
2062 }
2063 
2064 // Main subroutine of the constructor
2065 
2067 {
2068  setWindowIcon (QIcon (dw_icon_set_names["NONE"]));
2069 
2071 
2072  qt_interpreter_events *qt_link = interp_qobj->qt_link ();
2073 
2074  construct_menu_bar ();
2075 
2076  construct_tool_bar ();
2077 
2078  // FIXME: Is this action intended to be about quitting application
2079  // or closing the main window?
2080  connect (qApp, &QApplication::aboutToQuit,
2082 
2083  connect (qApp, &QApplication::focusChanged,
2085 
2086  connect (this, &main_window::settings_changed,
2087  this, [=] (const gui_settings *settings) { notice_settings (settings); });
2088 
2089  // Connections for signals from the interpreter thread where the slot
2090  // should be executed by the gui thread
2091 
2094 
2095  setWindowTitle ("Octave");
2096 
2097  setStatusBar (m_status_bar);
2098 
2099  // Signals for removing/renaming files/dirs in the temrinal window
2100  connect (qt_link, &qt_interpreter_events::file_remove_signal,
2102 
2105 
2108 
2110 }
2111 
2113 {
2115 
2116  qt_interpreter_events *qt_link = interp_qobj->qt_link ();
2117 
2118  connect (qt_link, &qt_interpreter_events::settings_changed,
2120 
2121  connect (qt_link, &qt_interpreter_events::apply_new_settings,
2123 
2126 
2129 
2132 
2135 
2137  this, [=] () { process_settings_dialog_request (); });
2138 
2141 
2144 
2147 
2150 
2153 }
2154 
2155 QAction* main_window::add_action (QMenu *menu, const QIcon& icon,
2156  const QString& text, const char *member,
2157  const QWidget *receiver)
2158 {
2159  QAction *a;
2160 
2161  if (receiver)
2162  a = menu->addAction (icon, text, receiver, member);
2163  else
2164  a = menu->addAction (icon, text, this, member);
2165 
2166  addAction (a); // important for shortcut context
2167  a->setShortcutContext (Qt::ApplicationShortcut);
2168  return a;
2169 }
2170 
2172 {
2173  QMenu *menu = p->addMenu (name);
2174 
2175  QString base_name = name; // get a copy
2176  // replace intended '&' ("&&") by a temp. string
2177  base_name.replace ("&&", "___octave_amp_replacement___");
2178  // remove single '&' (shortcut)
2179  base_name.remove ("&");
2180  // restore intended '&'
2181  base_name.replace ("___octave_amp_replacement___", "&&");
2182 
2183  // remember names with and without shortcut
2184  m_hash_menu_text[menu] = QStringList ({ name, base_name });
2185 
2186  return menu;
2187 }
2188 
2190 {
2191  QMenuBar *menu_bar = menuBar ();
2192 
2193  construct_file_menu (menu_bar);
2194 
2195  construct_edit_menu (menu_bar);
2196 
2197  construct_debug_menu (menu_bar);
2198 
2199  construct_tools_menu (menu_bar);
2200 
2201  construct_window_menu (menu_bar);
2202 
2203  construct_help_menu (menu_bar);
2204 
2205  construct_news_menu (menu_bar);
2206 
2207 #if defined (HAVE_QSCINTILLA)
2208  // call the editor to add actions which should also be available in the
2209  // editor's menu and tool bar
2210  QList<QAction *> shared_actions = {
2213  m_open_action,
2215  m_undo_action,
2216  m_copy_action,
2219  };
2220  m_editor_window->insert_global_actions (shared_actions);
2221 #endif
2222 }
2223 
2225 {
2226  QMenu *file_menu = m_add_menu (p, tr ("&File"));
2227 
2228  construct_new_menu (file_menu);
2229 
2231 
2233  file_menu, rmgr.icon ("document-open"), tr ("Open..."),
2234  SLOT (request_open_file (void)), this);
2235  m_open_action->setToolTip (tr ("Open an existing file in editor"));
2236 
2237 #if defined (HAVE_QSCINTILLA)
2238  file_menu->addMenu (m_editor_window->get_mru_menu ());
2239 #endif
2240 
2241  file_menu->addSeparator ();
2242 
2244  file_menu, QIcon (), tr ("Load Workspace..."),
2245  SLOT (handle_load_workspace_request (void)), this);
2246 
2248  file_menu, QIcon (), tr ("Save Workspace As..."),
2249  SLOT (handle_save_workspace_request (void)), this);
2250 
2251  file_menu->addSeparator ();
2252 
2254  file_menu, QIcon (), tr ("Exit"),
2255  SLOT (close (void)), this);
2256  m_exit_action->setMenuRole (QAction::QuitRole);
2257 
2258  // Connect signal related to opening or creating editor files
2259  connect (this, SIGNAL (new_file_signal (const QString&)),
2260  m_active_editor, SLOT (request_new_file (const QString&)));
2261 
2262  connect (this, SIGNAL (open_file_signal (const QString&)),
2263  m_active_editor, SLOT (request_open_file (const QString&)));
2264 
2265  connect (this,
2266  SIGNAL (open_file_signal (const QString&, const QString&, int)),
2268  SLOT (request_open_file (const QString&, const QString&, int)));
2269 }
2270 
2272 {
2273  QMenu *new_menu = p->addMenu (tr ("New"));
2274 
2276 
2278  new_menu, rmgr.icon ("document-new"), tr ("New Script"),
2279  SLOT (request_new_script (void)), this);
2280 
2282  new_menu, QIcon (), tr ("New Function..."),
2283  SLOT (request_new_function (void)), this);
2284 
2286  new_menu, QIcon (), tr ("New Figure"),
2287  SLOT (handle_new_figure_request (void)), this);
2288 }
2289 
2291 {
2292  QMenu *edit_menu = m_add_menu (p, tr ("&Edit"));
2293 
2294  QKeySequence ctrl_shift = Qt::ControlModifier + Qt::ShiftModifier;
2295 
2298  = edit_menu->addAction (rmgr.icon ("edit-undo"), tr ("Undo"));
2299  m_undo_action->setShortcutContext (Qt::ApplicationShortcut);
2300 
2301  edit_menu->addSeparator ();
2302 
2304  = edit_menu->addAction (rmgr.icon ("edit-copy"), tr ("Copy"), this,
2306  m_copy_action->setShortcutContext (Qt::ApplicationShortcut);
2307 
2309  = edit_menu->addAction (rmgr.icon ("edit-paste"), tr ("Paste"), this,
2311  m_paste_action->setShortcutContext (Qt::ApplicationShortcut);
2312 
2314  = edit_menu->addAction (tr ("Select All"), this,
2316  m_select_all_action->setShortcutContext (Qt::ApplicationShortcut);
2317 
2319  = edit_menu->addAction (tr ("Clear Clipboard"), this,
2321 
2322  edit_menu->addSeparator ();
2323 
2325  = edit_menu->addAction (rmgr.icon ("edit-find"), tr ("Find Files..."));
2326 
2327  edit_menu->addSeparator ();
2328 
2330  = edit_menu->addAction (tr ("Clear Command Window"));
2331 
2333  = edit_menu->addAction (tr ("Clear Command History"));
2334 
2336  = edit_menu->addAction (tr ("Clear Workspace"));
2337 
2338  edit_menu->addSeparator ();
2339 
2341  = edit_menu->addAction (tr ("Set Path"));
2342 
2344  = edit_menu->addAction (rmgr.icon ("preferences-system"),
2345  tr ("Preferences..."));
2346 
2347  connect (m_find_files_action, &QAction::triggered,
2348  this, [=] () { find_files (); });
2349 
2350  connect (m_clear_command_window_action, &QAction::triggered,
2352 
2353  connect (m_clear_command_history_action, &QAction::triggered,
2355 
2356  connect (m_clear_workspace_action, &QAction::triggered,
2358 
2359  connect (m_clipboard, &QClipboard::dataChanged,
2362 #if defined (Q_OS_WIN32)
2363  // Always enable paste action (unreliable clipboard signals in windows)
2364  // FIXME: This has to be removed, when the clipboard signals in windows
2365  // are working again
2366  m_paste_action->setEnabled (true);
2367  m_clear_clipboard_action->setEnabled (true);
2368 #endif
2369 
2370  connect (m_preferences_action, &QAction::triggered,
2371  this, [=] () { process_settings_dialog_request (); });
2372 
2373  connect (m_set_path_action, &QAction::triggered,
2375 
2376 }
2377 
2378 QAction * main_window::construct_debug_menu_item (const char *icon,
2379  const QString& item,
2380  const char *member)
2381 {
2383  QAction *action = add_action (m_debug_menu, rmgr.icon (QString (icon)),
2384  item, member);
2385 
2386  action->setEnabled (false);
2387 
2388 #if defined (HAVE_QSCINTILLA)
2389  m_editor_window->debug_menu ()->addAction (action);
2390  m_editor_window->toolbar ()->addAction (action);
2391 #endif
2392 
2393  return action;
2394 }
2395 
2397 {
2398  m_debug_menu = m_add_menu (p, tr ("De&bug"));
2399 
2401  = construct_debug_menu_item ("db-step", tr ("Step"),
2402  SLOT (debug_step_over (void)));
2403 
2405  = construct_debug_menu_item ("db-step-in", tr ("Step In"),
2406  SLOT (debug_step_into (void)));
2407 
2409  = construct_debug_menu_item ("db-step-out", tr ("Step Out"),
2410  SLOT (debug_step_out (void)));
2411 
2413  = construct_debug_menu_item ("db-cont", tr ("Continue"),
2414  SLOT (debug_continue (void)));
2415 
2416  m_debug_menu->addSeparator ();
2417 #if defined (HAVE_QSCINTILLA)
2418  m_editor_window->debug_menu ()->addSeparator ();
2419 #endif
2420 
2421  m_debug_quit
2422  = construct_debug_menu_item ("db-stop", tr ("Quit Debug Mode"),
2423  SLOT (debug_quit (void)));
2424 }
2425 
2427 {
2428  QMenu *tools_menu = m_add_menu (p, tr ("&Tools"));
2429 
2430  m_profiler_start = add_action (tools_menu, QIcon (),
2431  tr ("Start &Profiler Session"), SLOT (profiler_session ()));
2432 
2433  m_profiler_resume = add_action (tools_menu, QIcon (),
2434  tr ("&Resume Profiler Session"), SLOT (profiler_session_resume ()));
2435 
2436  m_profiler_stop = add_action (tools_menu, QIcon (),
2437  tr ("&Stop Profiler"), SLOT (profiler_stop ()));
2438  m_profiler_stop->setEnabled (false);
2439 
2440  m_profiler_show = add_action (tools_menu, QIcon (),
2441  tr ("&Show Profile Data"), SLOT (profiler_show ()));
2442 }
2443 
2444 void main_window::editor_tabs_changed (bool have_tabs, bool is_octave)
2445 {
2446  // Set state of actions which depend on the existence of editor tabs
2447  m_editor_has_tabs = have_tabs;
2448  m_editor_is_octave_file = is_octave;
2449  m_debug_step_over->setEnabled (have_tabs && is_octave);
2450 }
2451 
2453  const QString& item,
2454  bool checkable,
2455  QWidget *widget)
2456 {
2457  QAction *action = p->addAction (QIcon (), item);
2458 
2459  addAction (action); // important for shortcut context
2460  action->setCheckable (checkable);
2461  action->setShortcutContext (Qt::ApplicationShortcut);
2462 
2463  if (widget) // might be zero for m_editor_window
2464  {
2465  if (checkable)
2466  {
2467  // action for visibility of dock widget
2468  connect (action, SIGNAL (toggled (bool)),
2469  widget, SLOT (setVisible (bool)));
2470 
2471  connect (widget, SIGNAL (active_changed (bool)),
2472  action, SLOT (setChecked (bool)));
2473  }
2474  else
2475  {
2476  // action for focus of dock widget
2477  connect (action, SIGNAL (triggered (void)),
2478  widget, SLOT (activate (void)));
2479  }
2480  }
2481  else
2482  {
2483  action->setEnabled (false);
2484  }
2485 
2486  return action;
2487 }
2488 
2490 {
2491  QMenu *window_menu = m_add_menu (p, tr ("&Window"));
2492 
2494  (window_menu, tr ("Show Command Window"), true, m_command_window);
2495 
2497  (window_menu, tr ("Show Command History"), true, m_history_window);
2498 
2500  (window_menu, tr ("Show File Browser"), true, m_file_browser_window);
2501 
2503  (window_menu, tr ("Show Workspace"), true, m_workspace_window);
2504 
2506  (window_menu, tr ("Show Editor"), true, m_editor_window);
2507 
2509  (window_menu, tr ("Show Documentation"), true, m_doc_browser_window);
2510 
2512  (window_menu, tr ("Show Variable Editor"), true, m_variable_editor_window);
2513 
2514  window_menu->addSeparator ();
2515 
2517  (window_menu, tr ("Command Window"), false, m_command_window);
2518 
2520  (window_menu, tr ("Command History"), false, m_history_window);
2521 
2523  (window_menu, tr ("File Browser"), false, m_file_browser_window);
2524 
2526  (window_menu, tr ("Workspace"), false, m_workspace_window);
2527 
2529  (window_menu, tr ("Editor"), false, m_editor_window);
2530 
2532  (window_menu, tr ("Documentation"), false, m_doc_browser_window);
2533 
2535  (window_menu, tr ("Variable Editor"), false, m_variable_editor_window);
2536 
2537  window_menu->addSeparator ();
2538 
2539  m_previous_dock_action = add_action (window_menu, QIcon (),
2540  tr ("Previous Widget"), SLOT (go_to_previous_widget (void)));
2541 
2542  window_menu->addSeparator ();
2543 
2544  m_reset_windows_action = add_action (window_menu, QIcon (),
2545  tr ("Reset Default Window Layout"), SLOT (reset_windows (void)));
2546 }
2547 
2549 {
2550  QMenu *help_menu = m_add_menu (p, tr ("&Help"));
2551 
2552  construct_documentation_menu (help_menu);
2553 
2554  help_menu->addSeparator ();
2555 
2556  m_report_bug_action = add_action (help_menu, QIcon (),
2557  tr ("Report Bug"), SLOT (open_bug_tracker_page ()));
2558 
2559  m_octave_packages_action = add_action (help_menu, QIcon (),
2560  tr ("Octave Packages"), SLOT (open_octave_packages_page ()));
2561 
2562  m_contribute_action = add_action (help_menu, QIcon (),
2563  tr ("Contribute"), SLOT (open_contribute_page ()));
2564 
2565  m_developer_action = add_action (help_menu, QIcon (),
2566  tr ("Donate to Octave"), SLOT (open_donate_page ()));
2567 
2568  help_menu->addSeparator ();
2569 
2570  m_about_octave_action = add_action (help_menu, QIcon (),
2571  tr ("About Octave"), SLOT (show_about_octave ()));
2572 }
2573 
2575 {
2576  QMenu *doc_menu = p->addMenu (tr ("Documentation"));
2577 
2578  m_ondisk_doc_action = add_action (doc_menu, QIcon (),
2579  tr ("On Disk"), SLOT (activate ()), m_doc_browser_window);
2580 
2581  m_online_doc_action = add_action (doc_menu, QIcon (),
2582  tr ("Online"), SLOT (open_online_documentation_page ()));
2583 }
2584 
2586 {
2587  QMenu *news_menu = m_add_menu (p, tr ("&News"));
2588 
2590  = news_menu->addAction (QIcon (), tr ("Release Notes"),
2591  [=] () {
2592  emit show_release_notes_signal ();
2593  });
2594  addAction (m_release_notes_action);
2595  m_release_notes_action->setShortcutContext (Qt::ApplicationShortcut);
2596 
2598  = news_menu->addAction (QIcon (), tr ("Community News"),
2599  [=] () {
2600  emit show_community_news_signal (-1);
2601  });
2602  addAction (m_current_news_action);
2603  m_current_news_action->setShortcutContext (Qt::ApplicationShortcut);
2604 }
2605 
2607 {
2608  m_main_tool_bar = addToolBar (tr ("Toolbar"));
2609  m_main_tool_bar->setStyleSheet (m_main_tool_bar->styleSheet ()
2611 
2612  m_main_tool_bar->setObjectName ("MainToolBar");
2613  m_main_tool_bar->addAction (m_new_script_action);
2614  m_main_tool_bar->addAction (m_open_action);
2615 
2616  m_main_tool_bar->addSeparator ();
2617 
2618  m_main_tool_bar->addAction (m_copy_action);
2619  m_main_tool_bar->addAction (m_paste_action);
2620  m_main_tool_bar->addAction (m_undo_action);
2621 
2622  m_main_tool_bar->addSeparator ();
2623 
2624  m_current_directory_combo_box = new QComboBox (this);
2625  QFontMetrics fm = m_current_directory_combo_box->fontMetrics ();
2626  m_current_directory_combo_box->setFixedWidth (48*fm.averageCharWidth ());
2627  m_current_directory_combo_box->setEditable (true);
2628  m_current_directory_combo_box->setInsertPolicy (QComboBox::NoInsert);
2629  m_current_directory_combo_box->setToolTip (tr ("Enter directory name"));
2632  QSizePolicy sizePol (QSizePolicy::Preferred, QSizePolicy::Preferred);
2633  m_current_directory_combo_box->setSizePolicy (sizePol);
2634 
2635  // addWidget takes ownership of the objects so there is no
2636  // need to delete these upon destroying this main_window.
2637  m_main_tool_bar->addWidget (new QLabel (tr ("Current Directory: ")));
2640  QAction *current_dir_up
2641  = m_main_tool_bar->addAction (rmgr.icon ("folder-up", false, "go-up"),
2642  tr ("One directory up"));
2643  QAction *current_dir_search
2644  = m_main_tool_bar->addAction (rmgr.icon ("folder"),
2645  tr ("Browse directories"));
2646 
2647  connect (m_current_directory_combo_box, SIGNAL (activated (const QString&)),
2648  this, SLOT (set_current_working_directory (const QString&)));
2649 
2650  connect (m_current_directory_combo_box->lineEdit (),
2651  &QLineEdit::returnPressed,
2653 
2654  connect (current_dir_search, &QAction::triggered,
2656 
2657  connect (current_dir_up, &QAction::triggered,
2659 
2660  connect (m_undo_action, &QAction::triggered,
2662 }
2663 
2665 {
2667  gui_settings *settings = rmgr.get_settings ();
2668  if (settings->value (cs_focus_cmd).toBool ())
2670 }
2671 
2673 {
2674  bool enable
2676 
2678 
2679  // file menu
2686  scmgr.set_shortcut (m_exit_action, sc_main_file_exit, enable);
2687 
2688  // edit menu
2689  scmgr.set_shortcut (m_copy_action, sc_main_edit_copy, enable);
2691  scmgr.set_shortcut (m_undo_action, sc_main_edit_undo, enable);
2700 
2701  // debug menu
2706  scmgr.set_shortcut (m_debug_quit, sc_main_debug_quit, enable);
2707 
2708  // tools menu
2711  scmgr.set_shortcut (m_profiler_stop, sc_main_tools_start_profiler, enable); // same, toggling
2713 
2714  // window menu
2724  // Switching to the other widgets (including the previous one) is always enabled
2732 
2733  // help menu
2741 
2742  // news menu
2745 }
2746 
2748 {
2750  list.append (static_cast<octave_dock_widget *> (m_command_window));
2751  list.append (static_cast<octave_dock_widget *> (m_history_window));
2752  list.append (static_cast<octave_dock_widget *> (m_file_browser_window));
2753  list.append (static_cast<octave_dock_widget *> (m_doc_browser_window));
2754 #if defined (HAVE_QSCINTILLA)
2755  list.append (static_cast<octave_dock_widget *> (m_editor_window));
2756 #endif
2757  list.append (static_cast<octave_dock_widget *> (m_workspace_window));
2758  list.append (static_cast<octave_dock_widget *> (m_variable_editor_window));
2759  return list;
2760 }
2761 
2762 void main_window::update_default_encoding (const QString& default_encoding)
2763 {
2764  m_default_encoding = default_encoding;
2765  std::string mfile_encoding = m_default_encoding.toStdString ();
2766  if (m_default_encoding.startsWith ("SYSTEM", Qt::CaseInsensitive))
2767  mfile_encoding = "SYSTEM";
2768 
2769  emit interpreter_event
2770  ([=] (interpreter& interp)
2771  {
2772  // INTERPRETER THREAD
2773 
2774  F__mfile_encoding__ (interp, ovl (mfile_encoding));
2775  });
2776 }
2777 
2778 void main_window::resize_dock (QDockWidget *dw, int width, int height)
2779 {
2780 #if defined (HAVE_QMAINWINDOW_RESIZEDOCKS)
2781  // resizeDockWidget was added to Qt in Qt 5.6
2782  if (width >= 0)
2783  resizeDocks ({dw}, {width}, Qt::Horizontal);
2784  if (height >= 0)
2785  resizeDocks ({dw}, {height}, Qt::Vertical);
2786 #else
2787  // This replacement of resizeDockWidget is not very reliable.
2788  // But even if Qt4 is not yet
2789  QSize s = dw->widget ()->size ();
2790  if (width >= 0)
2791  s.setWidth (width);
2792  if (height >= 0)
2793  s.setHeight (height);
2794  dw->widget ()->resize (s);
2795  dw->adjustSize ();
2796 #endif
2797 }
2798 
2799 // The default main window size relative to the desktop size
2801 {
2802  int win_x, win_y;
2803  get_screen_geometry (win_x, win_y);
2804 
2805  move (0, 0);
2806  resize (2*win_x/3, 7*win_y/8);
2807 }
2808 
2810 {
2811  // Slot for resetting the window layout to the default one
2812  hide ();
2813  showNormal (); // Unmaximize
2814  do_reset_windows (true, true, true); // Add all widgets
2815 
2816  // Re-add after giving time: This seems to be a reliable way to
2817  // reset the main window's layout
2818 
2819  // JWE says: The following also works for me with 0 delay, so I
2820  // think the problem might just be that the event loop needs to run
2821  // somewhere in the sequence of resizing and adding widgets. Maybe
2822  // some actions in do_reset_windows should be using signal/slot
2823  // connections so that the event loop can do what it needs to do.
2824  // But I haven't been able to find the magic sequence.
2825 
2826  QTimer::singleShot (250, this, [=] () { do_reset_windows (true, true, true); });
2827 }
2828 
2829 // Create the default layout of the main window. Do not use
2830 // restoreState () and restoreGeometry () with default values since
2831 // this might lead to problems when the Qt version changes
2832 void main_window::do_reset_windows (bool show, bool save, bool force_all)
2833 {
2834  // Set main window default geometry and store its width for
2835  // later resizing the command window
2837  int win_x = geometry ().width ();
2838 
2839  // Resize command window (if docked),
2840  //the important one in the default layout
2841  if (dockWidgetArea (m_command_window) != Qt::NoDockWidgetArea)
2842  resize_dock (m_command_window, 7*win_x/8, -1);
2843 
2844  // See Octave bug #53409 and https://bugreports.qt.io/browse/QTBUG-55357
2845 #if (QT_VERSION < 0x050601) || (QT_VERSION >= 0x050701)
2846  setDockOptions (QMainWindow::AnimatedDocks
2847  | QMainWindow::AllowNestedDocks
2848  | QMainWindow::AllowTabbedDocks);
2849 #else
2850  setDockNestingEnabled (true);
2851 #endif
2852 
2853  // Add the dock widgets and show them
2854  if (! m_file_browser_window->adopted () || force_all)
2855  {
2856  // FIXME: Maybe there should be a main_window::add_dock_widget
2857  // function that combines both of these actions?
2858 
2859  addDockWidget (Qt::LeftDockWidgetArea, m_file_browser_window);
2860  m_file_browser_window->set_adopted (false);
2861  }
2862 
2863  if (! m_workspace_window->adopted () || force_all)
2864  {
2865  addDockWidget (Qt::LeftDockWidgetArea, m_workspace_window);
2866  m_workspace_window->set_adopted (false);
2867  }
2868 
2869  if (! m_history_window->adopted () || force_all)
2870  {
2871  addDockWidget (Qt::LeftDockWidgetArea, m_history_window);
2872  m_history_window->set_adopted (false);
2873  }
2874 
2875  if (! m_command_window->adopted () || force_all)
2876  {
2877  addDockWidget (Qt::RightDockWidgetArea, m_command_window);
2878  m_command_window->set_adopted (false);
2879  }
2880 
2881  if (! m_doc_browser_window->adopted () || force_all)
2882  {
2883  addDockWidget (Qt::RightDockWidgetArea, m_doc_browser_window);
2884  tabifyDockWidget (m_command_window, m_doc_browser_window);
2885  m_doc_browser_window->set_adopted (false);
2886  }
2887 
2888  if (! m_variable_editor_window->adopted () || force_all)
2889  {
2890  addDockWidget (Qt::RightDockWidgetArea, m_variable_editor_window);
2891  tabifyDockWidget (m_command_window, m_variable_editor_window);
2892  m_variable_editor_window->set_adopted (false);
2893  }
2894 
2895 #if defined (HAVE_QSCINTILLA)
2896  addDockWidget (Qt::RightDockWidgetArea, m_editor_window);
2897  tabifyDockWidget (m_command_window, m_editor_window);
2898 #endif
2899 
2900  // Resize command window, the important one in the default layout
2901  resize_dock (m_command_window, 2*win_x/3, -1);
2902 
2903  // Show main wibdow, save state and geometry of main window and
2904  // all dock widgets
2905  if (show)
2906  {
2907  // Show all dock widgets
2908  for (auto *widget : dock_widget_list ())
2909  widget->show ();
2910 
2911  // Show main window and store size and state
2912  showNormal ();
2913 
2914  if (save)
2915  {
2917  gui_settings *settings = rmgr.get_settings ();
2918 
2919  settings->setValue (mw_geometry.key, saveGeometry ());
2920  settings->setValue (mw_state.key, saveState ());
2921  }
2922 
2924  }
2925 }
2926 
OCTAVE_END_NAMESPACE(octave)
void report_status_message(const QString &)
virtual void pasteClipboard(void)=0
void set_screen_size_signal(int, int)
virtual void init_terminal_size(void)
Definition: QTerminal.h:131
void edit_mfile_request(const QString &, int)
void request_edit_mfile_signal(const QString &, int)
void request_open_file_signal(const QString &, const QString &, int)
virtual void copyClipboard(void)=0
void clear_command_window_request(void)
void execute_command_in_terminal_signal(const QString &)
virtual void selectAll(void)=0
Base class for Octave interfaces that use Qt.
QPointer< history_dock_widget > history_widget(main_window *mw=nullptr)
QPointer< files_dock_widget > file_browser_widget(main_window *mw=nullptr)
void connect_interpreter_events(T *widget)
bool is_gui_app(void) const
QApplication * qapplication(void)
bool experimental_terminal_widget(void) const
interpreter_qobject * interpreter_qobj(void)
resource_manager & get_resource_manager(void)
QPointer< variable_editor > variable_editor_widget(main_window *mw=nullptr)
void interpreter_event(const fcn_callback &fcn)
shortcut_manager & get_shortcut_manager(void)
QPointer< terminal_dock_widget > terminal_widget(main_window *mw=nullptr)
QPointer< workspace_view > workspace_widget(main_window *mw=nullptr)
QPointer< documentation_dock_widget > documentation_widget(main_window *mw=nullptr)
static void replace_line(const std::string &text, bool clear_undo=true)
Definition: cmd-edit.cc:1461
static void redisplay(void)
Definition: cmd-edit.cc:1238
static std::string get_current_line(void)
Definition: cmd-edit.cc:1447
static bool interrupt(bool=true)
Definition: cmd-edit.cc:1625
static void clear_screen(bool skip_redisplay=false)
Definition: cmd-edit.cc:1257
static void set_initial_input(const std::string &text)
Definition: cmd-edit.cc:1113
static void set_screen_size(int ht, int wd)
Definition: cmd-edit.cc:1271
static void accept_line(void)
Definition: cmd-edit.cc:1489
static std::string decode_prompt_string(const std::string &s)
Definition: cmd-edit.cc:1278
static void interrupt_event_loop(bool flag=true)
Definition: cmd-edit.cc:1645
static void kill_full_line(void)
Definition: cmd-edit.cc:1468
static bool undo(void)
Definition: cmd-edit.cc:1496
Provides threadsafe access to octave.
OCTINTERP_API void set_workspace(void)
void update_prompt(const std::string &prompt)
void request_settings_dialog(const QString &)
bool call_custom_editor(const QString &file=QString(), int line=-1)
void handle_insert_debugger_pointer_request(const QString &file, int line)
void handle_exit_debug_mode(void)
Definition: file-editor.cc:196
void request_open_file_external(const QString &file_name, int line)
void enable_menu_shortcuts(bool)
Definition: file-editor.cc:401
void handle_file_remove(const QString &, const QString &)
void focus_console_after_command_signal(void)
void update_octave_directory(const QString &dir)
void handle_delete_debugger_pointer_request(const QString &file, int line)
void request_step_into_file()
Definition: file-editor.cc:717
void request_dbcont_signal(void)
void update_gui_lexer_signal(bool)
void run_file_signal(const QFileInfo &)
void handle_file_renamed(bool load_new=true)
void execute_command_in_terminal_signal(const QString &)
void edit_mfile_request(const QString &, const QString &, const QString &, int)
void handle_update_breakpoint_marker_request(bool insert, const QString &file, int line, const QString &cond)
void request_settings_dialog(const QString &)
void debug_quit_signal(void)
void handle_enter_debug_mode(void)
Definition: file-editor.cc:181
void editor_tabs_changed_signal(bool, bool)
void open_file(const QString &fileName)
Emitted, whenever the user requested to open a file.
void set_current_directory(const QString &dir)
Sets the current directory being displayed.
void file_renamed_signal(bool)
Emitted, when a file or directory is renamed.
void displayed_directory_changed(const QString &dir)
Emitted, whenever the currently displayed directory changed.
void load_file_signal(const QString &fileName)
Emitted, whenever the user requested to load a file in the text editor.
void run_file_signal(const QFileInfo &info)
Emitted, whenever the user requested to run a file.
void modify_path_signal(const QStringList &dir_list, bool rm, bool subdirs)
Emitted, when the path has to be modified.
void open_any_signal(const QString &fileName)
Emitted, whenever the user requested to open an unknown type file.
void find_files_signal(const QString &startdir)
Emitted, whenever wants to search for a file .
void file_remove_signal(const QString &old_name, const QString &new_name)
Emitted, whenever the user removes or renames a file.
void set_search_dir(const QString &dir)
void file_selected(const QString &fileName)
void dir_selected(const QString &fileName)
void command_double_clicked(const QString &command)
Signal emitted whenever the user double-clicks a command in the history.
void command_create_script(const QString &commands)
Signal emitted whenever the user selects commands and chooses "Create script" from the popup menu.
string_vector do_history(const octave_value_list &args=octave_value_list(), int nargout=0)
Definition: oct-hist.cc:318
octave_value PS1(const octave_value_list &args, int nargout)
qt_interpreter_events * qt_link(void)
event_manager & get_event_manager(void)
Definition: interpreter.h:328
void quit(int exit_status, bool force=false, bool confirm=true)
history_system & get_history_system(void)
Definition: interpreter.h:273
tree_evaluator & get_evaluator(void)
int chdir(const std::string &dir)
octave_value_list feval(const char *name, const octave_value_list &args=octave_value_list(), int nargout=0)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
input_system & get_input_system(void)
Definition: interpreter.h:263
void set_state(led_state state)
Represents the main window.
Definition: main-window.h:73
void pasteClipboard_signal(void)
void open_contribute_page(void)
Definition: main-window.cc:868
void profiler_session_resume(void)
bool m_editor_is_octave_file
Some class global flags.
Definition: main-window.h:434
void new_file_signal(const QString &)
QAction * m_debug_step_into
Definition: main-window.h:345
QHash< QMenu *, QStringList > m_hash_menu_text
Definition: main-window.h:309
void set_default_geometry(void)
void construct(void)
find_files_dialog * m_find_files_dlg
Find files dialog.
Definition: main-window.h:417
QAction * m_clear_workspace_action
Definition: main-window.h:366
void request_new_script(const QString &commands=QString())
QPointer< history_dock_widget > m_history_window
Dock widgets.
Definition: main-window.h:324
void open_donate_page(void)
Definition: main-window.cc:873
void file_remove_proxy(const QString &o, const QString &n)
Definition: main-window.cc:831
void browse_for_directory(void)
static const int current_directory_max_count
For Toolbars.
Definition: main-window.h:407
QPointer< settings_dialog > m_settings_dlg
Settings dialog as guarded pointer (set to 0 when deleted).
Definition: main-window.h:413
QAction * m_select_all_action
Definition: main-window.h:368
bool m_suppress_dbg_location
Some class global flags.
Definition: main-window.h:432
void request_new_function(bool triggered=true)
void profiler_session(void)
void adopt_documentation_widget(void)
Definition: main-window.cc:292
base_qobject & m_octave_qobj
Definition: main-window.h:307
QAction * m_show_history_action
Definition: main-window.h:376
QList< octave_dock_widget * > dock_widget_list(void)
void run_file_in_terminal(const QFileInfo &info)
void pasteClipboard(void)
QClipboard * m_clipboard
Definition: main-window.h:426
void settings_changed(const gui_settings *)
QString m_default_encoding
Definition: main-window.h:311
octave_dock_widget * m_previous_dock
Definition: main-window.h:335
void focus_window(const QString &win_name)
Definition: main-window.cc:495
void set_window_layout(gui_settings *settings)
QString m_default_style
Definition: main-window.h:313
QAction * m_octave_packages_action
Definition: main-window.h:395
QAction * m_editor_action
Definition: main-window.h:386
void update_gui_lexer_signal(bool)
void construct_window_menu(QMenuBar *p)
QAction * m_clear_clipboard_action
Definition: main-window.h:362
void profiler_stop(void)
octave_dock_widget * m_active_dock
Definition: main-window.h:336
void handle_delete_debugger_pointer_request(const QString &file, int line)
void report_status_message(const QString &statusMessage)
Definition: main-window.cc:658
QPalette getFusionDarkPalette()
void open_bug_tracker_page(void)
Definition: main-window.cc:858
void close_gui_signal(void)
QAction * m_open_action
Definition: main-window.h:352
void show_about_octave(void)
Definition: main-window.cc:898
void set_current_working_directory(const QString &dir)
void process_settings_dialog_request(const QString &desired_tab=QString())
Definition: main-window.cc:878
void debug_step_out(void)
QAction * m_debug_continue
Definition: main-window.h:344
void copyClipboard_signal(void)
QAction * m_save_workspace_action
Definition: main-window.h:355
void step_into_file_signal(void)
void construct_tool_bar(void)
void closeEvent(QCloseEvent *closeEvent)
QAction * m_workspace_action
Definition: main-window.h:384
QWidget * m_active_editor
Definition: main-window.h:333
QAction * m_ondisk_doc_action
Definition: main-window.h:392
QAction * m_new_figure_action
Definition: main-window.h:353
QPointer< file_editor_interface > m_editor_window
Dock widgets.
Definition: main-window.h:327
void handle_profiler_status_update(bool)
void insert_debugger_pointer_signal(const QString &file, int line)
void edit_mfile(const QString &, int)
Definition: main-window.cc:826
void warning_function_not_found(const QString &message)
void focus_console_after_command(void)
void construct_debug_menu(QMenuBar *p)
void handle_clear_command_window_request(void)
Definition: main-window.cc:756
void handle_edit_mfile_request(const QString &name, const QString &file, const QString &curr_dir, int line)
QAction * m_history_action
Definition: main-window.h:383
void change_directory_up(void)
void clear_clipboard()
Handling the clipboard.
void handle_undo_request(void)
Definition: main-window.cc:781
void adopt_history_widget(void)
Definition: main-window.cc:327
void profiler_show(void)
void construct_central_widget(void)
void active_dock_changed(octave_dock_widget *, octave_dock_widget *)
QAction * m_documentation_action
Definition: main-window.h:387
void handle_load_workspace_request(const QString &file=QString())
Definition: main-window.cc:688
void adopt_dock_widgets(void)
Definition: main-window.cc:221
bool m_editor_has_tabs
Some class global flags.
Definition: main-window.h:433
QAction * m_contribute_action
Definition: main-window.h:396
void handle_set_path_dialog_request(void)
QAction * m_show_editor_action
Definition: main-window.h:379
void warning_function_not_found_signal(const QString &message)
void debug_step_into(void)
QMenu * m_debug_menu
Definition: main-window.h:340
void restore_create_file_setting(void)
QPointer< documentation_dock_widget > m_doc_browser_window
Dock widgets.
Definition: main-window.h:326
void reset_windows(void)
QStatusBar * m_status_bar
Toolbar.
Definition: main-window.h:318
void adopt_editor_widget(void)
Definition: main-window.cc:350
QAction * construct_window_menu_item(QMenu *p, const QString &item, bool checkable, QWidget *)
QAction * m_new_function_action
Definition: main-window.h:351
void construct_documentation_menu(QMenu *p)
void undo_signal(void)
QAction * m_reset_windows_action
Definition: main-window.h:390
void adopt_terminal_widget(void)
Definition: main-window.cc:234
void execute_command_signal(const QString &command)
void delete_debugger_pointer_signal(const QString &file, int line)
void notice_settings(const gui_settings *settings, bool update_by_worker=false)
Definition: main-window.cc:907
void handle_clear_workspace_request(void)
Definition: main-window.cc:745
void write_settings(void)
void update_breakpoint_marker_signal(bool insert, const QString &file, int line, const QString &cond)
void editor_focus_changed(bool)
void editor_tabs_changed(bool, bool)
void handle_insert_debugger_pointer_request(const QString &file, int line)
void disable_menu_shortcuts(bool disable)
QAction * m_find_files_action
Definition: main-window.h:367
void adopt_variable_editor_widget(void)
Definition: main-window.cc:454
void construct_menu_bar(void)
QAction * m_new_script_action
Definition: main-window.h:350
void construct_edit_menu(QMenuBar *p)
QPalette m_default_palette
Definition: main-window.h:314
void handle_open_any_request(const QString &file=QString())
Definition: main-window.cc:721
void selectAll_signal(void)
QPointer< variable_editor > m_variable_editor_window
Dock widgets.
Definition: main-window.h:329
QAction * m_debug_step_over
Definition: main-window.h:346
void read_settings(void)
void make_dock_widget_connections(octave_dock_widget *dw)
Definition: main-window.cc:461
bool m_prevent_readline_conflicts_menu
Some class global flags.
Definition: main-window.h:431
QPointer< set_path_dialog > m_set_path_dlg
Set path dialog.
Definition: main-window.h:420
void handle_clear_history_request(void)
Definition: main-window.cc:768
void show_community_news_signal(int serial)
void modify_path(const QStringList &dir_list, bool rm, bool subdirs)
Definition: main-window.cc:798
void find_files(const QString &startdir=QDir::currentPath())
Find files dialog.
QAction * m_profiler_resume
Definition: main-window.h:371
void go_to_previous_widget(void)
QAction * m_previous_dock_action
Definition: main-window.h:389
void handle_new_figure_request(void)
QAction * m_profiler_show
Definition: main-window.h:373
QAction * m_current_news_action
Definition: main-window.h:401
void accept_directory_line_edit(void)
QMenu * m_add_menu(QMenuBar *p, QString text)
QAction * m_command_window_action
Definition: main-window.h:382
QAction * m_release_notes_action
Definition: main-window.h:400
void debug_step_over(void)
void focus_command_window(void)
Definition: main-window.cc:490
void interpreter_event(const fcn_callback &fcn)
QAction * m_variable_editor_action
Definition: main-window.h:388
QAction * m_clear_command_window_action
Definition: main-window.h:364
void prepare_to_exit(void)
external_editor_interface * m_external_editor
Definition: main-window.h:332
void request_reload_settings(void)
Definition: main-window.cc:649
void configure_shortcuts(void)
QAction * construct_debug_menu_item(const char *icon, const QString &item, const char *member)
bool confirm_shutdown(void)
Definition: main-window.cc:507
void construct_news_menu(QMenuBar *p)
static const int current_directory_max_visible
For Toolbars.
Definition: main-window.h:406
QAction * m_preferences_action
Definition: main-window.h:357
QAction * m_show_variable_editor_action
Definition: main-window.h:381
void request_open_file(void)
void clipboard_has_changed(void)
Handling the clipboard.
void selectAll(void)
QAction * m_show_documentation_action
Definition: main-window.h:380
void handle_enter_debugger(void)
void init_terminal_size_signal(void)
QAction * m_about_octave_action
Definition: main-window.h:398
QAction * m_exit_action
Definition: main-window.h:358
void handle_save_workspace_request(void)
Definition: main-window.cc:663
QComboBox * m_current_directory_combo_box
For Toolbars.
Definition: main-window.h:405
QAction * add_action(QMenu *menu, const QIcon &icon, const QString &text, const char *member, const QWidget *receiver=nullptr)
void adopt_file_browser_widget(void)
Definition: main-window.cc:299
void construct_octave_qt_link(void)
bool m_prevent_readline_conflicts
Some class global flags.
Definition: main-window.h:430
QAction * m_debug_step_out
Definition: main-window.h:347
void find_files_finished(int)
Find files dialog.
Definition: main-window.h:226
QAction * m_copy_action
Definition: main-window.h:360
~main_window(void)
Definition: main-window.cc:219
void init_window_menu(void)
void construct_new_menu(QMenu *p)
QAction * m_profiler_start
Definition: main-window.h:370
QPointer< terminal_dock_widget > m_command_window
Dock widgets.
Definition: main-window.h:323
QAction * m_developer_action
Definition: main-window.h:397
QAction * m_show_workspace_action
Definition: main-window.h:377
void open_octave_packages_page(void)
Definition: main-window.cc:863
QAction * m_paste_action
Definition: main-window.h:361
void construct_file_menu(QMenuBar *p)
led_indicator * m_profiler_status_indicator
Definition: main-window.h:319
void execute_command_in_terminal(const QString &dir)
void init_terminal_size(void)
void set_file_encoding(const QString &new_encoding)
bool command_window_has_focus(void) const
Definition: main-window.cc:485
QAction * m_debug_quit
Definition: main-window.h:348
void handle_update_breakpoint_marker_request(bool insert, const QString &file, int line, const QString &cond)
void do_reset_windows(bool show=true, bool save=true, bool force_all=false)
QAction * m_show_command_window_action
Definition: main-window.h:375
QAction * m_load_workspace_action
Definition: main-window.h:354
void resize_dock(QDockWidget *dw, int width, int height)
void debug_quit(void)
void handle_gui_status_update(const QString &feature, const QString &status)
QAction * m_clear_command_history_action
Definition: main-window.h:365
void copyClipboard(void)
QString m_file_encoding
Definition: main-window.h:441
void open_online_documentation_page(void)
Definition: main-window.cc:852
void focus_changed(QWidget *w_old, QWidget *w_new)
Definition: main-window.cc:536
QAction * m_profiler_stop
Definition: main-window.h:372
QAction * m_undo_action
Definition: main-window.h:363
void show_release_notes_signal(void)
QAction * m_show_file_browser_action
Definition: main-window.h:378
void open_file_signal(const QString &)
void update_default_encoding(const QString &default_encoding)
void set_screen_size(int ht, int wd)
void construct_help_menu(QMenuBar *p)
void adopt_workspace_widget(void)
Definition: main-window.cc:340
void request_open_files(const QStringList &open_file_names)
QPointer< files_dock_widget > m_file_browser_window
Dock widgets.
Definition: main-window.h:325
QAction * m_report_bug_action
Definition: main-window.h:394
QToolBar * m_main_tool_bar
Definition: main-window.h:338
void handle_exit_debugger(void)
void update_octave_directory(const QString &dir)
QMenuBar * m_editor_menubar
Definition: main-window.h:342
void handle_octave_ready()
QAction * m_file_browser_action
Definition: main-window.h:385
QPointer< workspace_view > m_workspace_window
Dock widgets.
Definition: main-window.h:328
void construct_tools_menu(QMenuBar *p)
QAction * m_set_path_action
Definition: main-window.h:356
QAction * m_online_doc_action
Definition: main-window.h:393
void debug_continue(void)
void handle_settings(const gui_settings *)
void init_window_menu_entry(void)
virtual void save_settings(void)
void handle_active_dock_changed(octave_dock_widget *, octave_dock_widget *)
void set_predecessor_widget(octave_dock_widget *prev_widget)
virtual void activate(void)
octave_value_list & append(const octave_value &val)
Definition: ovl.cc:98
octave_idx_type length(void) const
Definition: ovl.h:113
void enter_debugger_signal(void)
void update_breakpoint_marker_signal(bool insert, const QString &file, int line, const QString &cond)
void insert_debugger_pointer_signal(const QString &, int)
void directory_changed_signal(const QString &dir)
void file_remove_signal(const QString &old_name, const QString &new_name)
void apply_new_settings(void)
void execute_command_in_terminal_signal(const QString &command)
void settings_changed(const gui_settings *, bool)
void file_renamed_signal(bool load_new)
void show_preferences_signal(void)
void exit_debugger_signal(void)
void gui_status_update_signal(const QString &feature, const QString &status)
void delete_debugger_pointer_signal(const QString &, int)
void update_gui_lexer_signal(bool update_apis_only)
void update_path_dialog_signal(void)
void update_network_settings(void)
gui_settings * get_settings(void) const
void config_translators(QTranslator *qt_tr, QTranslator *qsci_tr, QTranslator *gui_tr)
void config_icon_theme(void)
QIcon icon(const QString &icon_name, bool octave_only=false, const QString &icon_alt_name=QString())
bool is_first_run(void) const
void reload_settings(void)
void interpreter_event(const fcn_callback &fcn)
void modify_path_signal(const QStringList &dir_list, bool rm, bool subdirs)
Emitted, when the path has to be modified.
void update_model(void)
void apply_new_settings(void)
void set_shortcut(QAction *action, const sc_pref &scpref, bool enable=true)
void notice_settings(const gui_settings *settings)
void execute_command_signal(const QString &)
symbol_info_list get_symbol_info(void)
Definition: pt-eval.cc:4571
void command_requested(const QString &cmd)
Signal that user had requested a command on a variable.
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
OCTAVE_EXPORT octave_value_list Fdbstep(octave::interpreter &interp, const octave_value_list &args, int)
Definition: debug.cc:1065
OCTAVE_EXPORT octave_value_list Fdbcont(octave::interpreter &interp, const octave_value_list &args, int)
Definition: debug.cc:1118
OCTAVE_EXPORT octave_value_list F__db_next_breakpoint_quiet__(octave::interpreter &interp, const octave_value_list &args, int)
Definition: debug.cc:1191
OCTAVE_EXPORT octave_value_list Fdbquit(octave::interpreter &interp, const octave_value_list &args, int)
Definition: debug.cc:1141
void message(const char *name, const char *fmt,...)
Definition: error.cc:947
OCTAVE_EXPORT octave_value_list Fdrawnow(octave::interpreter &interp, const octave_value_list &args, int)
Definition: graphics.cc:13932
const gui_pref cs_focus_cmd("terminal/focus_after_command", QVariant(false))
const gui_pref cs_dbg_location("terminal/print_debug_location", QVariant(false))
const gui_pref cs_cursor_blinking("terminal/cursorBlinking", QVariant(true))
const gui_pref dw_is_floating("DockWidgets/%1Floating", QVariant(false))
const gui_pref dw_is_visible("DockWidgets/%1Visible", QVariant(true))
const gui_pref dw_is_minimized("DockWidgets/%1_minimized", QVariant(false))
const QHash< QString, QString > dw_icon_set_names
const gui_pref dw_icon_set("DockWidgets/widget_icon_set", QVariant("NONE"))
const gui_pref ed_create_new_file("editor/create_new_file", QVariant(false))
const gui_pref ed_default_enc("editor/default_encoding", QVariant("UTF-8"))
const gui_pref global_restore_ov_dir("restore_octave_dir", QVariant(false))
const gui_pref global_status_bar("show_status_bar", QVariant(true))
const QStyle::PixelMetric global_icon_sizes[3]
const QString gui_obj_name_main_window
const gui_pref global_prompt_to_exit("prompt_to_exit", QVariant(false))
const gui_pref global_use_native_dialogs("use_native_file_dialogs", QVariant(true))
const gui_pref global_use_custom_editor("useCustomFileEditor", QVariant(false))
@ EXTRA_STYLE_FUSION_DARK
const gui_pref global_ov_startup_dir("octave_startup_dir", QVariant(QString()))
const QStringList global_extra_styles
const QString global_toolbar_style("QToolBar {" "margin-top: 0px;" "margin-bottom: 0px;" "padding-top: 0px;" "padding-bottom: 0px;" "border-top: 0px;" "border-bottom: 0px;" "}")
const gui_pref global_icon_size("toolbar_icon_size", QVariant(0))
const gui_pref global_cursor_blinking("cursor_blinking", QVariant(true))
const gui_pref global_style("style", QVariant("default"))
const gui_pref mw_dir_list("MainWindow/current_directory_list", QVariant(QStringList()))
const gui_pref mw_geometry("MainWindow/geometry", QVariant(QByteArray()))
const gui_pref mw_state("MainWindow/windowState", QVariant(QByteArray()))
const gui_pref nr_allow_connection("news/allow_web_connection", QVariant(false))
const gui_pref nr_last_news("news/last_news_item", QVariant(0))
const gui_pref nr_last_time("news/last_time_checked", QVariant(QDateTime()))
const sc_pref sc_main_help_online_doc(sc_main_help+":online_doc", QKeySequence::UnknownKey)
const sc_pref sc_main_file_exit(sc_main_file+":exit", QKeySequence::Quit)
const sc_pref sc_main_file_new_file(sc_main_file+":new_file", QKeySequence::New)
const sc_pref sc_main_news_release_notes(sc_main_news+":release_notes", QKeySequence::UnknownKey)
const sc_pref sc_main_window_workspace(sc_main_window+":workspace", PRE+CTRL+Qt::Key_3)
const sc_pref sc_main_file_new_figure(sc_main_file+":new_figure", QKeySequence::UnknownKey)
const sc_pref sc_main_window_doc(sc_main_window+":doc", PRE+CTRL+Qt::Key_5)
const sc_pref sc_main_debug_step_over(sc_main_debug+":step_over", PRE+Qt::Key_F10)
const sc_pref sc_main_window_show_editor(sc_main_window+":show_editor", PRE+CTRL_SHIFT+Qt::Key_4)
const sc_pref sc_main_edit_set_path(sc_main_edit+":set_path", QKeySequence::UnknownKey)
const sc_pref sc_main_window_file_browser(sc_main_window+":file_browser", PRE+CTRL+Qt::Key_2)
const sc_pref sc_main_debug_continue(sc_main_debug+":continue", PRE+Qt::Key_F5)
const sc_pref sc_main_edit_clear_clipboard(sc_main_edit+":clear_clipboard", QKeySequence::UnknownKey)
const sc_pref sc_main_window_show_history(sc_main_window+":show_history", PRE+CTRL_SHIFT+Qt::Key_1)
const sc_pref sc_main_window_show_workspace(sc_main_window+":show_workspace", PRE+CTRL_SHIFT+Qt::Key_3)
const sc_pref sc_main_edit_clear_workspace(sc_main_edit+":clear_workspace", QKeySequence::UnknownKey)
const sc_pref sc_main_file_open_file(sc_main_file+":open_file", QKeySequence::Open)
const sc_pref sc_main_window_show_doc(sc_main_window+":show_doc", PRE+CTRL_SHIFT+Qt::Key_5)
const sc_pref sc_main_file_new_function(sc_main_file+":new_function", CTRL_SHIFT+Qt::Key_N)
const sc_pref sc_main_debug_step_into(sc_main_debug+":step_into", PRE+Qt::Key_F11)
const sc_pref sc_main_help_about(sc_main_help+":about", QKeySequence::UnknownKey)
const sc_pref sc_main_window_show_variable_editor(sc_main_window+":show_variable_editor", PRE+CTRL_SHIFT+Qt::Key_6)
const sc_pref sc_main_window_show_command(sc_main_window+":show_command", PRE+CTRL_SHIFT+Qt::Key_0)
const sc_pref sc_main_window_editor(sc_main_window+":editor", PRE+CTRL+Qt::Key_4)
const sc_pref sc_main_window_variable_editor(sc_main_window+":variable_editor", PRE+CTRL+Qt::Key_6)
const sc_pref sc_main_window_command(sc_main_window+":command", PRE+CTRL+Qt::Key_0)
const sc_pref sc_main_debug_quit(sc_main_debug+":quit", PRE+Qt::ShiftModifier+Qt::Key_F5)
const sc_pref sc_main_edit_copy(sc_main_edit+":copy", QKeySequence::Copy)
const sc_pref sc_main_help_ondisk_doc(sc_main_help+":ondisk_doc", QKeySequence::UnknownKey)
const sc_pref sc_main_help_developer(sc_main_help+":developer", QKeySequence::UnknownKey)
const gui_pref sc_prevent_rl_conflicts("shortcuts/prevent_readline_conflicts", QVariant(false))
const sc_pref sc_main_edit_undo(sc_main_edit+":undo", QKeySequence::Undo)
const sc_pref sc_main_edit_clear_command_window(sc_main_edit+":clear_command_window", QKeySequence::UnknownKey)
const sc_pref sc_main_window_reset(sc_main_window+":reset", QKeySequence::UnknownKey)
const sc_pref sc_main_window_previous_dock(sc_main_window+":previous_widget", PRE+CTRL_ALT+Qt::Key_P)
const sc_pref sc_main_help_contribute(sc_main_help+":contribute", QKeySequence::UnknownKey)
const sc_pref sc_main_window_history(sc_main_window+":history", PRE+CTRL+Qt::Key_1)
const gui_pref sc_prevent_rl_conflicts_menu("shortcuts/prevent_readline_conflicts_menu", QVariant(false))
const sc_pref sc_main_edit_preferences(sc_main_edit+":preferences", QKeySequence::UnknownKey)
const sc_pref sc_main_tools_show_profiler(sc_main_tools+":show_profiler", Qt::AltModifier+Qt::ShiftModifier+Qt::Key_P)
const sc_pref sc_main_help_packages(sc_main_help+":packages", QKeySequence::UnknownKey)
const sc_pref sc_main_file_save_workspace(sc_main_file+":save_workspace", QKeySequence::UnknownKey)
const sc_pref sc_main_edit_paste(sc_main_edit+":paste", QKeySequence::Paste)
const sc_pref sc_main_tools_resume_profiler(sc_main_tools+":resume_profiler", QKeySequence::UnknownKey)
const sc_pref sc_main_edit_find_in_files(sc_main_edit+":find_in_files", CTRL_SHIFT+Qt::Key_F)
const sc_pref sc_main_edit_select_all(sc_main_edit+":select_all", QKeySequence::SelectAll)
const sc_pref sc_main_window_show_file_browser(sc_main_window+":show_file_browser", PRE+CTRL_SHIFT+Qt::Key_2)
const sc_pref sc_main_edit_clear_history(sc_main_edit+":clear_history", QKeySequence::UnknownKey)
const sc_pref sc_main_debug_step_out(sc_main_debug+":step_out", PRE+Qt::ShiftModifier+Qt::Key_F11)
const sc_pref sc_main_news_community_news(sc_main_news+":community_news", QKeySequence::UnknownKey)
const sc_pref sc_main_tools_start_profiler(sc_main_tools+":start_profiler", CTRL_SHIFT+Qt::Key_P)
const sc_pref sc_main_help_report_bug(sc_main_help+":report_bug", QKeySequence::UnknownKey)
const sc_pref sc_main_file_load_workspace(sc_main_file+":load_workspace", QKeySequence::UnknownKey)
OCTGUI_API void get_screen_geometry(int &width, int &height)
Definition: gui-utils.cc:51
OCTAVE_EXPORT octave_value_list Fgenpath(const octave_value_list &args, int)
Definition: load-path.cc:2473
OCTAVE_EXPORT octave_value_list Faddpath(octave::interpreter &interp, const octave_value_list &args, int nargout)
Definition: load-path.cc:2652
OCTAVE_EXPORT octave_value_list Frmpath(octave::interpreter &interp, const octave_value_list &args, int nargout)
Definition: load-path.cc:2780
OCTAVE_EXPORT octave_value_list Fsave(octave::interpreter &interp, const octave_value_list &args, int nargout)
Definition: load-save.cc:1811
OCTAVE_EXPORT octave_value_list Fload(octave::interpreter &interp, const octave_value_list &args, int nargout)
Definition: load-save.cc:1656
octave_idx_type n
Definition: mx-inlines.cc:753
std::complex< double > w(std::complex< double > z, double relerr=0)
std::string toStdString(const QString &s)
QString fromStdString(const std::string &s)
OCTAVE_EXPORT octave_value_list Fbuiltin(octave::interpreter &interp, const octave_value_list &args, int nargout)
Definition: oct-parse.cc:10479
OCTAVE_EXPORT octave_value_list Ffeval(octave::interpreter &interp, const octave_value_list &args, int nargout)
Definition: oct-parse.cc:10447
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition: ovl.h:211
static uint32_t state[624]
Definition: randmtzig.cc:193
const QString key
const QVariant def
bool valid_identifier(const char *s)
Definition: utils.cc:78
OCTAVE_EXPORT octave_value_list Ffile_in_loadpath(octave::interpreter &interp, const octave_value_list &args, int)
Definition: utils.cc:569
OCTAVE_EXPORT octave_value_list Fexist(octave::interpreter &interp, const octave_value_list &args, int)
Definition: variables.cc:433
OCTAVE_EXPORT octave_value_list Fclear(octave::interpreter &interp, const octave_value_list &args, int)
Definition: variables.cc:1233
std::string octave_name_version_copyright_copying_warranty_and_bugs(bool html, const std::string &extra_info)
Definition: version.cc:100