GNU Octave  4.4.1
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) 2013-2018 John W. Eaton
4 Copyright (C) 2011-2018 Jacob Dawid
5 
6 This file is part of Octave.
7 
8 Octave is free software: you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if defined (HAVE_CONFIG_H)
25 # include "config.h"
26 #endif
27 
28 #include <QKeySequence>
29 #include <QApplication>
30 #include <QInputDialog>
31 #include <QLabel>
32 #include <QMenuBar>
33 #include <QMenu>
34 #include <QAction>
35 #include <QSettings>
36 #include <QStyle>
37 #include <QToolBar>
38 #include <QDesktopServices>
39 #include <QDesktopWidget>
40 #include <QFileDialog>
41 #include <QMessageBox>
42 #include <QIcon>
43 #include <QTextBrowser>
44 #include <QTextStream>
45 #include <QThread>
46 #include <QDateTime>
47 #include <QDebug>
48 #include <QTimer>
49 
50 #include <utility>
51 
52 #if defined (HAVE_QSCINTILLA)
53 # include "file-editor.h"
54 #endif
55 #include "main-window.h"
56 #include "settings-dialog.h"
57 #include "shortcut-manager.h"
58 
59 #include "Array.h"
60 #include "cmd-edit.h"
61 #include "url-transfer.h"
62 
63 #include "builtin-defun-decls.h"
64 #include "defaults.h"
65 #if defined (HAVE_QT_GRAPHICS)
66 # include "__init_qt__.h"
67 #endif
68 #include "interpreter-private.h"
69 #include "interpreter.h"
70 #include "oct-map.h"
71 #include "octave.h"
72 #include "symscope.h"
73 #include "utils.h"
74 #include "version.h"
75 
78 {
79 #if defined (HAVE_QSCINTILLA)
80  return new octave::file_editor (p);
81 #else
82  octave_unused_parameter (p);
83 
84  return 0;
85 #endif
86 }
87 
88 namespace octave
89 {
91  : QObject (), m_app_context (app_context)
92  { }
93 
95  {
96  // The application context owns the interpreter.
97 
98  interpreter& interp = m_app_context->create_interpreter ();
99 
100  int exit_status = 0;
101 
102  try
103  {
104  // Final initialization.
105 
106  interp.initialize ();
107 
108  if (interp.initialized ())
109  {
110  // The interpreter should be completely ready at this point so let
111  // the GUI know.
112 
113  emit octave_ready_signal ();
114 
115  // Start executing commands in the command window.
116 
117 #if defined (HAVE_QT_GRAPHICS)
118  // The qt graphics toolkit must be initialized before startup
119  // files are executed.
120 
121  symbol_table& symtab = interp.get_symbol_table ();
122 
124 
125  Fregister_graphics_toolkit (interp, ovl ("qt"));
126 #endif
127 
128  exit_status = interp.execute ();
129  }
130  }
131  catch (const exit_exception& ex)
132  {
133  exit_status = ex.exit_status ();
134  }
135 
136  // Whether or not initialization succeeds we need to clean up the
137  // interpreter once we are done with it.
138 
139  m_app_context->delete_interpreter ();
140 
141  emit octave_finished_signal (exit_status);
142  }
143 
145  : QMainWindow (p), m_app_context (app_context),
146  m_interpreter (new octave_interpreter (app_context)),
147  m_main_thread (new QThread ()), m_workspace_model (nullptr),
148  m_status_bar (nullptr), m_command_window (nullptr),
149  m_history_window (nullptr), m_file_browser_window (nullptr),
150  m_doc_browser_window (nullptr), m_editor_window (nullptr),
151  m_workspace_window (nullptr), m_variable_editor_window (nullptr),
152  m_settings_dlg (nullptr), m_find_files_dlg (nullptr),
153  m_release_notes_window (nullptr), m_community_news_window (nullptr),
154  m_octave_qt_link (nullptr), m_clipboard (QApplication::clipboard ()),
155  m_prevent_readline_conflicts (true), m_suppress_dbg_location (true),
156  m_start_gui (app_context && app_context->start_gui_p ()),
157  m_file_encoding (QString ())
158  {
159  if (m_start_gui)
160  {
162  m_status_bar = new QStatusBar ();
169  m_workspace_window = new workspace_view (this);
170  }
171 
172  // Initialize global Qt application metadata
173  QCoreApplication::setApplicationName ("GNU Octave");
174  QCoreApplication::setApplicationVersion (OCTAVE_VERSION);
175 #if defined (HAVE_QGUIAPPLICATION_SETDESKTOPFILENAME)
176  if (m_start_gui)
177  QGuiApplication::setDesktopFileName ("org.octave.Octave.desktop");
178 #endif
179 
181  m_active_editor = m_editor_window; // for connecting signals
182  if (! m_editor_window)
184 
185  QSettings *settings = resource_manager::get_settings ();
186 
187  bool connect_to_web = true;
188  QDateTime last_checked;
189  int serial = 0;
190  m_active_dock = nullptr;
191 
192  if (settings)
193  {
194  connect_to_web
195  = settings->value ("news/allow_web_connection", false).toBool ();
196 
197  last_checked
198  = settings->value ("news/last_time_checked", QDateTime ()).toDateTime ();
199 
200  serial = settings->value ("news/last_news_item", 0).toInt ();
201  }
202 
203  QDateTime current = QDateTime::currentDateTime ();
204  QDateTime one_day_ago = current.addDays (-1);
205 
206  if (m_start_gui && connect_to_web
207  && (! last_checked.isValid () || one_day_ago > last_checked))
209 
210  // We have to set up all our windows, before we finally launch octave.
211  construct ();
212 
213  connect (m_interpreter, SIGNAL (octave_ready_signal (void)),
214  this, SLOT (handle_octave_ready (void)));
215 
216  connect (m_interpreter, SIGNAL (octave_finished_signal (int)),
217  this, SLOT (handle_octave_finished (int)));
218 
219  connect (m_interpreter, SIGNAL (octave_finished_signal (int)),
220  m_main_thread, SLOT (quit (void)));
221 
222  connect (m_main_thread, SIGNAL (finished (void)),
223  m_main_thread, SLOT (deleteLater (void)));
224 
225  m_interpreter->moveToThread (m_main_thread);
226 
227  m_main_thread->start ();
228  }
229 
231  {
232  // Note that we don't delete m_main_thread here. That is handled by
233  // deleteLater slot that is called when the m_main_thread issues a
234  // finished signal.
235 
236  // Destroy the terminal first so that STDERR stream is redirected back
237  // to its original pipe to capture error messages at exit.
238 
239  delete m_editor_window; // first one for dialogs of modified editor-tabs
240  delete m_external_editor;
241  delete m_command_window;
242  delete m_workspace_window;
243  delete m_doc_browser_window;
244  delete m_file_browser_window;
245  delete m_history_window;
246  delete m_status_bar;
247  delete m_workspace_model;
249  delete m_interpreter;
250 
251  if (m_find_files_dlg)
252  {
253  delete m_find_files_dlg;
254  m_find_files_dlg = nullptr;
255  }
257  {
258  delete m_release_notes_window;
259  m_release_notes_window = nullptr;
260  }
261  if (m_settings_dlg)
262  {
263  delete m_settings_dlg;
264  m_settings_dlg = nullptr;
265  }
267  {
269  m_community_news_window = nullptr;
270  }
271  }
272 
274  {
275  return m_command_window->has_focus ();
276  }
277 
279  {
281  }
282 
283  // catch focus changes and determine the active dock widget
285  {
286  // If there is no new widget (e.g., when pressing <alt> and the global
287  // menu gets active, we can return immediately
288  if (! new_widget)
289  return;
290 
291  octave_dock_widget *dock = nullptr;
292  QWidget *w_new = new_widget; // get a copy of new focus widget
293  QWidget *start = w_new; // Save it as start of our search
294  int count = 0; // fallback to prevent endless loop
295 
297 
298  while (w_new && w_new != m_main_tool_bar && count < 100)
299  {
300  // Go through all dock widgets and check whether the current widget
301  // widget with focus is a child of one of it
302  foreach (octave_dock_widget *w, w_list)
303  {
304  if (w->isAncestorOf (w_new))
305  dock = w;
306  }
307 
308  if (dock)
309  break;
310 
311  // If not yet found (in case w_new is not a childs of its dock widget),
312  // test next widget in the focus chain
313  w_new = qobject_cast<QWidget *> (w_new->previousInFocusChain ());
314 
315  // Measures preventing an endless loop
316  if (w_new == start)
317  break; // We have arrived where we began ==> exit loop
318  count++; // Limited number of trials
319  }
320 
321  // editor needs extra handling
322  octave_dock_widget *edit_dock_widget
323  = static_cast<octave_dock_widget *> (m_editor_window);
324  // if new dock has focus, emit signal and store active focus
325  // except editor changes to a dialog (dock=0)
326  if ((dock || m_active_dock != edit_dock_widget) && (dock != m_active_dock))
327  {
328  // signal to all dock widgets for updating the style
329  emit active_dock_changed (m_active_dock, dock);
330 
331  QList<QDockWidget *> tabbed = tabifiedDockWidgets (dock);
332  if (tabbed.contains (m_active_dock))
334 
335  if (edit_dock_widget == dock)
336  emit editor_focus_changed (true);
337  else if (edit_dock_widget == m_active_dock)
338  emit editor_focus_changed (false);
339 
340  m_active_dock = dock;
341  }
342  }
343 
345  {
346  QSettings *settings = resource_manager::get_settings ();
347 
348  if (settings)
349  emit settings_changed (settings);
350  }
351 
352  void main_window::report_status_message (const QString& statusMessage)
353  {
354  m_status_bar->showMessage (statusMessage, 1000);
355  }
356 
358  {
359  QString file
360  = QFileDialog::getSaveFileName (this, tr ("Save Workspace As"), ".",
361  nullptr, nullptr,
362  QFileDialog::DontUseNativeDialog);
363 
364  if (! file.isEmpty ())
366  file.toStdString ());
367  }
368 
369  void main_window::handle_load_workspace_request (const QString& file_arg)
370  {
371  QString file = file_arg;
372 
373  if (file.isEmpty ())
374  file = QFileDialog::getOpenFileName (this, tr ("Load Workspace"), ".",
375  nullptr, nullptr,
376  QFileDialog::DontUseNativeDialog);
377 
378  if (! file.isEmpty ())
380  file.toStdString ());
381  }
382 
384  {
386  }
387 
389  {
391  }
392 
394  {
396  }
397 
399  {
402  else
403  emit undo_signal ();
404  }
405 
406  void main_window::handle_rename_variable_request (const QString& old_name,
407  const QString& new_name)
408 
409  {
410  name_pair names (old_name.toStdString (), new_name.toStdString ());
411 
413  names);
414  }
415 
416  void main_window::new_file (const QString& commands)
417  {
418  emit new_file_signal (commands);
419  }
420 
421  void main_window::open_file (const QString& file_name, int line)
422  {
423  if (line < 0)
424  emit open_file_signal (file_name);
425  else
426  emit open_file_signal (file_name, QString (), line);
427  }
428 
429  void main_window::edit_mfile (const QString& name, int line)
430  {
431  handle_edit_mfile_request (name, QString (), QString (), line);
432  }
433 
435  {
436  QDesktopServices::openUrl (
437  QUrl ("https://octave.org/doc/interpreter/index.html"));
438  }
439 
441  {
443  {
444  std::string news_file = config::oct_etc_dir () + "/NEWS";
445 
446  QString news;
447 
448  QFile *file = new QFile (QString::fromStdString (news_file));
449  if (file->open (QFile::ReadOnly))
450  {
451  QTextStream *stream = new QTextStream (file);
452  news = stream->readAll ();
453  if (! news.isEmpty ())
454  {
455  // Convert '<', '>' which would be interpreted as HTML
456  news.replace ("<", "&lt;");
457  news.replace (">", "&gt;");
458  // Add HTML tags for pre-formatted text
459  news.prepend ("<pre>");
460  news.append ("</pre>");
461  }
462  else
463  news = (tr ("The release notes file '%1' is empty.")
464  . arg (QString::fromStdString (news_file)));
465  }
466  else
467  news = (tr ("The release notes file '%1' cannot be read.")
468  . arg (QString::fromStdString (news_file)));
469 
471 
473  browser->setText (news);
474 
475  QVBoxLayout *vlayout = new QVBoxLayout;
476  vlayout->addWidget (browser);
477 
478  m_release_notes_window->setLayout (vlayout);
479  m_release_notes_window->setWindowTitle (tr ("Octave Release Notes"));
480 
481  browser->document ()->adjustSize ();
482 
483  // center the window on the screen where octave is running
484  QDesktopWidget *m_desktop = QApplication::desktop ();
485  int screen = m_desktop->screenNumber (this); // screen of the main window
486  QRect screen_geo = m_desktop->availableGeometry (screen);
487  int win_x = screen_geo.width (); // width of the screen
488  int win_y = screen_geo.height (); // height of the screen
489  int reln_x = std::min (720, win_x-80); // desired width of release notes
490  int reln_y = std::min (740, win_y-80); // desired height of release notes
491  m_release_notes_window->resize (reln_x, reln_y); // set size
492  m_release_notes_window->move (20, 0); // move to the top left corner
493  }
494 
495  if (! m_release_notes_window->isVisible ())
496  m_release_notes_window->show ();
497  else if (m_release_notes_window->isMinimized ())
498  m_release_notes_window->showNormal ();
499 
500  m_release_notes_window->setWindowIcon (QIcon (m_release_notes_icon));
501 
502  m_release_notes_window->raise ();
503  m_release_notes_window->activateWindow ();
504  }
505 
507  {
508  QSettings *settings = resource_manager::get_settings ();
509 
510  bool connect_to_web
511  = (settings
512  ? settings->value ("news/allow_web_connection", false).toBool ()
513  : true);
514 
515  QString base_url = "https://octave.org";
516  QString page = "community-news.html";
517 
518  QThread *worker_thread = new QThread;
519 
520  news_reader *reader = new news_reader (base_url, page, serial,
521  connect_to_web);
522 
523  reader->moveToThread (worker_thread);
524 
525  connect (reader, SIGNAL (display_news_signal (const QString&)),
526  this, SLOT (display_community_news (const QString&)));
527 
528  connect (worker_thread, SIGNAL (started (void)),
529  reader, SLOT (process (void)));
530 
531  connect (reader, SIGNAL (finished (void)), worker_thread, SLOT (quit (void)));
532 
533  connect (reader, SIGNAL (finished (void)), reader, SLOT (deleteLater (void)));
534 
535  connect (worker_thread, SIGNAL (finished (void)),
536  worker_thread, SLOT (deleteLater (void)));
537 
538  worker_thread->start ();
539  }
540 
541  void main_window::display_community_news (const QString& news)
542  {
544  {
546 
548 
549  browser->setHtml (news);
550  browser->setObjectName ("OctaveNews");
551  browser->setOpenExternalLinks (true);
552 
553  QVBoxLayout *vlayout = new QVBoxLayout;
554 
555  vlayout->addWidget (browser);
556 
557  m_community_news_window->setLayout (vlayout);
558  m_community_news_window->setWindowTitle (tr ("Octave Community News"));
559 
560  // center the window on the screen where octave is running
561  QDesktopWidget *m_desktop = QApplication::desktop ();
562  int screen = m_desktop->screenNumber (this); // screen of the main window
563  QRect screen_geo = m_desktop->availableGeometry (screen);
564  int win_x = screen_geo.width (); // width of the screen
565  int win_y = screen_geo.height (); // height of the screen
566  int news_x = std::min (640, win_x-80); // desired width of news window
567  int news_y = std::min (480, win_y-80); // desired height of news window
568  m_community_news_window->resize (news_x, news_y); // set size and center
569  m_community_news_window->move ((win_x - m_community_news_window->width ())/2,
570  (win_y - m_community_news_window->height ())/2);
571  }
572 
573  if (! m_community_news_window->isVisible ())
574  m_community_news_window->show ();
575  else if (m_community_news_window->isMinimized ())
576  m_community_news_window->showNormal ();
577 
578  // same icon as release notes
579  m_community_news_window->setWindowIcon (QIcon (m_release_notes_icon));
580 
581  m_community_news_window->raise ();
582  m_community_news_window->activateWindow ();
583  }
584 
586  {
587  QDesktopServices::openUrl (QUrl ("https://octave.org/bugs.html"));
588  }
589 
591  {
592  QDesktopServices::openUrl (QUrl ("https://octave.org/packages.html"));
593  }
594 
596  {
597  QDesktopServices::openUrl (QUrl ("https://octave.org/contribute.html"));
598  }
599 
601  {
602  QDesktopServices::openUrl (QUrl ("https://octave.org/donate.html"));
603  }
604 
605  void main_window::process_settings_dialog_request (const QString& desired_tab)
606  {
607  if (m_settings_dlg) // m_settings_dlg is a guarded pointer!
608  {
609  // here the dialog is still open and called once again
610  if (! desired_tab.isEmpty ())
611  m_settings_dlg->show_tab (desired_tab);
612  return;
613  }
614 
615  m_settings_dlg = new settings_dialog (this, desired_tab);
616 
617  connect (m_settings_dlg, SIGNAL (apply_new_settings (void)),
618  this, SLOT (request_reload_settings (void)));
619 
620  m_settings_dlg->setModal (false);
621  m_settings_dlg->setAttribute (Qt::WA_DeleteOnClose);
622  m_settings_dlg->show ();
623  }
624 
626  bool remove_file)
627  {
628  QClipboard *clipboard = QApplication::clipboard ();
629 
630  QImage img (file);
631 
632  if (img.isNull ())
633  {
634  // Report error?
635  return;
636  }
637 
638  clipboard->setImage (img);
639 
640  if (remove_file)
641  QFile::remove (file);
642  }
643 
645  {
648 
649  QMessageBox::about (this, tr ("About Octave"),
651  }
652 
653  void main_window::notice_settings (const QSettings *settings)
654  {
655  // QSettings pointer is checked before emitting.
656 
657  // the widget's icons (when floating)
658  QString icon_set
659  = settings->value ("DockWidgets/widget_icon_set", "NONE").toString ();
660 
661  static struct
662  {
663  QString name;
664  QString path;
665  }
666 
667  widget_icon_data[] =
668  {
669  // array of possible icon sets (name, path (complete for NONE))
670  // the first entry here is the default!
671  {"NONE", ":/actions/icons/logo.png"},
672  {"GRAPHIC", ":/actions/icons/graphic_logo_"},
673  {"LETTER", ":/actions/icons/letter_logo_"},
674  {"", ""} // end marker has empty name
675  };
676 
677  int count = 0;
678  int icon_set_found = 0; // default
679 
680  while (! widget_icon_data[count].name.isEmpty ())
681  {
682  // while not end of data
683  if (widget_icon_data[count].name == icon_set)
684  {
685  // data of desired icon set found
686  icon_set_found = count;
687  break;
688  }
689  count++;
690  }
691 
692  QString icon;
693  foreach (octave_dock_widget *widget, dock_widget_list ())
694  {
695  QString name = widget->objectName ();
696  if (! name.isEmpty ())
697  {
698  // if children has a name
699  icon = widget_icon_data[icon_set_found].path; // prefix | octave-logo
700  if (widget_icon_data[icon_set_found].name != "NONE")
701  icon += name + ".png"; // add widget name and ext.
702  widget->setWindowIcon (QIcon (icon));
703  }
704  }
705  if (widget_icon_data[icon_set_found].name != "NONE")
706  m_release_notes_icon = widget_icon_data[icon_set_found].path
707  + "ReleaseWidget.png";
708  else
709  m_release_notes_icon = ":/actions/icons/logo.png";
710 
711  int icon_size_settings = settings->value ("toolbar_icon_size",0).toInt ();
712  QStyle *st = style ();
713  int icon_size = st->pixelMetric (QStyle::PM_ToolBarIconSize);
714 
715  if (icon_size_settings == 1)
716  icon_size = st->pixelMetric (QStyle::PM_LargeIconSize);
717  else if (icon_size_settings == -1)
718  icon_size = st->pixelMetric (QStyle::PM_SmallIconSize);
719 
720  m_main_tool_bar->setIconSize (QSize (icon_size,icon_size));
721 
722  if (settings->value ("show_status_bar",true).toBool ())
723  m_status_bar->show ();
724  else
725  m_status_bar->hide ();
726 
728  = settings->value ("shortcuts/prevent_readline_conflicts", true).toBool ();
729 
731  = ! settings->value ("terminal/print_debug_location", false).toBool ();
732 
734 
735  emit active_dock_changed (nullptr, m_active_dock); // update dock widget styles
736 
740 
741 
742  // Set cursor blinking depending on the settings
743  // Cursor blinking: consider old terminal related setting if not yet set
744  // TODO: This pref. can be deprecated / removed if Qt adds support for
745  // getting the cursor blink preferences from all OS environments
746  bool cursor_blinking;
747 
748  if (settings->contains ("cursor_blinking"))
749  cursor_blinking = settings->value ("cursor_blinking",true).toBool ();
750  else
751  cursor_blinking = settings->value ("terminal/cursorBlinking",true).toBool ();
752 
753  if (cursor_blinking)
754  QApplication::setCursorFlashTime (1000); // 1000 ms flash time
755  else
756  QApplication::setCursorFlashTime (0); // no flashing
757 
758  }
759 
761  {
762  bool closenow = true;
763 
764  if (m_start_gui)
765  {
766  QSettings *settings = resource_manager::get_settings ();
767 
768  if (settings->value ("prompt_to_exit", false).toBool ())
769  {
770  int ans = QMessageBox::question (this, tr ("Octave"),
771  tr ("Are you sure you want to exit Octave?"),
772  (QMessageBox::Ok
773  | QMessageBox::Cancel),
774  QMessageBox::Ok);
775 
776  if (ans != QMessageBox::Ok)
777  closenow = false;
778  }
779 
780 #if defined (HAVE_QSCINTILLA)
781  if (closenow)
782  closenow = m_editor_window->check_closing ();
783 #endif
784  }
785 
786  // Wait for link thread to go to sleep state.
788 
790 
792 
793  // Awake the worker thread so that it continues shutting down (or not).
795  }
796 
798  {
799  // Find files dialog is constructed dynamically, not at time of main_window
800  // construction. Connecting it to qApp aboutToQuit signal would have
801  // caused it to run after QSettings deleted.
802  if (m_find_files_dlg)
804 
805  write_settings ();
806  }
807 
809  {
810  QSettings *settings = resource_manager::get_default_settings ();
811 
812  set_window_layout (settings);
813  showNormal (); // make sure main window is not minimized
815  }
816 
817  void main_window::change_directory (const QString& dir)
818  {
819  // Remove existing entry, if any, then add new directory at top and
820  // mark it as the current directory. Finally, update the file list
821  // widget.
822 
823  int index = m_current_directory_combo_box->findText (dir);
824 
825  if (index >= 0)
826  m_current_directory_combo_box->removeItem (index);
827 
828  m_current_directory_combo_box->insertItem (0, dir);
829  m_current_directory_combo_box->setCurrentIndex (0);
830  }
831 
833  {
834  QString dir
835  = QFileDialog::getExistingDirectory (this, tr ("Browse directories"), nullptr,
836  QFileDialog::ShowDirsOnly |
837  QFileDialog::DontUseNativeDialog);
838 
840 
841  // FIXME: on Windows systems, the command window freezes after the
842  // previous actions. Forcing the focus appears to unstick it.
843 
845  }
846 
848  {
849  // Change to dir if it is an existing directory.
850 
851  QString xdir = (dir.isEmpty () ? "." : dir);
852 
853  QFileInfo fileInfo (xdir);
854 
855  if (fileInfo.exists () && fileInfo.isDir ())
857  xdir.toStdString ());
858  }
859 
861  {
863  }
864 
865  // Slot that is called if return is pressed in the line edit of the
866  // combobox to change to a new directory or a directory that is already
867  // in the drop down list.
868 
870  {
871  // Get new directory name, and change to it if it is new. Otherwise,
872  // the combo box will triggers the "activated" signal to change to the
873  // directory.
874 
875  QString dir = m_current_directory_combo_box->currentText ();
876 
877  int index = m_current_directory_combo_box->findText (dir);
878 
879  if (index < 0)
881  }
882 
884  {
886 
887  m_cmd_queue.add_cmd (cmd);
888 
891  }
892 
893  void main_window::run_file_in_terminal (const QFileInfo& info)
894  {
895  octave_cmd_eval *cmd = new octave_cmd_eval (info);
896 
897  m_cmd_queue.add_cmd (cmd);
898 
901  }
902 
904  {
906  }
907 
909  {
910  setWindowTitle ("Octave (Debugging)");
911 
912  m_debug_continue->setEnabled (true);
913  m_debug_step_into->setEnabled (true);
914  m_debug_step_over->setEnabled (true);
915  m_debug_step_out->setEnabled (true);
916  m_debug_quit->setEnabled (true);
917 
918 #if defined (HAVE_QSCINTILLA)
920 #endif
921  }
922 
924  {
925  setWindowTitle ("Octave");
926 
927  m_debug_continue->setEnabled (false);
928  m_debug_step_into->setEnabled (false);
929  m_debug_step_over->setEnabled (false);
930  m_debug_step_out->setEnabled (false);
931  m_debug_quit->setEnabled (false);
932 
933 #if defined (HAVE_QSCINTILLA)
935 #endif
936  }
937 
939  {
940  octave_cmd_debug *cmd
942  m_cmd_queue.add_cmd (cmd);
943  }
944 
946  {
948  m_cmd_queue.add_cmd (cmd);
949  }
950 
952  {
953  octave_cmd_debug *cmd
955  m_cmd_queue.add_cmd (cmd);
956  }
957 
959  {
961  m_cmd_queue.add_cmd (cmd);
962  }
963 
965  {
966  octave_cmd_debug *cmd
968  m_cmd_queue.add_cmd (cmd);
969  }
970 
971  //
972  // Functions related to file editing
973  //
974  // These are moved from editor to here for also using them when octave
975  // is built without qscintilla
976  //
978  {
979  // Open file isn't a file_editor_tab or editor function since the file
980  // might be opened in an external editor. Hence, functionality is here.
981 
982  QSettings *settings = resource_manager::get_settings ();
983  bool is_internal = m_editor_window
984  && ! settings->value ("useCustomFileEditor",false).toBool ();
985 
986  // Create a NonModal message.
987  QWidget *p = this;
988  if (is_internal)
989  p = m_editor_window;
990  QFileDialog *fileDialog = new QFileDialog (p);
991  fileDialog->setNameFilter (tr ("Octave Files (*.m);;All Files (*)"));
992 
993  // Giving trouble under KDE (problem is related to Qt signal handling on unix,
994  // see https://bugs.kde.org/show_bug.cgi?id=260719 ,
995  // it had/has no effect on Windows, though)
996  fileDialog->setOption (QFileDialog::DontUseNativeDialog, true);
997 
998  // define a new grid layout with the extra elements
999  QGridLayout *extra = new QGridLayout (fileDialog);
1000  QFrame *separator = new QFrame (fileDialog);
1001  separator->setFrameShape (QFrame::HLine); // horizontal line as separator
1002  separator->setFrameStyle (QFrame::Sunken);
1003 
1004  if (is_internal)
1005  {
1006  // combo box for encoding, only when using the internal editor
1007  QLabel *label_enc = new QLabel (tr ("File Encoding:"));
1008  QComboBox *combo_enc = new QComboBox ();
1010  m_file_encoding = QString (); // default
1011 
1012  // track changes in the combo boxes
1013  connect (combo_enc, SIGNAL (currentIndexChanged (QString)),
1014  this, SLOT (set_file_encoding (QString)));
1015 
1016  // build the extra grid layout
1017  extra->addWidget (separator,0,0,1,3);
1018  extra->addWidget (label_enc,1,0);
1019  extra->addWidget (combo_enc,1,1);
1020  extra->addItem (new QSpacerItem (1,20,QSizePolicy::Expanding,
1021  QSizePolicy::Fixed), 1,2);
1022 
1023  // and add the extra grid layout to the dialog's layout
1024  QGridLayout *dialog_layout = dynamic_cast<QGridLayout *> (
1025  fileDialog->layout ());
1026  dialog_layout->addLayout (extra,dialog_layout->rowCount (),0,
1027  1,dialog_layout->columnCount ());
1028  }
1029 
1030  fileDialog->setAcceptMode (QFileDialog::AcceptOpen);
1031  fileDialog->setViewMode (QFileDialog::Detail);
1032  fileDialog->setFileMode (QFileDialog::ExistingFiles);
1033  fileDialog->setDirectory (m_current_directory_combo_box->itemText (0));
1034 
1035  connect (fileDialog, SIGNAL (filesSelected (const QStringList&)),
1036  this, SLOT (request_open_files (const QStringList&)));
1037 
1038  fileDialog->setWindowModality (Qt::NonModal);
1039  fileDialog->setAttribute (Qt::WA_DeleteOnClose);
1040  fileDialog->show ();
1041  }
1042 
1043  // Create a new script
1045  {
1046  emit new_file_signal (commands);
1047  }
1048 
1049  // Create a new function and open it
1051  {
1052  bool ok;
1053  // Get the name of the new function: Parent of the input dialog is the
1054  // editor window or the main window. The latter is chosen, if a custom
1055  // editor is used or qscintilla is not available
1057  QSettings *settings = resource_manager::get_settings ();
1058  if (! p || settings->value ("useCustomFileEditor",false).toBool ())
1059  p = this;
1060  QString new_name = QInputDialog::getText (p, tr ("New Function"),
1061  tr ("New function name:\n"), QLineEdit::Normal, "", &ok);
1062 
1063  if (ok && new_name.length () > 0)
1064  {
1065  // append suffix if it not already exists
1066  if (new_name.rightRef (2) != ".m")
1067  new_name.append (".m");
1068  // check whether new files are created without prompt
1069  if (! settings->value ("editor/create_new_file",false).toBool ())
1070  {
1071  // no, so enable this settings and wait for end of new file loading
1072  settings->setValue ("editor/create_new_file",true);
1073  connect (m_editor_window, SIGNAL (file_loaded_signal (void)),
1074  this, SLOT (restore_create_file_setting (void)));
1075  }
1076  // start the edit command
1077  execute_command_in_terminal ("edit " + new_name);
1078  }
1079  }
1080 
1082  const QString& ffile,
1083  const QString& curr_dir,
1084  int line)
1085  {
1086  interpreter& interp
1087  = __get_interpreter__ ("main_window::clear_workspace_callback");
1088 
1089  // Is it a regular function within the search path? (Call __which__)
1090  octave_value_list fct = F__which__ (interp, ovl (fname.toStdString ()),0);
1091  octave_map map = fct(0).map_value ();
1092 
1093  QString type = QString::fromStdString (
1094  map.contents ("type").data ()[0].string_value ());
1095  QString name = QString::fromStdString (
1096  map.contents ("name").data ()[0].string_value ());
1097 
1098  QString message = QString ();
1099  QString filename = QString ();
1100 
1101  if (type == QString ("built-in function"))
1102  {
1103  // built in function: can't edit
1104  message = tr ("%1 is a built-in function");
1105  }
1106  else if (type.isEmpty ())
1107  {
1108  // function not known to octave -> try directory of edited file
1109  // get directory
1110  QDir dir;
1111  if (ffile.isEmpty ())
1112  {
1113  if (curr_dir.isEmpty ())
1114  dir = QDir (m_current_directory_combo_box->itemText (0));
1115  else
1116  dir = QDir (curr_dir);
1117  }
1118  else
1119  dir = QDir (QFileInfo (ffile).canonicalPath ());
1120 
1121  // function not known to octave -> try directory of edited file
1122  QFileInfo file = QFileInfo (dir, fname + ".m");
1123 
1124  if (file.exists ())
1125  {
1126  filename = file.canonicalFilePath (); // local file exists
1127  }
1128  else
1129  {
1130  // local file does not exist -> try private directory
1131  file = QFileInfo (ffile);
1132  file = QFileInfo (QDir (file.canonicalPath () + "/private"),
1133  fname + ".m");
1134 
1135  if (file.exists ())
1136  {
1137  filename = file.canonicalFilePath (); // private function exists
1138  }
1139  else
1140  {
1141  message = tr ("Can not find function %1"); // no file found
1142  }
1143  }
1144  }
1145 
1146  if (! message.isEmpty ())
1147  {
1148  QMessageBox *msgBox
1149  = new QMessageBox (QMessageBox::Critical,
1150  tr ("Octave Editor"),
1151  message.arg (name),
1152  QMessageBox::Ok, this);
1153 
1154  msgBox->setWindowModality (Qt::NonModal);
1155  msgBox->setAttribute (Qt::WA_DeleteOnClose);
1156  msgBox->show ();
1157  return;
1158  }
1159 
1160  if (filename.isEmpty ())
1162  map.contents ("file").data ()[0].string_value ());
1163 
1164  if (! filename.endsWith (".m"))
1165  filename.append (".m");
1166 
1167  emit open_file_signal (filename, QString (), line); // default encoding
1168  }
1169 
1171  int line)
1172  {
1173  bool cmd_focus = command_window_has_focus ();
1174 
1176 
1177  if (cmd_focus)
1179  }
1180 
1182  int line)
1183  {
1184  bool cmd_focus = command_window_has_focus ();
1185 
1187 
1188  if (cmd_focus)
1190  }
1191 
1193  const QString& file,
1194  int line,
1195  const QString& cond)
1196  {
1197  bool cmd_focus = command_window_has_focus ();
1198 
1199  emit update_breakpoint_marker_signal (insert, file, line, cond);
1200 
1201  if (cmd_focus)
1203  }
1204 
1206  {
1207  QSettings *settings = resource_manager::get_settings ();
1208 
1209  if (! settings)
1210  {
1211  qDebug ("Error: QSettings pointer from resource manager is NULL.");
1212  return;
1213  }
1214 
1215  set_window_layout (settings);
1216 
1217  // restore the list of the last directories
1218  QStringList curr_dirs
1219  = settings->value ("MainWindow/current_directory_list").toStringList ();
1220  for (int i=0; i < curr_dirs.size (); i++)
1221  {
1222  m_current_directory_combo_box->addItem (curr_dirs.at (i));
1223  }
1224  emit settings_changed (settings);
1225  }
1226 
1228  {
1229  emit init_terminal_size_signal ();
1230  }
1231 
1232  void main_window::set_window_layout (QSettings *settings)
1233  {
1234  restoreState (settings->value ("MainWindow/windowState").toByteArray ());
1235  restoreGeometry (settings->value ("MainWindow/geometry").toByteArray ());
1236 
1237  // Restore the geometry of all dock-widgets
1238  foreach (octave_dock_widget *widget, dock_widget_list ())
1239  {
1240  QString name = widget->objectName ();
1241 
1242  if (! name.isEmpty ())
1243  {
1244  bool floating = settings->value
1245  ("DockWidgets/" + name + "Floating", false).toBool ();
1246  bool visible = settings->value
1247  ("DockWidgets/" + name + "Visible", true).toBool ();
1248 
1249  // If floating, make window from widget.
1250  if (floating)
1251  {
1252  widget->make_window ();
1253 
1254  if (visible)
1255  {
1256  if (settings->value ("DockWidgets/" + widget->objectName ()
1257  + "_minimized").toBool ())
1258  widget->showMinimized ();
1259  else
1260  widget->setVisible (true);
1261  }
1262  }
1263  else // not floating
1264  {
1265  if (! widget->parent ()) // should not be floating but is
1266  widget->make_widget (false); // no docking, just reparent
1267 
1268  widget->make_widget ();
1269  widget->setVisible (visible); // not floating -> show
1270  }
1271  }
1272  }
1273 
1274  show ();
1275  }
1276 
1278  {
1279  QSettings *settings = resource_manager::get_settings ();
1280  if (! settings)
1281  {
1282  qDebug ("Error: QSettings pointer from resource manager is NULL.");
1283  return;
1284  }
1285 
1286  settings->setValue ("MainWindow/geometry", saveGeometry ());
1287  settings->setValue ("MainWindow/windowState", saveState ());
1288  // write the list of recent used directories
1289  QStringList curr_dirs;
1290  for (int i=0; i<m_current_directory_combo_box->count (); i++)
1291  {
1292  curr_dirs.append (m_current_directory_combo_box->itemText (i));
1293  }
1294  settings->setValue ("MainWindow/current_directory_list", curr_dirs);
1295  settings->sync ();
1296  }
1297 
1298  // Connecting the signals emitted when the visibility of a widget changes.
1299  // This has to be done after the window is shown (see octave-gui.cc)
1301  {
1302  foreach (octave_dock_widget *widget, dock_widget_list ())
1303  widget->connect_visibility_changed ();
1304 
1305 #if defined (HAVE_QSCINTILLA)
1307 #endif
1308  }
1309 
1311  {
1312  if (m_current_directory_combo_box->hasFocus ())
1313  {
1314  QLineEdit *edit = m_current_directory_combo_box->lineEdit ();
1315  if (edit && edit->hasSelectedText ())
1316  {
1317  QClipboard *clipboard = QApplication::clipboard ();
1318  clipboard->setText (edit->selectedText ());
1319  }
1320  }
1321  else
1322  emit copyClipboard_signal ();
1323  }
1324 
1326  {
1327  if (m_current_directory_combo_box->hasFocus ())
1328  {
1329  QLineEdit *edit = m_current_directory_combo_box->lineEdit ();
1330  QClipboard *clipboard = QApplication::clipboard ();
1331  QString str = clipboard->text ();
1332  if (edit && str.length () > 0)
1333  {
1334  edit->insert (str);
1335  }
1336  }
1337  else
1338  emit pasteClipboard_signal ();
1339  }
1340 
1342  {
1343  if (m_current_directory_combo_box->hasFocus ())
1344  {
1345  QLineEdit *edit = m_current_directory_combo_box->lineEdit ();
1346  if (edit)
1347  {
1348  edit->selectAll ();
1349  }
1350  }
1351  else
1352  emit selectAll_signal ();
1353  }
1354 
1355  // Connect the signals emitted when the Octave thread wants to create
1356  // a dialog box of some sort. Perhaps a better place for this would be
1357  // as part of the QUIWidgetCreator class. However, mainWindow currently
1358  // is not a global variable and not accessible for connecting.
1359 
1361  {
1362  connect (&uiwidget_creator,
1363  SIGNAL (create_dialog (const QString&, const QString&,
1364  const QString&, const QStringList&,
1365  const QString&, const QStringList&)),
1366  this,
1367  SLOT (handle_create_dialog (const QString&, const QString&,
1368  const QString&, const QStringList&,
1369  const QString&, const QStringList&)));
1370 
1371  // Register QIntList so that list of ints may be part of a signal.
1372  qRegisterMetaType<QIntList> ("QIntList");
1373  connect (&uiwidget_creator,
1374  SIGNAL (create_listview (const QStringList&, const QString&,
1375  int, int, const QIntList&,
1376  const QString&, const QStringList&,
1377  const QString&, const QString&)),
1378  this,
1379  SLOT (handle_create_listview (const QStringList&, const QString&,
1380  int, int, const QIntList&,
1381  const QString&, const QStringList&,
1382  const QString&, const QString&)));
1383 
1384  // Register QFloatList so that list of floats may be part of a signal.
1385  qRegisterMetaType<QFloatList> ("QFloatList");
1386  connect (&uiwidget_creator,
1387  SIGNAL (create_inputlayout (const QStringList&, const QString&,
1388  const QFloatList&, const QFloatList&,
1389  const QStringList&)),
1390  this,
1391  SLOT (handle_create_inputlayout (const QStringList&, const QString&,
1392  const QFloatList&,
1393  const QFloatList&,
1394  const QStringList&)));
1395 
1396  connect (&uiwidget_creator,
1397  SIGNAL (create_filedialog (const QStringList &,const QString&,
1398  const QString&, const QString&,
1399  const QString&)),
1400  this,
1401  SLOT (handle_create_filedialog (const QStringList &, const QString&,
1402  const QString&, const QString&,
1403  const QString&)));
1404  }
1405 
1406  // Create a message dialog with specified string, buttons and decorative
1407  // text.
1408 
1410  const QString& title,
1411  const QString& icon,
1412  const QStringList& button,
1413  const QString& defbutton,
1414  const QStringList& role)
1415  {
1416  MessageDialog *message_dialog = new MessageDialog (message, title, icon,
1417  button, defbutton, role);
1418  message_dialog->setAttribute (Qt::WA_DeleteOnClose);
1419  message_dialog->show ();
1420  }
1421 
1422  // Create a list dialog with specified list, initially selected, mode,
1423  // view size and decorative text.
1424 
1425  void main_window::handle_create_listview (const QStringList& list,
1426  const QString& mode,
1427  int wd, int ht,
1428  const QIntList& initial,
1429  const QString& name,
1430  const QStringList& prompt,
1431  const QString& ok_string,
1432  const QString& cancel_string)
1433  {
1434  ListDialog *list_dialog = new ListDialog (list, mode, wd, ht,
1435  initial, name, prompt,
1436  ok_string, cancel_string);
1437 
1438  list_dialog->setAttribute (Qt::WA_DeleteOnClose);
1439  list_dialog->show ();
1440  }
1441 
1442  // Create an input dialog with specified prompts and defaults, title and
1443  // row/column size specifications.
1444  void main_window::handle_create_inputlayout (const QStringList& prompt,
1445  const QString& title,
1446  const QFloatList& nr,
1447  const QFloatList& nc,
1448  const QStringList& defaults)
1449  {
1450  InputDialog *input_dialog = new InputDialog (prompt, title, nr, nc,
1451  defaults);
1452 
1453  input_dialog->setAttribute (Qt::WA_DeleteOnClose);
1454  input_dialog->show ();
1455  }
1456 
1457  void main_window::handle_create_filedialog (const QStringList& filters,
1458  const QString& title,
1459  const QString& filename,
1460  const QString& dirname,
1461  const QString& multimode)
1462  {
1463  FileDialog *file_dialog = new FileDialog (filters, title, filename,
1464  dirname, multimode);
1465 
1466  file_dialog->setAttribute (Qt::WA_DeleteOnClose);
1467  file_dialog->show ();
1468  }
1469 
1470  void main_window::handle_show_doc (const QString& file)
1471  {
1472  m_doc_browser_window->setVisible (true);
1473  emit show_doc_signal (file);
1474  }
1475 
1477  {
1478  emit register_doc_signal (file);
1479  }
1480 
1482  {
1483  emit unregister_doc_signal (file);
1484  }
1485 
1487  {
1488  // actions after the startup files are executed
1489  QSettings *settings = resource_manager::get_settings ();
1490 
1491  QDir startup_dir = QDir (); // current octave dir after startup
1492 
1493  if (settings)
1494  {
1495  if (settings->value ("restore_octave_dir").toBool ())
1496  {
1497  // restore last dir from previous session
1498  QStringList curr_dirs
1499  = settings->value ("MainWindow/current_directory_list").toStringList ();
1500  startup_dir
1501  = QDir (curr_dirs.at (0)); // last dir in previous session
1502  }
1503  else if (! settings->value ("octave_startup_dir").toString ().isEmpty ())
1504  {
1505  // do not restore but there is a startup dir configured
1506  startup_dir
1507  = QDir (settings->value ("octave_startup_dir").toString ());
1508  }
1509  }
1510 
1511  if (! startup_dir.exists ())
1512  {
1513  // the configured startup dir does not exist, take actual one
1514  startup_dir = QDir ();
1515  }
1516 
1517  set_current_working_directory (startup_dir.absolutePath ());
1518 
1519  if (m_editor_window)
1520  {
1521 #if defined (HAVE_QSCINTILLA)
1522  // Octave ready, determine whether to create an empty script.
1523  // This can not be done when the editor is created because all functions
1524  // must be known for the lexer's auto completion informations
1525  m_editor_window->empty_script (true, false);
1526  m_editor_window->restore_session (settings);
1527 #endif
1528  }
1529 
1530  if (m_start_gui)
1531  focus_command_window (); // make sure that the command window has focus
1532  }
1533 
1535  {
1536  qApp->exit (exit_status);
1537  }
1538 
1539  void main_window::find_files (const QString& start_dir)
1540  {
1541 
1542  if (! m_find_files_dlg)
1543  {
1544  m_find_files_dlg = new find_files_dialog (this);
1545 
1546  connect (m_find_files_dlg, SIGNAL (finished (int)),
1547  this, SLOT (find_files_finished (int)));
1548 
1549  connect (m_find_files_dlg, SIGNAL (dir_selected (const QString &)),
1551  SLOT (set_current_directory (const QString&)));
1552 
1553  connect (m_find_files_dlg, SIGNAL (file_selected (const QString &)),
1554  this, SLOT (open_file (const QString &)));
1555 
1556  m_find_files_dlg->setWindowModality (Qt::NonModal);
1557  }
1558 
1559  if (! m_find_files_dlg->isVisible ())
1560  {
1561  m_find_files_dlg->show ();
1562  }
1563 
1564  m_find_files_dlg->set_search_dir (start_dir);
1565 
1566  m_find_files_dlg->activateWindow ();
1567 
1568  }
1569 
1570  void main_window::set_global_shortcuts (bool set_shortcuts)
1571  {
1572  // this slot is called when the terminal gets/loses focus
1573 
1574  // return if the user don't want to use readline shortcuts
1576  return;
1577 
1578  if (set_shortcuts)
1579  {
1580  // terminal loses focus: set the global shortcuts
1582  }
1583  else
1584  {
1585  // terminal gets focus: disable some shortcuts
1586  QKeySequence no_key = QKeySequence ();
1587 
1588  // file menu
1589  m_open_action->setShortcut (no_key);
1590  m_new_script_action->setShortcut (no_key);
1591  m_new_function_action->setShortcut (no_key);
1592  m_new_function_action->setShortcut (no_key);
1593  m_load_workspace_action->setShortcut (no_key);
1594  m_save_workspace_action->setShortcut (no_key);
1595  m_preferences_action->setShortcut (no_key);
1596  m_exit_action->setShortcut (no_key);
1597 
1598  // edit menu
1599  m_select_all_action->setShortcut (no_key);
1600  m_clear_clipboard_action->setShortcut (no_key);
1601  m_find_files_action->setShortcut (no_key);
1602  m_clear_command_history_action->setShortcut (no_key);
1603  m_clear_command_window_action->setShortcut (no_key);
1604  m_clear_workspace_action->setShortcut (no_key);
1605 
1606  // window menu
1607  m_reset_windows_action->setShortcut (no_key);
1608 
1609  // help menu
1610  m_ondisk_doc_action->setShortcut (no_key);
1611  m_online_doc_action->setShortcut (no_key);
1612  m_report_bug_action->setShortcut (no_key);
1613  m_octave_packages_action->setShortcut (no_key);
1614  m_contribute_action->setShortcut (no_key);
1615  m_developer_action->setShortcut (no_key);
1616  m_about_octave_action->setShortcut (no_key);
1617 
1618  // news menu
1619  m_release_notes_action->setShortcut (no_key);
1620  m_current_news_action->setShortcut (no_key);
1621  }
1622  }
1623 
1624  void main_window::set_screen_size (int ht, int wd)
1625  {
1627  int_pair (ht, wd));
1628  }
1629 
1631  {
1632  if (m_clipboard->text ().isEmpty ())
1633  {
1634  m_paste_action->setEnabled (false);
1635  m_clear_clipboard_action->setEnabled (false);
1636  }
1637  else
1638  {
1639  m_paste_action->setEnabled (true);
1640  m_clear_clipboard_action->setEnabled (true);
1641  }
1642  }
1643 
1645  {
1646  m_clipboard->clear (QClipboard::Clipboard);
1647  }
1648 
1650  {
1651  QHash<QMenu*, QStringList>::const_iterator i = m_hash_menu_text.constBegin ();
1652 
1653  while (i != m_hash_menu_text.constEnd ())
1654  {
1655  i.key ()->setTitle (i.value ().at (disable));
1656  ++i;
1657  }
1658  }
1659 
1661  {
1662  // restore the new files creation setting
1663  QSettings *settings = resource_manager::get_settings ();
1664  settings->setValue ("editor/create_new_file",false);
1665  disconnect (m_editor_window, SIGNAL (file_loaded_signal (void)),
1666  this, SLOT (restore_create_file_setting (void)));
1667  }
1668 
1669  void main_window::set_file_encoding (const QString& new_encoding)
1670  {
1671  m_file_encoding = new_encoding;
1672  }
1673 
1674  // The following slot is called after files have been selected in the
1675  // open file dialog., possibly with a new selected encoding stored in
1676  // m_file_encoding
1677  void main_window::request_open_files (const QStringList& open_file_names)
1678  {
1679  for (int i = 0; i < open_file_names.count (); i++)
1680  emit open_file_signal (open_file_names.at (i), m_file_encoding, -1);
1681  }
1682 
1683  void main_window::edit_variable (const QString &expr, const octave_value& val)
1684  {
1686 
1687  if (! m_variable_editor_window->isVisible ())
1688  {
1689  m_variable_editor_window->show ();
1690  m_variable_editor_window->raise ();
1691  }
1692 
1693  }
1694 
1696  {
1698  }
1699 
1701  {
1702  // Called when the variable editor emits the updated signal. The size
1703  // of a variable may have changed, so we refresh the workspace in the
1704  // interpreter. That will eventually cause the workspace view in the
1705  // GUI to be updated.
1706 
1708  }
1709 
1710  void main_window::closeEvent (QCloseEvent *e)
1711  {
1712  e->ignore ();
1713  octave_cmd_exec *cmd = new octave_cmd_exec ("exit");
1714  m_cmd_queue.add_cmd (cmd);
1715  }
1716 
1717  // Main subroutine of the constructor
1718 
1720  {
1721  m_closing = false; // flag for editor files when closed
1722 
1723  // Create and set the central widget. QMainWindow takes ownership of
1724  // the widget (pointer) so there is no need to delete the object upon
1725  // destroying this main_window.
1726 
1727  QWidget *dummyWidget = new QWidget ();
1728  dummyWidget->setObjectName ("CentralDummyWidget");
1729  dummyWidget->resize (10, 10);
1730  dummyWidget->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum);
1731  dummyWidget->hide ();
1732  setCentralWidget (dummyWidget);
1733 
1735 
1737 
1738  if (m_start_gui)
1739  {
1740  setWindowIcon (QIcon (":/actions/icons/logo.png"));
1741 
1743 
1744  connect (m_workspace_model, SIGNAL (model_changed (void)),
1745  m_workspace_window, SLOT (handle_model_changed (void)));
1746 
1747  connect (m_octave_qt_link,
1748  SIGNAL (edit_variable_signal (const QString&,
1749  const octave_value&)),
1750  this,
1751  SLOT (edit_variable (const QString&, const octave_value&)));
1752 
1753  connect (m_octave_qt_link, SIGNAL (refresh_variable_editor_signal (void)),
1754  this, SLOT (refresh_variable_editor (void)));
1755 
1756  connect (m_workspace_model,
1757  SIGNAL (rename_variable (const QString&, const QString&)),
1758  this,
1759  SLOT (handle_rename_variable_request (const QString&,
1760  const QString&)));
1761 
1762  connect (m_variable_editor_window, SIGNAL (updated (void)),
1763  this, SLOT (handle_variable_editor_update (void)));
1764 
1765  construct_menu_bar ();
1766 
1767  construct_tool_bar ();
1768 
1769  // Order is important. Deleting QSettings must be last.
1770  connect (qApp, SIGNAL (aboutToQuit (void)),
1771  m_command_window, SLOT (save_settings (void)));
1772 
1773  connect (qApp, SIGNAL (aboutToQuit (void)),
1774  m_history_window, SLOT (save_settings (void)));
1775 
1776  connect (qApp, SIGNAL (aboutToQuit (void)),
1777  m_file_browser_window, SLOT (save_settings (void)));
1778 
1779  connect (qApp, SIGNAL (aboutToQuit (void)),
1780  m_doc_browser_window, SLOT (save_settings (void)));
1781 
1782  connect (qApp, SIGNAL (aboutToQuit (void)),
1783  m_workspace_window, SLOT (save_settings (void)));
1784 
1785  connect (qApp, SIGNAL (aboutToQuit (void)),
1786  m_editor_window, SLOT (save_settings (void)));
1787 
1788  connect (qApp, SIGNAL (aboutToQuit (void)),
1789  m_variable_editor_window, SLOT (save_settings (void)));
1790 
1791  connect (qApp, SIGNAL (aboutToQuit (void)),
1792  this, SLOT (prepare_to_exit (void)));
1793 
1794  connect (qApp, SIGNAL (aboutToQuit (void)),
1795  shortcut_manager::instance, SLOT (cleanup_instance (void)));
1796 
1797  // QSettings are saved upon deletion (i.e., cleanup_instance)
1798  connect (qApp, SIGNAL (aboutToQuit (void)),
1799  resource_manager::instance, SLOT (cleanup_instance (void)));
1800 
1801  connect (qApp, SIGNAL (focusChanged (QWidget*, QWidget*)),
1802  this, SLOT (focus_changed (QWidget*, QWidget*)));
1803 
1804  connect (this, SIGNAL (settings_changed (const QSettings *)),
1805  this, SLOT (notice_settings (const QSettings *)));
1806 
1807  connect (this, SIGNAL (editor_focus_changed (bool)),
1808  this, SLOT (disable_menu_shortcuts (bool)));
1809 
1810  connect (this, SIGNAL (editor_focus_changed (bool)),
1811  m_editor_window, SLOT (enable_menu_shortcuts (bool)));
1812 
1813  connect (m_editor_window,
1814  SIGNAL (request_open_file_external (const QString&, int)),
1816  SLOT (call_custom_editor (const QString&, int)));
1817 
1818  connect (m_external_editor,
1819  SIGNAL (request_settings_dialog (const QString&)),
1820  this, SLOT (process_settings_dialog_request (const QString&)));
1821 
1822  connect (m_file_browser_window, SIGNAL (load_file_signal (const QString&)),
1823  this, SLOT (handle_load_workspace_request (const QString&)));
1824 
1825  connect (m_file_browser_window, SIGNAL (find_files_signal (const QString&)),
1826  this, SLOT (find_files (const QString&)));
1827 
1828  setWindowTitle ("Octave");
1829 
1830 // See Octave bug #53409 and https://bugreports.qt.io/browse/QTBUG-55357
1831 #if (QT_VERSION < 0x050601) || (QT_VERSION >= 0x050701)
1832  setDockOptions (QMainWindow::AnimatedDocks
1833  | QMainWindow::AllowNestedDocks
1834  | QMainWindow::AllowTabbedDocks);
1835 #else
1836  setDockNestingEnabled (true);
1837 #endif
1838 
1839  addDockWidget (Qt::RightDockWidgetArea, m_command_window);
1840  addDockWidget (Qt::RightDockWidgetArea, m_doc_browser_window);
1841  tabifyDockWidget (m_command_window, m_doc_browser_window);
1842 
1843 #if defined (HAVE_QSCINTILLA)
1844  addDockWidget (Qt::RightDockWidgetArea, m_editor_window);
1845  tabifyDockWidget (m_command_window, m_editor_window);
1846 #endif
1847  addDockWidget (Qt::RightDockWidgetArea, m_variable_editor_window);
1848  tabifyDockWidget (m_command_window, m_variable_editor_window);
1849 
1850  addDockWidget (Qt::LeftDockWidgetArea, m_file_browser_window);
1851  addDockWidget (Qt::LeftDockWidgetArea, m_workspace_window);
1852  addDockWidget (Qt::LeftDockWidgetArea, m_history_window);
1853 
1854  int win_x = QApplication::desktop ()->width ();
1855  int win_y = QApplication::desktop ()->height ();
1856 
1857  if (win_x > 960)
1858  win_x = 960;
1859 
1860  if (win_y > 720)
1861  win_y = 720;
1862 
1863  setGeometry (0, 0, win_x, win_y);
1864 
1865  setStatusBar (m_status_bar);
1866 
1867 #if defined (HAVE_QSCINTILLA)
1868  connect (this,
1869  SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
1871  SLOT (handle_insert_debugger_pointer_request (const QString&,
1872  int)));
1873 
1874  connect (this,
1875  SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
1877  SLOT (handle_delete_debugger_pointer_request (const QString&,
1878  int)));
1879 
1880  connect (this,
1881  SIGNAL (update_breakpoint_marker_signal (bool, const QString&,
1882  int, const QString&)),
1885  const QString&,
1886  int,
1887  const QString&)));
1888 
1889  connect (m_file_browser_window,
1890  SIGNAL (file_remove_signal (const QString&, const QString&)),
1892  SLOT (handle_file_remove (const QString&, const QString&)));
1893 
1894  connect (m_file_browser_window, SIGNAL (file_renamed_signal (bool)),
1895  m_editor_window, SLOT (handle_file_renamed (bool)));
1896 #endif
1897 
1900 
1902  }
1903  }
1904 
1906  {
1908 
1910 
1911  connect (m_octave_qt_link, SIGNAL (confirm_shutdown_signal (void)),
1912  this, SLOT (confirm_shutdown_octave (void)));
1913 
1914  connect (m_octave_qt_link,
1915  SIGNAL (copy_image_to_clipboard_signal (const QString&, bool)),
1916  this, SLOT (copy_image_to_clipboard (const QString&, bool)));
1917 
1918  if (m_start_gui)
1919  {
1920  connect (m_octave_qt_link,
1921  SIGNAL (set_workspace_signal (bool, bool,
1922  const symbol_scope&)),
1924  SLOT (set_workspace (bool, bool, const symbol_scope&)));
1925 
1926  connect (m_octave_qt_link, SIGNAL (clear_workspace_signal (void)),
1927  m_workspace_model, SLOT (clear_workspace (void)));
1928 
1929  connect (m_octave_qt_link, SIGNAL (change_directory_signal (QString)),
1930  this, SLOT (change_directory (QString)));
1931 
1932  connect (m_octave_qt_link, SIGNAL (change_directory_signal (QString)),
1933  m_file_browser_window, SLOT (update_octave_directory (QString)));
1934 
1935  connect (m_octave_qt_link, SIGNAL (change_directory_signal (QString)),
1936  m_editor_window, SLOT (update_octave_directory (QString)));
1937 
1938  connect (m_octave_qt_link,
1939  SIGNAL (execute_command_in_terminal_signal (QString)),
1940  this, SLOT (execute_command_in_terminal (QString)));
1941 
1942  connect (m_octave_qt_link,
1943  SIGNAL (set_history_signal (const QStringList&)),
1944  m_history_window, SLOT (set_history (const QStringList&)));
1945 
1946  connect (m_octave_qt_link,
1947  SIGNAL (append_history_signal (const QString&)),
1948  m_history_window, SLOT (append_history (const QString&)));
1949 
1950  connect (m_octave_qt_link,
1951  SIGNAL (clear_history_signal (void)),
1952  m_history_window, SLOT (clear_history (void)));
1953 
1954  connect (m_octave_qt_link, SIGNAL (enter_debugger_signal (void)),
1955  this, SLOT (handle_enter_debugger (void)));
1956 
1957  connect (m_octave_qt_link, SIGNAL (exit_debugger_signal (void)),
1958  this, SLOT (handle_exit_debugger (void)));
1959 
1960  connect (m_octave_qt_link,
1961  SIGNAL (show_preferences_signal (void)),
1962  this, SLOT (process_settings_dialog_request (void)));
1963 
1964  connect (m_octave_qt_link,
1965  SIGNAL (edit_file_signal (const QString&)),
1967  SLOT (handle_edit_file_request (const QString&)));
1968 
1969  connect (m_octave_qt_link,
1970  SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
1971  this,
1972  SLOT (handle_insert_debugger_pointer_request (const QString&,
1973  int)));
1974 
1975  connect (m_octave_qt_link,
1976  SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
1977  this,
1978  SLOT (handle_delete_debugger_pointer_request (const QString&,
1979  int)));
1980 
1981  connect (m_octave_qt_link,
1982  SIGNAL (update_breakpoint_marker_signal (bool, const QString&,
1983  int, const QString&)),
1984  this,
1985  SLOT (handle_update_breakpoint_marker_request (bool, const QString&,
1986  int, const QString&)));
1987 
1988  connect (m_octave_qt_link,
1989  SIGNAL (show_doc_signal (const QString &)),
1990  this, SLOT (handle_show_doc (const QString &)));
1991 
1992  connect (m_octave_qt_link,
1993  SIGNAL (register_doc_signal (const QString &)),
1994  this, SLOT (handle_register_doc (const QString &)));
1995 
1996  connect (m_octave_qt_link,
1997  SIGNAL (unregister_doc_signal (const QString &)),
1998  this, SLOT (handle_unregister_doc (const QString &)));
1999  }
2000 
2001  // Defer initializing and executing the interpreter until after the main
2002  // window and QApplication are running to prevent race conditions
2003  QTimer::singleShot (0, m_interpreter, SLOT (execute (void)));
2004  }
2005 
2006  QAction* main_window::add_action (QMenu *menu, const QIcon& icon,
2007  const QString& text, const char *member,
2008  const QWidget *receiver)
2009  {
2010  QAction *a;
2011 
2012  if (receiver)
2013  a = menu->addAction (icon, text, receiver, member);
2014  else
2015  a = menu->addAction (icon, text, this, member);
2016 
2017  addAction (a); // important for shortcut context
2018  a->setShortcutContext (Qt::ApplicationShortcut);
2019  return a;
2020  }
2021 
2023  {
2024  QMenu *menu = p->addMenu (name);
2025 
2026  QString base_name = name; // get a copy
2027  // replace intended '&' ("&&") by a temp. string
2028  base_name.replace ("&&", "___octave_amp_replacement___");
2029  // remove single '&' (shortcut)
2030  base_name.remove ("&");
2031  // restore intended '&'
2032  base_name.replace ("___octave_amp_replacement___", "&&");
2033 
2034  // remember names with and without shortcut
2035  m_hash_menu_text[menu] = QStringList () << name << base_name;
2036 
2037  return menu;
2038  }
2039 
2041  {
2042  QMenuBar *menu_bar = menuBar ();
2043 
2044  construct_file_menu (menu_bar);
2045 
2046  construct_edit_menu (menu_bar);
2047 
2048  construct_debug_menu (menu_bar);
2049 
2050  construct_window_menu (menu_bar);
2051 
2052  construct_help_menu (menu_bar);
2053 
2054  construct_news_menu (menu_bar);
2055 
2056 #if defined (HAVE_QSCINTILLA)
2057  // call the editor to add actions which should also be available in the
2058  // editor's menu and tool bar
2059  QList<QAction*> shared_actions;
2060  shared_actions << m_new_script_action
2062  << m_open_action
2064  << m_undo_action
2065  << m_copy_action
2066  << m_paste_action
2068  m_editor_window->insert_global_actions (shared_actions);
2069 #endif
2070  }
2071 
2073  {
2074  QMenu *file_menu = m_add_menu (p, tr ("&File"));
2075 
2076  construct_new_menu (file_menu);
2077 
2079  = file_menu->addAction (resource_manager::icon ("document-open"),
2080  tr ("Open..."));
2081  m_open_action->setShortcutContext (Qt::ApplicationShortcut);
2082  m_open_action->setToolTip (tr ("Open an existing file in editor"));
2083 
2084 #if defined (HAVE_QSCINTILLA)
2085  file_menu->addMenu (m_editor_window->get_mru_menu ());
2086 #endif
2087 
2088  file_menu->addSeparator ();
2089 
2091  = file_menu->addAction (tr ("Load Workspace..."));
2092 
2094  = file_menu->addAction (tr ("Save Workspace As..."));
2095 
2096  file_menu->addSeparator ();
2097 
2098  m_exit_action = file_menu->addAction (tr ("Exit"));
2099  m_exit_action->setShortcutContext (Qt::ApplicationShortcut);
2100 
2101  connect (m_open_action, SIGNAL (triggered (void)),
2102  this, SLOT (request_open_file (void)));
2103 
2104  connect (m_load_workspace_action, SIGNAL (triggered (void)),
2105  this, SLOT (handle_load_workspace_request (void)));
2106 
2107  connect (m_save_workspace_action, SIGNAL (triggered (void)),
2108  this, SLOT (handle_save_workspace_request (void)));
2109 
2110  connect (m_exit_action, SIGNAL (triggered (void)),
2111  this, SLOT (close (void)));
2112  }
2113 
2115  {
2116  QMenu *new_menu = p->addMenu (tr ("New"));
2117 
2119  = new_menu->addAction (resource_manager::icon ("document-new"),
2120  tr ("New Script"));
2121  m_new_script_action->setShortcutContext (Qt::ApplicationShortcut);
2122 
2123  m_new_function_action = new_menu->addAction (tr ("New Function..."));
2124  m_new_function_action->setEnabled (true);
2125  m_new_function_action->setShortcutContext (Qt::ApplicationShortcut);
2126 
2127  m_new_figure_action = new_menu->addAction (tr ("New Figure"));
2128  m_new_figure_action->setEnabled (true);
2129 
2130  connect (m_new_script_action, SIGNAL (triggered (void)),
2131  this, SLOT (request_new_script (void)));
2132 
2133  connect (m_new_function_action, SIGNAL (triggered (void)),
2134  this, SLOT (request_new_function (void)));
2135 
2136  connect (this, SIGNAL (new_file_signal (const QString&)),
2137  m_active_editor, SLOT (request_new_file (const QString&)));
2138 
2139  connect (this, SIGNAL (open_file_signal (const QString&)),
2140  m_active_editor, SLOT (request_open_file (const QString&)));
2141 
2142  connect (this,
2143  SIGNAL (open_file_signal (const QString&, const QString&, int)),
2145  SLOT (request_open_file (const QString&, const QString&, int)));
2146 
2147  connect (m_new_figure_action, SIGNAL (triggered (void)),
2148  this, SLOT (handle_new_figure_request (void)));
2149  }
2150 
2152  {
2153  QMenu *edit_menu = m_add_menu (p, tr ("&Edit"));
2154 
2155  QKeySequence ctrl_shift = Qt::ControlModifier + Qt::ShiftModifier;
2156 
2158  = edit_menu->addAction (resource_manager::icon ("edit-undo"), tr ("Undo"));
2159  m_undo_action->setShortcutContext (Qt::ApplicationShortcut);
2160 
2161  edit_menu->addSeparator ();
2162 
2164  = edit_menu->addAction (resource_manager::icon ("edit-copy"),
2165  tr ("Copy"), this, SLOT (copyClipboard (void)));
2166  m_copy_action->setShortcutContext (Qt::ApplicationShortcut);
2167 
2169  = edit_menu->addAction (resource_manager::icon ("edit-paste"),
2170  tr ("Paste"), this, SLOT (pasteClipboard (void)));
2171  m_paste_action->setShortcutContext (Qt::ApplicationShortcut);
2172 
2174  = edit_menu->addAction (tr ("Select All"), this, SLOT (selectAll (void)));
2175  m_select_all_action->setShortcutContext (Qt::ApplicationShortcut);
2176 
2178  = edit_menu->addAction (tr ("Clear Clipboard"), this,
2179  SLOT (clear_clipboard (void)));
2180 
2181  edit_menu->addSeparator ();
2182 
2184  = edit_menu->addAction (resource_manager::icon ("edit-find"),
2185  tr ("Find Files..."));
2186 
2187  edit_menu->addSeparator ();
2188 
2190  = edit_menu->addAction (tr ("Clear Command Window"));
2191 
2193  = edit_menu->addAction (tr ("Clear Command History"));
2194 
2196  = edit_menu->addAction (tr ("Clear Workspace"));
2197 
2198  edit_menu->addSeparator ();
2199 
2201  = edit_menu->addAction (resource_manager::icon ("preferences-system"),
2202  tr ("Preferences..."));
2203 
2204  connect (m_find_files_action, SIGNAL (triggered (void)),
2205  this, SLOT (find_files (void)));
2206 
2207  connect (m_clear_command_window_action, SIGNAL (triggered (void)),
2208  this, SLOT (handle_clear_command_window_request (void)));
2209 
2210  connect (m_clear_command_history_action, SIGNAL (triggered (void)),
2211  this, SLOT (handle_clear_history_request (void)));
2212 
2213  connect (m_clear_workspace_action, SIGNAL (triggered (void)),
2214  this, SLOT (handle_clear_workspace_request (void)));
2215 
2216  connect (m_clipboard, SIGNAL (dataChanged (void)),
2217  this, SLOT (clipboard_has_changed (void)));
2219 #if defined (Q_OS_WIN32)
2220  // Always enable paste action (unreliable clipboard signals in windows)
2221  // FIXME: This has to be removed, when the clipboards signals in windows
2222  // are working again
2223  m_paste_action->setEnabled (true);
2224  m_clear_clipboard_action->setEnabled (true);
2225 #endif
2226 
2227  connect (m_preferences_action, SIGNAL (triggered (void)),
2228  this, SLOT (process_settings_dialog_request (void)));
2229  }
2230 
2231  QAction * main_window::construct_debug_menu_item (const char *icon,
2232  const QString& item,
2233  const char *member)
2234  {
2235  QAction *action = add_action (m_debug_menu,
2236  resource_manager::icon (QString (icon)),
2237  item, member);
2238 
2239  action->setEnabled (false);
2240 
2241 #if defined (HAVE_QSCINTILLA)
2242  m_editor_window->debug_menu ()->addAction (action);
2243  m_editor_window->toolbar ()->addAction (action);
2244 #endif
2245 
2246  return action;
2247  }
2248 
2250  {
2251  m_debug_menu = m_add_menu (p, tr ("De&bug"));
2252 
2254  "db-step", tr ("Step"),
2255  SLOT (debug_step_over (void)));
2256 
2258  "db-step-in", tr ("Step In"),
2259  SLOT (debug_step_into (void)));
2260 
2262  "db-step-out", tr ("Step Out"),
2263  SLOT (debug_step_out (void)));
2264 
2266  "db-cont", tr ("Continue"),
2267  SLOT (debug_continue (void)));
2268 
2269  m_debug_menu->addSeparator ();
2270 #if defined (HAVE_QSCINTILLA)
2271  m_editor_window->debug_menu ()->addSeparator ();
2272 #endif
2273 
2275  "db-stop", tr ("Quit Debug Mode"),
2276  SLOT (debug_quit (void)));
2277  }
2278 
2280  const QString& item,
2281  bool checkable,
2282  QWidget *widget)
2283  {
2284  QAction *action = p->addAction (QIcon (), item);
2285 
2286  addAction (action); // important for shortcut context
2287  action->setCheckable (checkable);
2288  action->setShortcutContext (Qt::ApplicationShortcut);
2289 
2290  if (widget) // might be zero for m_editor_window
2291  {
2292  if (checkable)
2293  {
2294  // action for visibilty of dock widget
2295  connect (action, SIGNAL (toggled (bool)),
2296  widget, SLOT (setVisible (bool)));
2297 
2298  connect (widget, SIGNAL (active_changed (bool)),
2299  action, SLOT (setChecked (bool)));
2300  }
2301  else
2302  {
2303  // action for focus of dock widget
2304  connect (action, SIGNAL (triggered (void)), widget, SLOT (focus (void)));
2305  }
2306  }
2307 
2308  return action;
2309  }
2310 
2312  {
2313  QMenu *window_menu = m_add_menu (p, tr ("&Window"));
2314 
2316  (window_menu, tr ("Show Command Window"), true, m_command_window);
2317 
2319  (window_menu, tr ("Show Command History"), true, m_history_window);
2320 
2322  (window_menu, tr ("Show File Browser"), true, m_file_browser_window);
2323 
2325  (window_menu, tr ("Show Workspace"), true, m_workspace_window);
2326 
2328  (window_menu, tr ("Show Editor"), true, m_editor_window);
2329 
2331  (window_menu, tr ("Show Documentation"), true, m_doc_browser_window);
2332 
2334  (window_menu, tr ("Show Variable Editor"), true, m_variable_editor_window);
2335 
2336  window_menu->addSeparator ();
2337 
2339  (window_menu, tr ("Command Window"), false, m_command_window);
2340 
2342  (window_menu, tr ("Command History"), false, m_history_window);
2343 
2345  (window_menu, tr ("File Browser"), false, m_file_browser_window);
2346 
2348  (window_menu, tr ("Workspace"), false, m_workspace_window);
2349 
2351  (window_menu, tr ("Editor"), false, m_editor_window);
2352 
2354  (window_menu, tr ("Documentation"), false, m_doc_browser_window);
2355 
2357  (window_menu, tr ("Variable Editor"), false, m_variable_editor_window);
2358 
2359  window_menu->addSeparator ();
2360 
2361  m_reset_windows_action = add_action (window_menu, QIcon (),
2362  tr ("Reset Default Window Layout"), SLOT (reset_windows (void)));
2363  }
2364 
2366  {
2367  QMenu *help_menu = m_add_menu (p, tr ("&Help"));
2368 
2369  construct_documentation_menu (help_menu);
2370 
2371  help_menu->addSeparator ();
2372 
2373  m_report_bug_action = add_action (help_menu, QIcon (),
2374  tr ("Report Bug"), SLOT (open_bug_tracker_page ()));
2375 
2376  m_octave_packages_action = add_action (help_menu, QIcon (),
2377  tr ("Octave Packages"), SLOT (open_octave_packages_page ()));
2378 
2379  m_contribute_action = add_action (help_menu, QIcon (),
2380  tr ("Contribute"), SLOT (open_contribute_page ()));
2381 
2382  m_developer_action = add_action (help_menu, QIcon (),
2383  tr ("Donate to Octave"), SLOT (open_donate_page ()));
2384 
2385  help_menu->addSeparator ();
2386 
2387  m_about_octave_action = add_action (help_menu, QIcon (),
2388  tr ("About Octave"), SLOT (show_about_octave ()));
2389  }
2390 
2392  {
2393  QMenu *doc_menu = p->addMenu (tr ("Documentation"));
2394 
2395  m_ondisk_doc_action = add_action (doc_menu, QIcon (),
2396  tr ("On Disk"), SLOT (focus ()), m_doc_browser_window);
2397 
2398  m_online_doc_action = add_action (doc_menu, QIcon (),
2399  tr ("Online"), SLOT (open_online_documentation_page ()));
2400  }
2401 
2403  {
2404  QMenu *news_menu = m_add_menu (p, tr ("&News"));
2405 
2406  m_release_notes_action = add_action (news_menu, QIcon (),
2407  tr ("Release Notes"), SLOT (display_release_notes ()));
2408 
2409  m_current_news_action = add_action (news_menu, QIcon (),
2410  tr ("Community News"), SLOT (load_and_display_community_news ()));
2411  }
2412 
2414  {
2415  m_main_tool_bar = addToolBar (tr ("Toolbar"));
2416 
2417  m_main_tool_bar->setObjectName ("MainToolBar");
2418  m_main_tool_bar->addAction (m_new_script_action);
2419  m_main_tool_bar->addAction (m_open_action);
2420 
2421  m_main_tool_bar->addSeparator ();
2422 
2423  m_main_tool_bar->addAction (m_copy_action);
2424  m_main_tool_bar->addAction (m_paste_action);
2425  m_main_tool_bar->addAction (m_undo_action);
2426 
2427  m_main_tool_bar->addSeparator ();
2428 
2429  m_current_directory_combo_box = new QComboBox (this);
2430  QFontMetrics fm = m_current_directory_combo_box->fontMetrics ();
2431  m_current_directory_combo_box->setFixedWidth (48*fm.averageCharWidth ());
2432  m_current_directory_combo_box->setEditable (true);
2433  m_current_directory_combo_box->setInsertPolicy (QComboBox::NoInsert);
2434  m_current_directory_combo_box->setToolTip (tr ("Enter directory name"));
2435  m_current_directory_combo_box->setMaxVisibleItems (
2438  QSizePolicy sizePol (QSizePolicy::Preferred, QSizePolicy::Preferred);
2439  m_current_directory_combo_box->setSizePolicy (sizePol);
2440 
2441  // addWidget takes ownership of the objects so there is no
2442  // need to delete these upon destroying this main_window.
2443  m_main_tool_bar->addWidget (new QLabel (tr ("Current Directory: ")));
2445  QAction *current_dir_up = m_main_tool_bar->addAction (
2446  resource_manager::icon ("go-up"),
2447  tr ("One directory up"));
2448  QAction *current_dir_search = m_main_tool_bar->addAction (
2449  resource_manager::icon ("folder"),
2450  tr ("Browse directories"));
2451 
2452  connect (m_current_directory_combo_box, SIGNAL (activated (QString)),
2453  this, SLOT (set_current_working_directory (QString)));
2454 
2455  connect (m_current_directory_combo_box->lineEdit (), SIGNAL (returnPressed (void)),
2456  this, SLOT (accept_directory_line_edit (void)));
2457 
2458  connect (current_dir_search, SIGNAL (triggered (void)),
2459  this, SLOT (browse_for_directory (void)));
2460 
2461  connect (current_dir_up, SIGNAL (triggered (void)),
2462  this, SLOT (change_directory_up (void)));
2463 
2464  connect (m_undo_action, SIGNAL (triggered (void)),
2465  this, SLOT (handle_undo_request (void)));
2466  }
2467 
2469  {
2470  // INTERPRETER THREAD
2471 
2472  Fsave (ovl (file));
2473  }
2474 
2476  {
2477  // INTERPRETER THREAD
2478 
2479  Fload (ovl (file));
2480 
2481  symbol_scope scope
2482  = __get_current_scope__ ("main_window::load_workspace_callback");
2483 
2484  if (scope)
2485  octave_link::set_workspace (true, scope);
2486  }
2487 
2489  {
2490  // INTERPRETER THREAD
2491 
2492  symbol_scope scope
2493  = __get_current_scope__ ("main_window::rename_variable_callback");
2494 
2495  if (scope)
2496  {
2497  scope.rename (names.first, names.second);
2498 
2499  octave_link::set_workspace (true, scope);
2500  }
2501 
2502  // FIXME: if this action fails, do we need a way to display that info
2503  // in the GUI?
2504  }
2505 
2507  {
2508  // INTERPRETER THREAD
2509 
2512  }
2513 
2515  {
2516  // INTERPRETER THREAD
2517 
2520  }
2521 
2523  {
2524  // INTERPRETER THREAD
2525 
2527  }
2528 
2530  {
2531  // INTERPRETER THREAD
2532 
2533  command_editor::set_screen_size (sz.first, sz.second);
2534  }
2535 
2537  {
2538  // INTERPRETER THREAD
2539 
2540  interpreter& interp
2541  = __get_interpreter__ ("main_window::clear_workspace_callback");
2542 
2543  Fclear (interp);
2544  }
2545 
2547  {
2548  // INTERPRETER THREAD
2549 
2550  Fhistory (ovl ("-c"));
2551  }
2552 
2554  {
2555  // INTERPRETER THREAD
2556 
2557  symbol_scope scope
2558  = __get_current_scope__ ("main_window::force_refresh_workspace");
2559 
2560  if (scope)
2561  octave_link::set_workspace (true, scope, false);
2562  }
2563 
2565  {
2566  QSettings *settings = resource_manager::get_settings ();
2567  return settings->value ("terminal/focus_after_command",false).toBool ();
2568  }
2569 
2571  {
2572  // INTERPRETER THREAD
2573 
2574  interpreter& interp
2575  = __get_interpreter__ ("main_window::new_figure_callback");
2576 
2577  Fbuiltin (interp, ovl ("figure"));
2578  Fdrawnow ();
2579  }
2580 
2582  {
2583  // INTERPRETER THREAD
2584 
2585  Fcd (ovl (directory));
2586  }
2587 
2589  {
2590  // file menu
2591  shortcut_manager::set_shortcut (m_open_action, "main_file:open_file");
2592  shortcut_manager::set_shortcut (m_new_script_action, "main_file:new_file");
2594  "main_file:new_function");
2595  shortcut_manager::set_shortcut (m_new_function_action, "main_file:new_figure");
2597  "main_file:load_workspace");
2599  "main_file:save_workspace");
2600  shortcut_manager::set_shortcut (m_preferences_action, "main_file:preferences");
2601  shortcut_manager::set_shortcut (m_exit_action,"main_file:exit");
2602 
2603  // edit menu
2604  shortcut_manager::set_shortcut (m_copy_action, "main_edit:copy");
2605  shortcut_manager::set_shortcut (m_paste_action, "main_edit:paste");
2606  shortcut_manager::set_shortcut (m_undo_action, "main_edit:undo");
2607  shortcut_manager::set_shortcut (m_select_all_action, "main_edit:select_all");
2609  "main_edit:clear_clipboard");
2610  shortcut_manager::set_shortcut (m_find_files_action, "main_edit:find_in_files");
2612  "main_edit:clear_history");
2614  "main_edit:clear_command_window");
2616  "main_edit:clear_workspace");
2617 
2618  // debug menu
2619  shortcut_manager::set_shortcut (m_debug_step_over, "main_debug:step_over");
2620  shortcut_manager::set_shortcut (m_debug_step_into, "main_debug:step_into");
2621  shortcut_manager::set_shortcut (m_debug_step_out, "main_debug:step_out");
2622  shortcut_manager::set_shortcut (m_debug_continue, "main_debug:continue");
2623  shortcut_manager::set_shortcut (m_debug_quit, "main_debug:quit");
2624 
2625  // window menu
2627  "main_window:show_command");
2629  "main_window:show_history");
2631  "main_window:show_workspace");
2633  "main_window:show_file_browser");
2635  "main_window:show_editor");
2637  "main_window:show_doc");
2639  "main_window:show_variable_editor");
2641  shortcut_manager::set_shortcut (m_history_action, "main_window:history");
2642  shortcut_manager::set_shortcut (m_workspace_action, "main_window:workspace");
2644  "main_window:file_browser");
2645  shortcut_manager::set_shortcut (m_editor_action, "main_window:editor");
2648  "main_window:variable_editor");
2650 
2651  // help menu
2652  shortcut_manager::set_shortcut (m_ondisk_doc_action, "main_help:ondisk_doc");
2653  shortcut_manager::set_shortcut (m_online_doc_action, "main_help:online_doc");
2654  shortcut_manager::set_shortcut (m_report_bug_action, "main_help:report_bug");
2656  shortcut_manager::set_shortcut (m_contribute_action, "main_help:contribute");
2657  shortcut_manager::set_shortcut (m_developer_action, "main_help:developer");
2659 
2660  // news menu
2662  "main_news:release_notes");
2664  "main_news:community_news");
2665  }
2666 
2668  {
2670  list.append (static_cast<octave_dock_widget *> (m_command_window));
2671  list.append (static_cast<octave_dock_widget *> (m_history_window));
2672  list.append (static_cast<octave_dock_widget *> (m_file_browser_window));
2673  list.append (static_cast<octave_dock_widget *> (m_doc_browser_window));
2674 #if defined (HAVE_QSCINTILLA)
2675  list.append (static_cast<octave_dock_widget *> (m_editor_window));
2676 #endif
2677  list.append (static_cast<octave_dock_widget *> (m_workspace_window));
2678  list.append (static_cast<octave_dock_widget *> (m_variable_editor_window));
2679  return list;
2680  }
2681 
2683  {
2684  QString html_text;
2685 
2686  if (m_connect_to_web)
2687  {
2688  // Run this part in a separate thread so Octave can continue to
2689  // run while we wait for the page to load. Then emit the signal
2690  // to display it when we have the page contents.
2691 
2692  QString url = m_base_url + '/' + m_page;
2693  std::ostringstream buf;
2694  url_transfer octave_dot_org (url.toStdString (), buf);
2695 
2696  if (octave_dot_org.is_valid ())
2697  {
2699  octave_dot_org.http_get (param);
2700 
2701  if (octave_dot_org.good ())
2702  html_text = QString::fromStdString (buf.str ());
2703  }
2704 
2705  if (html_text.contains ("this-is-the-gnu-octave-community-news-page"))
2706  {
2707  if (m_serial >= 0)
2708  {
2709  QSettings *settings = resource_manager::get_settings ();
2710 
2711  if (settings)
2712  {
2713  settings->setValue ("news/last_time_checked",
2714  QDateTime::currentDateTime ());
2715 
2716  settings->sync ();
2717  }
2718 
2719  QString tag ("community-news-page-serial=");
2720 
2721  int b = html_text.indexOf (tag);
2722 
2723  if (b)
2724  {
2725  b += tag.length ();
2726 
2727  int e = html_text.indexOf ("\n", b);
2728 
2729  QString tmp = html_text.mid (b, e-b);
2730 
2731  int curr_page_serial = tmp.toInt ();
2732 
2733  if (curr_page_serial > m_serial)
2734  {
2735  if (settings)
2736  {
2737  settings->setValue ("news/last_news_item",
2738  curr_page_serial);
2739 
2740  settings->sync ();
2741  }
2742  }
2743  else
2744  return;
2745  }
2746  else
2747  return;
2748  }
2749  }
2750  else
2751  html_text = QString
2752  (tr ("<html>\n"
2753  "<body>\n"
2754  "<p>\n"
2755  "Octave's community news source seems to be unavailable.\n"
2756  "</p>\n"
2757  "<p>\n"
2758  "For the latest news, please check\n"
2759  "<a href=\"https://octave.org/community-news.html\">https://octave.org/community-news.html</a>\n"
2760  "when you have a connection to the web (link opens in an external browser).\n"
2761  "</p>\n"
2762  "<p>\n"
2763  "<small><em>&mdash; The Octave Developers, ") + OCTAVE_RELEASE_DATE + "</em></small>\n"
2764  "</p>\n"
2765  "</body>\n"
2766  "</html>\n");
2767  }
2768  else
2769  html_text = QString
2770  (tr ("<html>\n"
2771  "<body>\n"
2772  "<p>\n"
2773  "Connecting to the web to display the latest Octave Community news has been disabled.\n"
2774  "</p>\n"
2775  "<p>\n"
2776  "For the latest news, please check\n"
2777  "<a href=\"https://octave.org/community-news.html\">https://octave.org/community-news.html</a>\n"
2778  "when you have a connection to the web (link opens in an external browser)\n"
2779  "or enable web connections for news in Octave's network settings dialog.\n"
2780  "</p>\n"
2781  "<p>\n"
2782  "<small><em>&mdash; The Octave Developers, ") + OCTAVE_RELEASE_DATE + "</em></small>\n"
2783  "</p>\n"
2784  "</body>\n"
2785  "</html>\n");
2786 
2787  emit display_news_signal (html_text);
2788 
2789  emit finished ();
2790  }
2791 }
QAction * m_debug_continue
Definition: main-window.h:387
void request_new_function(bool triggered=true)
QAction * m_contribute_action
Definition: main-window.h:432
workspace_model * m_workspace_model
Definition: main-window.h:357
void clear_history_callback(void)
void set_search_dir(const QString &dir)
void handle_edit_mfile_request(const QString &name, const QString &file, const QString &curr_dir, int line)
static const int current_directory_max_visible
For Toolbars.
Definition: main-window.h:442
QAction * m_undo_action
Definition: main-window.h:405
void handle_clear_command_window_request(void)
Definition: main-window.cc:388
void unregister_doc_signal(const QString &)
void construct_edit_menu(QMenuBar *p)
void find_files(const QString &startdir=QDir::currentPath())
Find files dialog.
std::pair< std::string, std::string > name_pair
Definition: main-window.h:102
void handle_register_doc(const QString &file)
void open_online_documentation_page(void)
Definition: main-window.cc:434
variable_editor * m_variable_editor_window
Dock widgets.
Definition: main-window.h:373
void set_screen_size_callback(const int_pair &)
terminal_dock_widget * m_command_window
Dock widgets.
Definition: main-window.h:367
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:124
static void combo_encoding(QComboBox *combo, QString current=QString())
workspace_view * m_workspace_window
Dock widgets.
Definition: main-window.h:372
interpreter & __get_interpreter__(const std::string &who)
void browse_for_directory(void)
Definition: main-window.cc:832
QString m_release_notes_icon
Definition: main-window.h:381
void change_directory(const QString &dir)
Definition: main-window.cc:817
file_editor_interface * m_editor_window
Dock widgets.
Definition: main-window.h:371
fname
Definition: load-save.cc:767
void execute_command_in_terminal(const QString &dir)
Definition: main-window.cc:883
find_files_dialog * m_find_files_dlg
Find files dialog.
Definition: main-window.h:453
QAction * m_new_script_action
Definition: main-window.h:393
std::string string_value(bool force=false) const
Definition: ov.h:955
void handle_create_filedialog(const QStringList &filters, const QString &title, const QString &filename, const QString &dirname, const QString &multimode)
The value of lines which begin with a space character are not saved in the history list A value of all commands are saved on the history list
Definition: oct-hist.cc:734
void load_and_display_community_news(int serial=-1)
Definition: main-window.cc:506
std::string oct_etc_dir(void)
Definition: defaults.cc:298
const T * data(void) const
Definition: Array.h:582
void handle_enter_debugger(void)
Definition: main-window.cc:908
QAction * m_paste_action
Definition: main-window.h:403
QAction * m_debug_quit
Definition: main-window.h:391
void settings_changed(const QSettings *)
QAction * m_exit_action
Definition: main-window.h:400
history_dock_widget * m_history_window
Dock widgets.
Definition: main-window.h:368
static void update_network_settings(void)
QWidget * m_active_editor
Definition: main-window.h:377
QAction * m_editor_action
Definition: main-window.h:423
void set_predecessor_widget(octave_dock_widget *prev_widget)
void pasteClipboard(void)
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
QHash< QMenu *, QStringList > m_hash_menu_text
Definition: main-window.h:359
QAction * m_workspace_action
Definition: main-window.h:421
QAction * m_save_workspace_action
Definition: main-window.h:398
void handle_unregister_doc(const QString &file)
Dock widget to display files in the current directory.
void construct_file_menu(QMenuBar *p)
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
Definition: data.cc:6348
application * m_app_context
Definition: main-window.h:91
virtual void enable_menu_shortcuts(bool enable)=0
void init_terminal_size_signal(void)
void rename_variable_callback(const name_pair &names)
static QSettings * get_default_settings(void)
void pasteClipboard_signal(void)
void construct_window_menu(QMenuBar *p)
OCTAVE_EXPORT octave_value_list page
Definition: sub2ind.cc:107
QAction * m_new_figure_action
Definition: main-window.h:396
void active_dock_changed(octave_dock_widget *, octave_dock_widget *)
void open_contribute_page(void)
Definition: main-window.cc:595
QAction * m_report_bug_action
Definition: main-window.h:430
QWidget * m_release_notes_window
Release notes window.
Definition: main-window.h:457
void add_cmd(octave_cmd *cmd)
Adds a new octave command to the command queue.
Definition: octave-cmd.cc:101
void open_donate_page(void)
Definition: main-window.cc:600
virtual void empty_script(bool, bool)=0
QAction * add_action(QMenu *menu, const QIcon &icon, const QString &text, const char *member, const QWidget *receiver=nullptr)
virtual void insert_global_actions(QList< QAction *>)=0
void display_community_news(const QString &news)
Definition: main-window.cc:541
QString fromStdString(const std::string &s)
QAction * m_file_browser_action
Definition: main-window.h:422
void set_global_shortcuts(bool enable)
Setting global shortcuts.
void command_window_undo_callback(void)
void editor_focus_changed(bool)
QAction * m_new_function_action
Definition: main-window.h:394
QAction * m_ondisk_doc_action
Definition: main-window.h:428
void execute(void)
Initialize and execute the octave interpreter.
Definition: main-window.cc:94
void refresh_workspace_callback(void)
std::string filename
Definition: urlwrite.cc:121
void edit_mfile(const QString &, int)
Definition: main-window.cc:429
void edit_variable(const QString &name, const octave_value &)
Opens the variable editor for name.
std::string dirname(const std::string &path)
Definition: file-ops.cc:353
void request_reload_settings(void)
Definition: main-window.cc:344
void debug_quit(void)
Definition: main-window.cc:964
QToolBar * m_main_tool_bar
Definition: main-window.h:383
virtual void restore_session(QSettings *)=0
void handle_load_workspace_request(const QString &file=QString())
Definition: main-window.cc:369
void change_directory_callback(const std::string &directory)
QAction * m_show_workspace_action
Definition: main-window.h:414
bool m_prevent_readline_conflicts
Some class global flags.
Definition: main-window.h:472
QAction * m_history_action
Definition: main-window.h:420
void copyClipboard_signal(void)
symbol_scope __get_current_scope__(const std::string &who)
OCTAVE_EXPORT octave_value_list Fsave(const octave_value_list &args, int nargout) ar
Definition: load-save.cc:1612
QAction * m_debug_step_into
Definition: main-window.h:388
bool m_closing
Flag for closing the whole application.
Definition: main-window.h:478
to define functions rather than attempting to enter them directly on the command line The block of commands is executed as soon as you exit the editor To avoid executing any simply delete all the lines from the buffer before leaving the editor When invoked with no edit the previously executed command
Definition: oct-hist.cc:587
bool command_window_has_focus(void) const
Definition: main-window.cc:273
void clear_clipboard()
Handling the clipboard.
void request_new_script(const QString &commands=QString())
i e
Definition: data.cc:2591
void new_file(const QString &commands=QString())
Definition: main-window.cc:416
void initialize(void)
octave_value arg
Definition: pr-output.cc:3244
virtual QToolBar * toolbar(void)=0
void debug_step_out(void)
Definition: main-window.cc:958
void save_workspace_callback(const std::string &file)
void construct_menu_bar(void)
void reset_windows(void)
Definition: main-window.cc:808
#define OCTAVE_VERSION
Definition: main.in.cc:48
void show_about_octave(void)
Definition: main-window.cc:644
QAction * m_variable_editor_action
Definition: main-window.h:425
void construct_octave_qt_link(void)
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
static shortcut_manager * instance
bool focus_console_after_command(void)
QAction * m_debug_step_over
Definition: main-window.h:389
void disable_menu_shortcuts(bool disable)
void handle_clear_history_request(void)
Definition: main-window.cc:393
static void set_screen_size(int ht, int wd)
Definition: cmd-edit.cc:1260
void clear_workspace_callback(void)
void copyClipboard(void)
void focus_command_window(void)
Definition: main-window.cc:278
void debug_continue(void)
Definition: main-window.cc:938
void message(const char *name, const char *fmt,...)
Definition: error.cc:435
void notice_settings(const QSettings *settings)
Definition: main-window.cc:653
QAction * m_show_variable_editor_action
Definition: main-window.h:418
void connect_visibility_changed(void)
OCTAVE_EXPORT octave_value_list Fload(const octave_value_list &args, int nargout) ar
Definition: load-save.cc:642
void report_status_message(const QString &statusMessage)
Definition: main-window.cc:352
nd deftypefn *std::string name
Definition: sysdep.cc:647
void debug_step_over(void)
Definition: main-window.cc:951
QAction * m_select_all_action
Definition: main-window.h:410
void construct_debug_menu(QMenuBar *p)
QAction * m_find_files_action
Definition: main-window.h:409
void read_settings(void)
void accept_directory_line_edit(void)
Definition: main-window.cc:869
QAction * m_show_file_browser_action
Definition: main-window.h:415
#define OCTAVE_RELEASE_DATE
Definition: version.in.h:47
static void set_shortcut(QAction *action, const QString &key)
QAction * m_documentation_action
Definition: main-window.h:424
QAction * construct_debug_menu_item(const char *icon, const QString &item, const char *member)
void confirm_shutdown_octave(void)
Definition: main-window.cc:760
static void resize_terminal(void)
Definition: cmd-edit.cc:1253
QAction * m_show_command_window_action
Definition: main-window.h:412
QAction * m_release_notes_action
Definition: main-window.h:436
QThread * m_main_thread
Definition: main-window.h:355
std::complex< double > w(std::complex< double > z, double relerr=0)
static const int current_directory_max_count
For Toolbars.
Definition: main-window.h:443
bool m_start_gui
Some class global flags.
Definition: main-window.h:474
std::string str
Definition: hash.cc:118
void connect_uiwidget_links(void)
void prepare_to_exit(void)
Definition: main-window.cc:797
void display_news_signal(const QString &news)
void handle_rename_variable_request(const QString &old_name, const QString &new_name)
Definition: main-window.cc:406
void set_file_encoding(const QString &new_encoding)
void install___init_qt___functions(octave::symbol_table &symtab)
Definition: __init_qt__.cc:113
double tmp
Definition: data.cc:6252
void process_settings_dialog_request(const QString &desired_tab=QString())
Definition: main-window.cc:605
QComboBox * m_current_directory_combo_box
For Toolbars.
Definition: main-window.h:441
main_window(QWidget *parent, gui_application *app_context)
Definition: main-window.cc:144
void handle_new_figure_request(void)
Definition: main-window.cc:903
void closeEvent(QCloseEvent *closeEvent)
static octave::file_editor_interface * create_default_editor(QWidget *p)
Definition: main-window.cc:77
QAction * m_show_history_action
Definition: main-window.h:413
bool m_suppress_dbg_location
Some class global flags.
Definition: main-window.h:473
const Cell & contents(const_iterator p) const
Definition: oct-map.h:317
void rename(const std::string &old_name, const std::string &new_name)
Definition: symscope.h:701
void write_settings(void)
void focus_changed(QWidget *w_old, QWidget *w_new)
Definition: main-window.cc:284
QClipboard * m_clipboard
Definition: main-window.h:463
virtual void handle_exit_debug_mode(void)=0
octave_dock_widget * m_active_dock
Definition: main-window.h:379
idx type
Definition: ov.cc:3114
Array< std::string > param
Definition: urlwrite.cc:124
sz
Definition: data.cc:5264
void debug_step_into(void)
Definition: main-window.cc:945
QAction * m_preferences_action
Definition: main-window.h:399
QAction * m_copy_action
Definition: main-window.h:402
void delete_debugger_pointer_signal(const QString &file, int line)
void new_figure_callback(void)
void selectAll_signal(void)
void update_breakpoint_marker_signal(bool insert, const QString &file, int line, const QString &cond)
void handle_save_workspace_request(void)
Definition: main-window.cc:357
virtual void handle_enter_debug_mode(void)=0
void handle_insert_debugger_pointer_request(const QString &file, int line)
void set_window_layout(QSettings *settings)
void request_open_file(void)
Definition: main-window.cc:977
static resource_manager * instance
QAction * construct_window_menu_item(QMenu *p, const QString &item, bool checkable, QWidget *)
void edit_variable(const QString &name, const octave_value &val)
std::string url
Definition: urlwrite.cc:118
octave_interpreter(application *app_context)
Definition: main-window.cc:90
virtual QMenu * get_mru_menu(void)=0
static bool undo(void)
Definition: cmd-edit.cc:1489
void register_doc_signal(const QString &)
symbol_table & get_symbol_table(void)
Definition: interpreter.h:169
virtual void connect_visibility_changed(void)
void make_widget(bool dock=true)
std::string octave_name_version_copyright_copying_warranty_and_bugs(bool html, const std::string &extra_info)
Definition: version.cc:98
static QIcon icon(const QString &icon_name, bool fallback=true)
QAction * m_load_workspace_action
Definition: main-window.h:397
void undo_signal(void)
void handle_clear_workspace_request(void)
Definition: main-window.cc:383
static void redisplay(void)
Definition: cmd-edit.cc:1225
void open_file(const QString &file_name=QString(), int line=-1)
Definition: main-window.cc:421
octave::sys::time start
Definition: graphics.cc:12337
void handle_create_dialog(const QString &message, const QString &title, const QString &icon, const QStringList &button, const QString &defbutton, const QStringList &role)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
QAction * m_current_news_action
Definition: main-window.h:437
void configure_shortcuts(void)
void handle_variable_editor_update(void)
virtual bool check_closing(void)=0
void construct_new_menu(QMenu *p)
void clear_command_window_callback(void)
void handle_update_breakpoint_marker_request(bool insert, const QString &file, int line, const QString &cond)
p
Definition: lu.cc:138
documentation_dock_widget * m_doc_browser_window
Dock widgets.
Definition: main-window.h:370
octave_map map(dims)
void set_current_working_directory(const QString &dir)
Definition: main-window.cc:847
QAction * m_open_action
Definition: main-window.h:395
void show_doc_signal(const QString &)
virtual QMenu * debug_menu(void)=0
QAction * m_clear_workspace_action
Definition: main-window.h:408
void handle_create_inputlayout(const QStringList &, const QString &, const QFloatList &, const QFloatList &, const QStringList &)
void open_file_signal(const QString &)
b
Definition: cellfun.cc:400
OCTAVE_EXPORT octave_value_list Fcd(const octave_value_list &args, int nargout) the current directory is changed to the user 's home directory(@qcode
Definition: dirfns.cc:124
static QSettings * get_settings(void)
static void kill_full_line(void)
Definition: cmd-edit.cc:1461
octave_qt_link * m_octave_qt_link
Definition: main-window.h:461
void display_release_notes(void)
Definition: main-window.cc:440
void run_file_in_terminal(const QFileInfo &info)
Definition: main-window.cc:893
void handle_undo_request(void)
Definition: main-window.cc:398
std::pair< int, int > int_pair
Definition: main-window.h:103
void load_workspace_callback(const std::string &file)
QStatusBar * m_status_bar
Toolbar.
Definition: main-window.h:363
void restore_create_file_setting(void)
void construct_documentation_menu(QMenu *p)
void construct_tool_bar(void)
for i
Definition: data.cc:5264
QAction * m_clear_clipboard_action
Definition: main-window.h:404
void refresh_variable_editor(void)
void handle_create_listview(const QStringList &list, const QString &mode, int width, int height, const QIntList &initial, const QString &name, const QStringList &prompt, const QString &ok_string, const QString &cancel_string)
void setModel(workspace_model *model)
QList< int > QIntList
Definition: dialog.h:38
QAction * m_reset_windows_action
Definition: main-window.h:426
QMenu * m_add_menu(QMenuBar *p, QString text)
void insert_debugger_pointer_signal(const QString &file, int line)
void clipboard_has_changed(void)
Handling the clipboard.
bool initialized(void) const
Definition: interpreter.h:144
QList< octave_dock_widget * > dock_widget_list(void)
gui_application * m_app_context
Definition: main-window.h:351
void open_octave_packages_page(void)
Definition: main-window.cc:590
void request_open_files(const QStringList &open_file_names)
QAction * m_clear_command_history_action
Definition: main-window.h:407
void handle_show_doc(const QString &file)
QAction * m_about_octave_action
Definition: main-window.h:434
octave_interpreter * m_interpreter
Definition: main-window.h:353
void copy_image_to_clipboard(const QString &file, bool remove_file)
Definition: main-window.cc:625
QPointer< settings_dialog > m_settings_dlg
Settings dialog as guarded pointer (set to 0 when deleted).
Definition: main-window.h:449
QAction * m_show_editor_action
Definition: main-window.h:416
void set_screen_size(int ht, int wd)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
void handle_delete_debugger_pointer_request(const QString &file, int line)
void init_terminal_size(void)
void construct_help_menu(QMenuBar *p)
QAction * m_online_doc_action
Definition: main-window.h:429
void construct_news_menu(QMenuBar *p)
void handle_octave_finished(int)
QUIWidgetCreator uiwidget_creator
Definition: dialog.cc:46
void resize_command_window_callback(void)
QAction * m_debug_step_out
Definition: main-window.h:390
QAction * m_clear_command_window_action
Definition: main-window.h:406
QAction * m_octave_packages_action
Definition: main-window.h:431
void find_files_finished(int)
Find files dialog.
Definition: main-window.h:252
QAction * m_show_documentation_action
Definition: main-window.h:417
charNDArray min(char d, const charNDArray &m)
Definition: chNDArray.cc:204
void handle_exit_debugger(void)
Definition: main-window.cc:923
QAction * m_developer_action
Definition: main-window.h:433
void change_directory_up(void)
Definition: main-window.cc:860
void open_bug_tracker_page(void)
Definition: main-window.cc:585
static void clear_screen(bool skip_redisplay=false)
Definition: cmd-edit.cc:1246
to define functions rather than attempting to enter them directly on the command line The block of commands is executed as soon as you exit the editor To avoid executing any commands
Definition: oct-hist.cc:587
octave_command_queue m_cmd_queue
Command queue and semaphore to synchronize execution signals and related callbacks.
Definition: main-window.h:468
files_dock_widget * m_file_browser_window
Dock widgets.
Definition: main-window.h:369
QAction * m_command_window_action
Definition: main-window.h:419
OCTAVE_EXPORT octave_value_list directory
Definition: variables.cc:593
external_editor_interface * m_external_editor
Definition: main-window.h:376
void new_file_signal(const QString &)
QWidget * m_community_news_window
Definition: main-window.h:459