GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
main-window.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2013-2017 John W. Eaton
4 Copyright (C) 2011-2016 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 the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 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 <http://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 <QLabel>
31 #include <QMenuBar>
32 #include <QMenu>
33 #include <QAction>
34 #include <QSettings>
35 #include <QStyle>
36 #include <QToolBar>
37 #include <QDesktopServices>
38 #include <QDesktopWidget>
39 #include <QFileDialog>
40 #include <QMessageBox>
41 #include <QIcon>
42 #include <QTextStream>
43 #include <QThread>
44 #include <QDateTime>
45 #include <QDebug>
46 #include <QTimer>
47 
48 #include <utility>
49 
50 #if defined (HAVE_QSCINTILLA)
51 # include "file-editor.h"
52 #endif
53 #include "main-window.h"
54 #include "settings-dialog.h"
55 #include "shortcut-manager.h"
56 
57 #include "Array.h"
58 #include "cmd-edit.h"
59 #include "url-transfer.h"
60 
61 #include "builtin-defun-decls.h"
62 #include "defaults.h"
63 #include "octave.h"
64 #include "symtab.h"
65 #include "version.h"
66 #include "utils.h"
67 
68 static file_editor_interface *
70 {
71 #if defined (HAVE_QSCINTILLA)
72  return new file_editor (p);
73 #else
74  octave_unused_parameter (p);
75 
76  return 0;
77 #endif
78 }
79 
81  : QMainWindow (p), m_app_context (app_context), _workspace_model (0),
82  status_bar (0), command_window (0), history_window (0),
83  file_browser_window (0), doc_browser_window (0), editor_window (0),
84  workspace_window (0), _settings_dlg (0), find_files_dlg (0),
85  release_notes_window (0), community_news_window (0), _octave_qt_link (0),
86  _clipboard (QApplication::clipboard ()),
87  _prevent_readline_conflicts (true),
88  _suppress_dbg_location (true),
89  _start_gui (app_context && app_context->start_gui_p ())
90 {
91  if (_start_gui)
92  {
94  status_bar = new QStatusBar ();
100  workspace_window = new workspace_view (this);
101  }
102 
103  QSettings *settings = resource_manager::get_settings ();
104 
105  bool connect_to_web = true;
106  QDateTime last_checked;
107  int serial = 0;
108  _active_dock = 0;
109 
110  if (settings)
111  {
112  connect_to_web
113  = settings->value ("news/allow_web_connection", true).toBool ();
114 
115  last_checked
116  = settings->value ("news/last_time_checked", QDateTime ()).toDateTime ();
117 
118  serial = settings->value ("news/last_news_item", 0).toInt ();
119  }
120 
121  QDateTime current = QDateTime::currentDateTime ();
122  QDateTime one_day_ago = current.addDays (-1);
123 
124  if (_start_gui && connect_to_web
125  && (! last_checked.isValid () || one_day_ago > last_checked))
127 
128  // We have to set up all our windows, before we finally launch octave.
129  construct ();
130 }
131 
133 {
134  // Destroy the terminal first so that STDERR stream is redirected back
135  // to its original pipe to capture error messages at exit.
136 
137  delete editor_window; // first one for dialogs of modified editor-tabs
138  delete command_window;
139  delete workspace_window;
140  delete doc_browser_window;
141  delete file_browser_window;
142  delete history_window;
143  delete status_bar;
144  delete _workspace_model;
145  if (find_files_dlg)
146  {
147  delete find_files_dlg;
148  find_files_dlg = 0;
149  }
151  {
152  delete release_notes_window;
154  }
155  if (_settings_dlg)
156  {
157  delete _settings_dlg;
158  _settings_dlg = 0;
159  }
161  {
162  delete community_news_window;
164  }
165  delete _octave_qt_link;
166 }
167 
168 // catch focus changes and determine the active dock widget
169 void
171 {
172  octave_dock_widget* dock = 0;
173  QWidget *w_new = new_widget; // get a copy of new focus widget
174  QWidget *start = w_new; // Save it as start of our search
175  int count = 0; // fallback to prevent endless loop
176 
177  while (w_new && w_new != _main_tool_bar && count < 100)
178  {
179  dock = qobject_cast<octave_dock_widget *> (w_new);
180  if (dock)
181  break; // it is a QDockWidget ==> exit loop
182 
183 #if defined (HAVE_QSCINTILLA)
184  if (qobject_cast<octave_qscintilla *> (w_new))
185  {
186  dock = static_cast<octave_dock_widget *> (editor_window);
187  break; // it is the editor window ==> exit loop
188  }
189 #endif
190 
191  w_new = qobject_cast<QWidget *> (w_new->previousInFocusChain ());
192  if (w_new == start)
193  break; // we have arrived where we began ==> exit loop
194 
195  count++;
196  }
197 
198  // editor needs extra handling
199  octave_dock_widget *edit_dock_widget
200  = static_cast<octave_dock_widget *> (editor_window);
201  // if new dock has focus, emit signal and store active focus
202  // except editor changes to a dialog (dock=0)
203  if ((dock || _active_dock != edit_dock_widget) && (dock != _active_dock))
204  {
205  // signal to all dock widgets for updating the style
206  emit active_dock_changed (_active_dock, dock);
207 
208  QList<QDockWidget *> tabbed = tabifiedDockWidgets (dock);
209  if (tabbed.contains (_active_dock))
211 
212  if (edit_dock_widget == dock)
213  emit editor_focus_changed (true);
214  else if (edit_dock_widget == _active_dock)
215  emit editor_focus_changed (false);
216 
217  _active_dock = dock;
218  }
219 }
220 
221 bool
223 {
224  return command_window->has_focus ();
225 }
226 
227 void
229 {
230  command_window->focus ();
231 }
232 
233 void
235 {
236  emit new_file_signal (commands);
237 }
238 
239 void
240 main_window::open_file (const QString& file_name)
241 {
242  emit open_file_signal (file_name);
243 }
244 void
245 
246 main_window::edit_mfile (const QString& name, int line)
247 {
248  emit edit_mfile_request (name, QString (), QString (), line);
249 }
250 
251 void
252 main_window::report_status_message (const QString& statusMessage)
253 {
254  status_bar->showMessage (statusMessage, 1000);
255 }
256 
257 void
259 {
260  QString file
261  = QFileDialog::getSaveFileName (this, tr ("Save Workspace As"), ".", 0, 0,
262  QFileDialog::DontUseNativeDialog);
263 
264  if (! file.isEmpty ())
266  file.toStdString ());
267 }
268 
269 void
271 {
272  QString file = file_arg;
273 
274  if (file.isEmpty ())
275  file = QFileDialog::getOpenFileName (this, tr ("Load Workspace"), ".", 0, 0,
276  QFileDialog::DontUseNativeDialog);
277 
278  if (! file.isEmpty ())
280  file.toStdString ());
281 }
282 
283 void
285 {
287 }
288 
289 void
291  const QString& new_name)
292 
293 {
294  name_pair names (old_name.toStdString (), new_name.toStdString ());
295 
297  names);
298 }
299 
300 void
302 {
305  else
306  emit undo_signal ();
307 }
308 
309 void
311 {
313 }
314 
315 void
317 {
319 }
320 
321 bool
323 {
324  QSettings *settings = resource_manager::get_settings ();
325  return settings->value ("terminal/focus_after_command",false).toBool ();
326 }
327 
328 void
330 {
331  octave_cmd_exec *cmd = new octave_cmd_exec (command);
332  _cmd_queue.add_cmd (cmd);
335 }
336 
337 void
338 main_window::run_file_in_terminal (const QFileInfo& info)
339 {
343 }
344 
345 void
346 main_window::run_file_callback (const QFileInfo& info)
347 {
348  octave_cmd_eval *cmd = new octave_cmd_eval (info);
349  _cmd_queue.add_cmd (cmd);
350 }
351 
352 void
354 {
356 }
357 
358 void
360 {
361  QDesktopServices::openUrl (
362  QUrl ("http://octave.org/doc/interpreter/index.html"));
363 }
364 
365 void
367 {
368  if (! release_notes_window)
369  {
370  std::string news_file = Voct_etc_dir + "/NEWS";
371 
372  QString news;
373 
374  QFile *file = new QFile (QString::fromStdString (news_file));
375  if (file->open (QFile::ReadOnly))
376  {
377  QTextStream *stream = new QTextStream (file);
378  news = stream->readAll ();
379  if (! news.isEmpty ())
380  {
381  news.prepend ("<pre>");
382  news.append ("</pre>");
383  }
384  else
385  news = (tr ("The release notes file '%1' is empty.")
386  . arg (QString::fromStdString (news_file)));
387  }
388  else
389  news = (tr ("The release notes file '%1' cannot be read.")
390  . arg (QString::fromStdString (news_file)));
391 
393 
394  QTextBrowser *browser = new QTextBrowser (release_notes_window);
395  browser->setText (news);
396 
397  QVBoxLayout *vlayout = new QVBoxLayout;
398  vlayout->addWidget (browser);
399 
400  release_notes_window->setLayout (vlayout);
401  release_notes_window->setWindowTitle (tr ("Octave Release Notes"));
402 
403  browser->document()->adjustSize ();
404 
405  // center the window on the screen where octave is running
406  QDesktopWidget *m_desktop = QApplication::desktop ();
407  int screen = m_desktop->screenNumber (this); // screen of the main window
408  QRect screen_geo = m_desktop->availableGeometry (screen);
409  int win_x = screen_geo.width (); // width of the screen
410  int win_y = screen_geo.height (); // height of the screen
411  int reln_x = std::min (720, win_x-80); // desired width of release notes
412  int reln_y = std::min (740, win_y-80); // desired height of release notes
413  release_notes_window->resize (reln_x, reln_y); // set size
414  release_notes_window->move (20, 0); // move to the top left corner
415  }
416 
417  if (! release_notes_window->isVisible ())
418  release_notes_window->show ();
419  else if (release_notes_window->isMinimized ())
420  release_notes_window->showNormal ();
421 
422  release_notes_window->setWindowIcon (QIcon (_release_notes_icon));
423 
424  release_notes_window->raise ();
425  release_notes_window->activateWindow ();
426 }
427 
428 void
430 {
431  QString html_text;
432 
433  if (connect_to_web)
434  {
435  // Run this part in a separate thread so Octave can continue to
436  // run while we wait for the page to load. Then emit the signal
437  // to display it when we have the page contents.
438 
439  QString url = base_url + "/" + page;
440  std::ostringstream buf;
441  octave::url_transfer octave_dot_org (url.toStdString (), buf);
442 
443  if (octave_dot_org.is_valid ())
444  {
446  octave_dot_org.http_get (param);
447 
448  if (octave_dot_org.good ())
449  html_text = QString::fromStdString (buf.str ());
450  }
451 
452  if (html_text.contains ("this-is-the-gnu-octave-community-news-page"))
453  {
454  if (serial >= 0)
455  {
456  QSettings *settings = resource_manager::get_settings ();
457 
458  if (settings)
459  {
460  settings->setValue ("news/last_time_checked",
461  QDateTime::currentDateTime ());
462 
463  settings->sync ();
464  }
465 
466  QString tag ("community-news-page-serial=");
467 
468  int b = html_text.indexOf (tag);
469 
470  if (b)
471  {
472  b += tag.length ();
473 
474  int e = html_text.indexOf ("\n", b);
475 
476  QString tmp = html_text.mid (b, e-b);
477 
478  int curr_page_serial = tmp.toInt ();
479 
480  if (curr_page_serial > serial)
481  {
482  if (settings)
483  {
484  settings->setValue ("news/last_news_item",
485  curr_page_serial);
486 
487  settings->sync ();
488  }
489  }
490  else
491  return;
492  }
493  else
494  return;
495  }
496  }
497  else
498  html_text = QString
499  (tr ("<html>\n"
500  "<body>\n"
501  "<p>\n"
502  "Octave's community news source seems to be unavailable.\n"
503  "</p>\n"
504  "<p>\n"
505  "For the latest news, please check\n"
506  "<a href=\"http://octave.org/community-news.html\">http://octave.org/community-news.html</a>\n"
507  "when you have a connection to the web (link opens in an external browser).\n"
508  "</p>\n"
509  "<p>\n"
510  "<small><em>&mdash; The Octave Developers, ") + OCTAVE_RELEASE_DATE + "</em></small>\n"
511  "</p>\n"
512  "</body>\n"
513  "</html>\n");
514  }
515  else
516  html_text = QString
517  (tr ("<html>\n"
518  "<body>\n"
519  "<p>\n"
520  "Connecting to the web to display the latest Octave Community news has been disabled.\n"
521  "</p>\n"
522  "<p>\n"
523  "For the latest news, please check\n"
524  "<a href=\"http://octave.org/community-news.html\">http://octave.org/community-news.html</a>\n"
525  "when you have a connection to the web (link opens in an external browser)\n"
526  "or enable web connections for news in Octave's network settings dialog.\n"
527  "</p>\n"
528  "<p>\n"
529  "<small><em>&mdash; The Octave Developers, ") + OCTAVE_RELEASE_DATE + "</em></small>\n"
530  "</p>\n"
531  "</body>\n"
532  "</html>\n");
533 
534  emit display_news_signal (html_text);
535 
536  emit finished ();
537 }
538 
539 void
541 {
542  QSettings *settings = resource_manager::get_settings ();
543 
544  bool connect_to_web
545  = (settings
546  ? settings->value ("news/allow_web_connection", true).toBool ()
547  : true);
548 
549  QString base_url = "http://octave.org";
550  QString page = "community-news.html";
551 
552  QThread *worker_thread = new QThread;
553 
554  news_reader *reader = new news_reader (base_url, page, serial,
555  connect_to_web);
556 
557  reader->moveToThread (worker_thread);
558 
559  connect (reader, SIGNAL (display_news_signal (const QString&)),
560  this, SLOT (display_community_news (const QString&)));
561 
562  connect (worker_thread, SIGNAL (started (void)),
563  reader, SLOT (process ()));
564 
565  connect (reader, SIGNAL (finished (void)), worker_thread, SLOT (quit ()));
566 
567  connect (reader, SIGNAL (finished (void)), reader, SLOT (deleteLater ()));
568 
569  connect (worker_thread, SIGNAL (finished (void)),
570  worker_thread, SLOT (deleteLater ()));
571 
572  worker_thread->start ();
573 }
574 
575 void
577 {
578  if (! community_news_window)
579  {
581 
582  QTextBrowser *browser = new QTextBrowser (community_news_window);
583 
584  browser->setHtml (news);
585  browser->setObjectName ("OctaveNews");
586  browser->setOpenExternalLinks (true);
587 
588  QVBoxLayout *vlayout = new QVBoxLayout;
589 
590  vlayout->addWidget (browser);
591 
592  community_news_window->setLayout (vlayout);
593  community_news_window->setWindowTitle (tr ("Octave Community News"));
594 
595  // center the window on the screen where octave is running
596  QDesktopWidget *m_desktop = QApplication::desktop ();
597  int screen = m_desktop->screenNumber (this); // screen of the main window
598  QRect screen_geo = m_desktop->availableGeometry (screen);
599  int win_x = screen_geo.width (); // width of the screen
600  int win_y = screen_geo.height (); // height of the screen
601  int news_x = std::min (640, win_x-80); // desired width of news window
602  int news_y = std::min (480, win_y-80); // desired height of news window
603  community_news_window->resize (news_x, news_y); // set size and center
604  community_news_window->move ((win_x - community_news_window->width ())/2,
605  (win_y - community_news_window->height ())/2);
606  }
607 
608  if (! community_news_window->isVisible ())
609  community_news_window->show ();
610  else if (community_news_window->isMinimized ())
611  community_news_window->showNormal ();
612 
613  // same icon as release notes
614  community_news_window->setWindowIcon (QIcon (_release_notes_icon));
615 
616  community_news_window->raise ();
617  community_news_window->activateWindow ();
618 }
619 
620 void
622 {
623  QDesktopServices::openUrl (QUrl ("http://octave.org/bugs.html"));
624 }
625 
626 void
628 {
629  QDesktopServices::openUrl (QUrl ("http://octave.org/packages.html"));
630 }
631 
632 void
634 {
635  QDesktopServices::openUrl (QUrl ("http://octave.org/contribute.html"));
636 }
637 
638 void
640 {
641  QDesktopServices::openUrl (QUrl ("http://octave.org/donate.html"));
642 }
643 
644 void
646 {
647  if (_settings_dlg) // _settings_dlg is a guarded pointer!
648  {
649  // here the dialog is still open and called once again
650  if (! desired_tab.isEmpty ())
651  _settings_dlg->show_tab (desired_tab);
652  return;
653  }
654 
655  _settings_dlg = new settings_dialog (this, desired_tab);
656 
657  connect (_settings_dlg, SIGNAL (apply_new_settings ()),
658  this, SLOT (request_reload_settings ()));
659 
660  _settings_dlg->setModal (false);
661  _settings_dlg->setAttribute (Qt::WA_DeleteOnClose);
662  _settings_dlg->show ();
663 }
664 
665 void
666 main_window::copy_image_to_clipboard (const QString& file, bool remove_file)
667 {
668  QClipboard *clipboard = QApplication::clipboard ();
669 
670  QImage img (file);
671 
672  if (img.isNull ())
673  {
674  // Report error?
675  return;
676  }
677 
678  clipboard->setImage (img);
679 
680  if (remove_file)
681  QFile::remove (file);
682 }
683 
684 void
686 {
687  QSettings *settings = resource_manager::get_settings ();
688 
689  if (settings)
690  emit settings_changed (settings);
691 }
692 
693 void
694 main_window::notice_settings (const QSettings *settings)
695 {
696  // QSettings pointer is checked before emitting.
697 
698  // the widget's icons (when floating)
699  QString icon_set
700  = settings->value ("DockWidgets/widget_icon_set", "NONE").toString ();
701 
702  static struct
703  {
704  QString name;
705  QString path;
706  }
707 
708  widget_icon_data[] =
709  {
710  // array of possible icon sets (name, path (complete for NONE))
711  // the first entry here is the default!
712  {"NONE", ":/actions/icons/logo.png"},
713  {"GRAPHIC", ":/actions/icons/graphic_logo_"},
714  {"LETTER", ":/actions/icons/letter_logo_"},
715  {"", ""} // end marker has empty name
716  };
717 
718  int count = 0;
719  int icon_set_found = 0; // default
720 
721  while (! widget_icon_data[count].name.isEmpty ())
722  {
723  // while not end of data
724  if (widget_icon_data[count].name == icon_set)
725  {
726  // data of desired icon set found
727  icon_set_found = count;
728  break;
729  }
730  count++;
731  }
732 
733  QString icon;
734  foreach (octave_dock_widget *widget, dock_widget_list ())
735  {
736  QString name = widget->objectName ();
737  if (! name.isEmpty ())
738  { // if children has a name
739  icon = widget_icon_data[icon_set_found].path; // prefix | octave-logo
740  if (widget_icon_data[icon_set_found].name != "NONE")
741  icon += name + ".png"; // add widget name and ext.
742  widget->setWindowIcon (QIcon (icon));
743  }
744  }
745  if (widget_icon_data[icon_set_found].name != "NONE")
746  _release_notes_icon = widget_icon_data[icon_set_found].path
747  + "ReleaseWidget.png";
748  else
749  _release_notes_icon = ":/actions/icons/logo.png";
750 
751  int icon_size_settings = settings->value ("toolbar_icon_size",0).toInt ();
752  QStyle *st = style ();
753  int icon_size = st->pixelMetric (QStyle::PM_ToolBarIconSize);
754 
755  if (icon_size_settings == 1)
756  icon_size = st->pixelMetric (QStyle::PM_LargeIconSize);
757  else if (icon_size_settings == -1)
758  icon_size = st->pixelMetric (QStyle::PM_SmallIconSize);
759 
760  _main_tool_bar->setIconSize (QSize (icon_size,icon_size));
761 
762  if (settings->value ("show_status_bar",true).toBool ())
763  status_bar->show ();
764  else
765  status_bar->hide ();
766 
768  = settings->value ("shortcuts/prevent_readline_conflicts", true).toBool ();
769 
771  = ! settings->value ("terminal/print_debug_location", false).toBool ();
772 
774 
775  emit active_dock_changed (0, _active_dock); // update dock widget styles
776 
780 }
781 
782 void
784 {
785  bool closenow = true;
786 
787  if (_start_gui)
788  {
789  QSettings *settings = resource_manager::get_settings ();
790 
791  if (settings->value ("prompt_to_exit", false).toBool ())
792  {
793  int ans = QMessageBox::question (this, tr ("Octave"),
794  tr ("Are you sure you want to exit Octave?"),
795  (QMessageBox::Ok
796  | QMessageBox::Cancel),
797  QMessageBox::Ok);
798 
799  if (ans != QMessageBox::Ok)
800  closenow = false;
801  }
802 
803 #if defined (HAVE_QSCINTILLA)
804  if (closenow)
805  closenow = editor_window->check_closing ();
806 #endif
807  }
808 
809  // Wait for link thread to go to sleep state.
810  _octave_qt_link->mutex.lock ();
811 
813 
814  _octave_qt_link->mutex.unlock ();
815 
816  // Awake the worker thread so that it continues shutting down (or not).
817  _octave_qt_link->waitcondition.wakeAll ();
818 
819 }
820 
821 void
823 {
824  // Find files dialog is constructed dynamically, not at time of main_window
825  // construction. Connecting it to qApp aboutToQuit signal would have
826  // caused it to run after QSettings deleted.
827  if (find_files_dlg)
829 
830  write_settings ();
831 }
832 
833 void
835 {
836  qApp->exit (status);
837 }
838 
839 void
841 {
842  QSettings *settings = resource_manager::get_default_settings ();
843 
844  set_window_layout (settings);
845  showNormal (); // make sure main window is not minimized
846 }
847 
848 void
849 main_window::change_directory (const QString& dir)
850 {
851  // Remove existing entry, if any, then add new directory at top and
852  // mark it as the current directory. Finally, update the file list
853  // widget.
854 
855  int index = _current_directory_combo_box->findText (dir);
856 
857  if (index >= 0)
858  _current_directory_combo_box->removeItem (index);
859 
860  _current_directory_combo_box->insertItem (0, dir);
861  _current_directory_combo_box->setCurrentIndex (0);
862 }
863 
864 void
866 {
867  QString dir
868  = QFileDialog::getExistingDirectory (this, tr ("Browse directories"), 0,
869  QFileDialog::ShowDirsOnly |
870  QFileDialog::DontUseNativeDialog);
871 
873 
874  // FIXME: on Windows systems, the command window freezes after the
875  // previous actions. Forcing the focus appears to unstick it.
876 
878 }
879 
880 void
882 {
883  // Change to dir if it is an existing directory.
884 
885  QString xdir = dir.isEmpty () ? "." : dir;
886 
887  QFileInfo fileInfo (xdir);
888 
889  if (fileInfo.exists () && fileInfo.isDir ())
891  xdir.toStdString ());
892 }
893 
894 void
896 {
898 }
899 
900 // Slot that is called if return is pressed in the line edit of the
901 // combobox to change to a new directory or a directory that is already
902 // in the drop down list.
903 
904 void
906 {
907  // Get new directory name, and change to it if it is new. Otherwise,
908  // the combo box will triggers the "activated" signal to change to the
909  // directory.
910 
911  QString dir = _current_directory_combo_box->currentText ();
912 
913  int index = _current_directory_combo_box->findText (dir);
914 
915  if (index < 0)
917 }
918 
919 void
921 {
922  setWindowTitle ("Octave (Debugging)");
923 
924  _debug_continue->setEnabled (true);
925  _debug_step_into->setEnabled (true);
926  _debug_step_over->setEnabled (true);
927  _debug_step_out->setEnabled (true);
928  _debug_quit->setEnabled (true);
929 
930 #if defined (HAVE_QSCINTILLA)
932 #endif
933 }
934 
935 void
937 {
938  setWindowTitle ("Octave");
939 
940  _debug_continue->setEnabled (false);
941  _debug_step_into->setEnabled (false);
942  _debug_step_over->setEnabled (false);
943  _debug_step_out->setEnabled (false);
944  _debug_quit->setEnabled (false);
945 
946 #if defined (HAVE_QSCINTILLA)
948 #endif
949 }
950 
951 void
953 {
954  octave_cmd_debug *cmd
956  _cmd_queue.add_cmd (cmd);
957 }
958 
959 void
961 {
963  _cmd_queue.add_cmd (cmd);
964 }
965 
966 void
968 {
969  octave_cmd_debug *cmd
971  _cmd_queue.add_cmd (cmd);
972 }
973 
974 void
976 {
978  _cmd_queue.add_cmd (cmd);
979 }
980 
981 void
983 {
984  octave_cmd_debug *cmd
986  _cmd_queue.add_cmd (cmd);
987 }
988 
989 void
991  int line)
992 {
993  bool cmd_focus = command_window_has_focus ();
994 
995  emit insert_debugger_pointer_signal (file, line);
996 
997  if (cmd_focus)
999 }
1000 
1001 void
1003  int line)
1004 {
1005  bool cmd_focus = command_window_has_focus ();
1006 
1007  emit delete_debugger_pointer_signal (file, line);
1008 
1009  if (cmd_focus)
1011 }
1012 
1013 void
1015  const QString& file,
1016  int line,
1017  const QString& cond)
1018 {
1019  bool cmd_focus = command_window_has_focus ();
1020 
1021  emit update_breakpoint_marker_signal (insert, file, line, cond);
1022 
1023  if (cmd_focus)
1025 }
1026 
1027 void
1029 {
1032 
1033  QMessageBox::about (this, tr ("About Octave"),
1034  QString::fromStdString (message));
1035 }
1036 
1037 void
1039 {
1040  e->ignore ();
1041  octave_cmd_exec *cmd = new octave_cmd_exec ("exit");
1042  _cmd_queue.add_cmd (cmd);
1043 }
1044 
1045 void
1047 {
1048  QSettings *settings = resource_manager::get_settings ();
1049 
1050  if (! settings)
1051  {
1052  qDebug ("Error: QSettings pointer from resource manager is NULL.");
1053  return;
1054  }
1055 
1056  set_window_layout (settings);
1057 
1058  // restore the list of the last directories
1059  QStringList curr_dirs
1060  = settings->value ("MainWindow/current_directory_list").toStringList ();
1061  for (int i=0; i < curr_dirs.size (); i++)
1062  {
1063  _current_directory_combo_box->addItem (curr_dirs.at (i));
1064  }
1065  emit settings_changed (settings);
1066 }
1067 
1068 void
1070 {
1071  emit init_terminal_size_signal ();
1072 }
1073 
1074 void
1075 main_window::set_window_layout (QSettings *settings)
1076 {
1077 #if ! defined (Q_OS_WIN32)
1078  restoreState (settings->value ("MainWindow/windowState").toByteArray ());
1079  restoreGeometry (settings->value ("MainWindow/geometry").toByteArray ());
1080 #endif
1081 
1082  // Restore the geometry of all dock-widgets
1083  foreach (octave_dock_widget *widget, dock_widget_list ())
1084  {
1085  QString name = widget->objectName ();
1086 
1087  if (! name.isEmpty ())
1088  {
1089  bool floating = settings->value
1090  ("DockWidgets/" + name + "Floating", false).toBool ();
1091  bool visible = settings->value
1092  ("DockWidgets/" + name + "Visible", true).toBool ();
1093 
1094  // If floating, make window from widget.
1095  if (floating)
1096  widget->make_window ();
1097  else if (! widget->parent ()) // should not be floating but is
1098  widget->make_widget (false); // no docking, just reparent
1099 #if ! defined (Q_OS_WIN32)
1100  // restore geometry
1101  QVariant val = settings->value ("DockWidgets/" + name);
1102  widget->restoreGeometry (val.toByteArray ());
1103 #endif
1104  // make widget visible if desired
1105  if (floating && visible) // floating and visible
1106  {
1107  if (settings->value ("DockWidgets/" + widget->objectName ()
1108  + "_minimized").toBool ())
1109  widget->showMinimized ();
1110  else
1111  widget->setVisible (true);
1112  }
1113  else
1114  {
1115  widget->make_widget ();
1116  widget->setVisible (visible); // not floating -> show
1117  }
1118  }
1119  }
1120 
1121 #if defined (Q_OS_WIN32)
1122  restoreState (settings->value ("MainWindow/windowState").toByteArray ());
1123  restoreGeometry (settings->value ("MainWindow/geometry").toByteArray ());
1124 #endif
1125 
1126  show ();
1127 }
1128 
1129 void
1131 {
1132  QSettings *settings = resource_manager::get_settings ();
1133  if (! settings)
1134  {
1135  qDebug ("Error: QSettings pointer from resource manager is NULL.");
1136  return;
1137  }
1138 
1139  settings->setValue ("MainWindow/geometry", saveGeometry ());
1140  settings->setValue ("MainWindow/windowState", saveState ());
1141  // write the list of recent used directories
1142  QStringList curr_dirs;
1143  for (int i=0; i<_current_directory_combo_box->count (); i++)
1144  {
1145  curr_dirs.append (_current_directory_combo_box->itemText (i));
1146  }
1147  settings->setValue ("MainWindow/current_directory_list", curr_dirs);
1148  settings->sync ();
1149 }
1150 
1151 // Connecting the signals emitted when the visibility of a widget changes.
1152 // This has to be done after the window is shown (see octave-gui.cc)
1153 void
1155 {
1156  foreach (octave_dock_widget *widget, dock_widget_list ())
1157  widget->connect_visibility_changed ();
1158 
1159 #if defined (HAVE_QSCINTILLA)
1161 #endif
1162 }
1163 
1164 void
1166 {
1167  if (_current_directory_combo_box->hasFocus ())
1168  {
1169  QLineEdit * edit = _current_directory_combo_box->lineEdit ();
1170  if (edit && edit->hasSelectedText ())
1171  {
1172  QClipboard *clipboard = QApplication::clipboard ();
1173  clipboard->setText (edit->selectedText ());
1174  }
1175  }
1176  else
1177  emit copyClipboard_signal ();
1178 }
1179 
1180 void
1182 {
1183  if (_current_directory_combo_box->hasFocus ())
1184  {
1185  QLineEdit * edit = _current_directory_combo_box->lineEdit ();
1186  QClipboard *clipboard = QApplication::clipboard ();
1187  QString str = clipboard->text ();
1188  if (edit && str.length () > 0)
1189  {
1190  edit->insert (str);
1191  }
1192  }
1193  else
1194  emit pasteClipboard_signal ();
1195 }
1196 
1197 void
1199 {
1200  if (_current_directory_combo_box->hasFocus ())
1201  {
1202  QLineEdit * edit = _current_directory_combo_box->lineEdit ();
1203  if (edit)
1204  {
1205  edit->selectAll ();
1206  }
1207  }
1208  else
1209  emit selectAll_signal ();
1210 }
1211 
1212 // Connect the signals emitted when the Octave thread wants to create
1213 // a dialog box of some sort. Perhaps a better place for this would be
1214 // as part of the QUIWidgetCreator class. However, mainWindow currently
1215 // is not a global variable and not accessible for connecting.
1216 
1217 void
1219 {
1220  connect (&uiwidget_creator,
1221  SIGNAL (create_dialog (const QString&, const QString&,
1222  const QString&, const QStringList&,
1223  const QString&, const QStringList&)),
1224  this,
1225  SLOT (handle_create_dialog (const QString&, const QString&,
1226  const QString&, const QStringList&,
1227  const QString&, const QStringList&)));
1228 
1229  // Register QIntList so that list of ints may be part of a signal.
1230  qRegisterMetaType<QIntList> ("QIntList");
1231  connect (&uiwidget_creator,
1232  SIGNAL (create_listview (const QStringList&, const QString&,
1233  int, int, const QIntList&,
1234  const QString&, const QStringList&,
1235  const QString&, const QString&)),
1236  this,
1237  SLOT (handle_create_listview (const QStringList&, const QString&,
1238  int, int, const QIntList&,
1239  const QString&, const QStringList&,
1240  const QString&, const QString&)));
1241 
1242  // Register QFloatList so that list of floats may be part of a signal.
1243  qRegisterMetaType<QFloatList> ("QFloatList");
1244  connect (&uiwidget_creator,
1245  SIGNAL (create_inputlayout (const QStringList&, const QString&,
1246  const QFloatList&, const QFloatList&,
1247  const QStringList&)),
1248  this,
1249  SLOT (handle_create_inputlayout (const QStringList&, const QString&,
1250  const QFloatList&,
1251  const QFloatList&,
1252  const QStringList&)));
1253 
1254  connect (&uiwidget_creator,
1255  SIGNAL (create_filedialog (const QStringList &,const QString&,
1256  const QString&, const QString&,
1257  const QString&)),
1258  this,
1259  SLOT (handle_create_filedialog (const QStringList &, const QString&,
1260  const QString&, const QString&,
1261  const QString&)));
1262 }
1263 
1264 // Create a message dialog with specified string, buttons and decorative
1265 // text.
1266 
1267 void
1269  const QString& title,
1270  const QString& icon,
1271  const QStringList& button,
1272  const QString& defbutton,
1273  const QStringList& role)
1274 {
1275  MessageDialog *message_dialog = new MessageDialog (message, title, icon,
1276  button, defbutton, role);
1277  message_dialog->setAttribute (Qt::WA_DeleteOnClose);
1278  message_dialog->show ();
1279 }
1280 
1281 // Create a list dialog with specified list, initially selected, mode,
1282 // view size and decorative text.
1283 
1284 void
1286  const QString& mode,
1287  int wd, int ht,
1288  const QIntList& initial,
1289  const QString& name,
1290  const QStringList& prompt,
1291  const QString& ok_string,
1292  const QString& cancel_string)
1293 {
1294  ListDialog *list_dialog = new ListDialog (list, mode, wd, ht,
1295  initial, name, prompt,
1296  ok_string, cancel_string);
1297 
1298  list_dialog->setAttribute (Qt::WA_DeleteOnClose);
1299  list_dialog->show ();
1300 }
1301 
1302 // Create an input dialog with specified prompts and defaults, title and
1303 // row/column size specifications.
1304 void
1305 main_window::handle_create_inputlayout (const QStringList& prompt,
1306  const QString& title,
1307  const QFloatList& nr,
1308  const QFloatList& nc,
1309  const QStringList& defaults)
1310 {
1311  InputDialog *input_dialog = new InputDialog (prompt, title, nr, nc,
1312  defaults);
1313 
1314  input_dialog->setAttribute (Qt::WA_DeleteOnClose);
1315  input_dialog->show ();
1316 }
1317 
1318 void
1319 main_window::handle_create_filedialog (const QStringList& filters,
1320  const QString& title,
1321  const QString& filename,
1322  const QString& dirname,
1323  const QString& multimode)
1324 {
1325  FileDialog *file_dialog = new FileDialog (filters, title, filename,
1326  dirname, multimode);
1327 
1328  file_dialog->setAttribute (Qt::WA_DeleteOnClose);
1329  file_dialog->show ();
1330 }
1331 
1332 // Main subroutine of the constructor
1333 void
1335 {
1336  _closing = false; // flag for editor files when closed
1337 
1338  // Create and set the central widget. QMainWindow takes ownership of
1339  // the widget (pointer) so there is no need to delete the object upon
1340  // destroying this main_window.
1341 
1342  QWidget *dummyWidget = new QWidget ();
1343  dummyWidget->setObjectName ("CentralDummyWidget");
1344  dummyWidget->resize (10, 10);
1345  dummyWidget->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum);
1346  dummyWidget->hide ();
1347  setCentralWidget (dummyWidget);
1348 
1350 
1352 
1353  if (_start_gui)
1354  {
1355  setWindowIcon (QIcon (":/actions/icons/logo.png"));
1356 
1358  connect (_workspace_model, SIGNAL (model_changed (void)),
1359  workspace_window, SLOT (handle_model_changed (void)));
1360 
1361  construct_menu_bar ();
1362 
1363  construct_tool_bar ();
1364 
1365  // Order is important. Deleting QSettings must be last.
1366  connect (qApp, SIGNAL (aboutToQuit ()),
1367  command_window, SLOT (save_settings ()));
1368  connect (qApp, SIGNAL (aboutToQuit ()),
1369  history_window, SLOT (save_settings ()));
1370  connect (qApp, SIGNAL (aboutToQuit ()),
1371  file_browser_window, SLOT (save_settings ()));
1372  connect (qApp, SIGNAL (aboutToQuit ()),
1373  doc_browser_window, SLOT (save_settings ()));
1374  connect (qApp, SIGNAL (aboutToQuit ()),
1375  workspace_window, SLOT (save_settings ()));
1376  connect (qApp, SIGNAL (aboutToQuit ()),
1377  editor_window, SLOT (save_settings ()));
1378  connect (qApp, SIGNAL (aboutToQuit ()),
1379  this, SLOT (prepare_to_exit ()));
1380  connect (qApp, SIGNAL (aboutToQuit ()),
1381  shortcut_manager::instance, SLOT (cleanup_instance ()));
1382  // QSettings are saved upon deletion (i.e., cleanup_instance)
1383  connect (qApp, SIGNAL (aboutToQuit ()),
1384  resource_manager::instance, SLOT (cleanup_instance ()));
1385 
1386  connect (qApp, SIGNAL (focusChanged (QWidget*, QWidget*)),
1387  this, SLOT(focus_changed (QWidget*, QWidget*)));
1388 
1389  connect (this, SIGNAL (settings_changed (const QSettings *)),
1390  this, SLOT (notice_settings (const QSettings *)));
1391 
1392  connect (this, SIGNAL (editor_focus_changed (bool)),
1393  this, SLOT (disable_menu_shortcuts (bool)));
1394 
1395  connect (this, SIGNAL (editor_focus_changed (bool)),
1396  editor_window, SLOT (enable_menu_shortcuts (bool)));
1397 
1398  connect (file_browser_window, SIGNAL (load_file_signal (const QString&)),
1399  this, SLOT (handle_load_workspace_request (const QString&)));
1400 
1401  connect (file_browser_window, SIGNAL (find_files_signal (const QString&)),
1402  this, SLOT (find_files (const QString&)));
1403 
1404  setWindowTitle ("Octave");
1405 
1406  setDockOptions (QMainWindow::AnimatedDocks
1407  | QMainWindow::AllowNestedDocks
1408  | QMainWindow::AllowTabbedDocks);
1409 
1410  addDockWidget (Qt::RightDockWidgetArea, command_window);
1411  addDockWidget (Qt::RightDockWidgetArea, doc_browser_window);
1412  tabifyDockWidget (command_window, doc_browser_window);
1413 
1414 #if defined (HAVE_QSCINTILLA)
1415  addDockWidget (Qt::RightDockWidgetArea, editor_window);
1416  tabifyDockWidget (command_window, editor_window);
1417 #endif
1418 
1419  addDockWidget (Qt::LeftDockWidgetArea, file_browser_window);
1420  addDockWidget (Qt::LeftDockWidgetArea, workspace_window);
1421  addDockWidget (Qt::LeftDockWidgetArea, history_window);
1422 
1423  int win_x = QApplication::desktop ()->width ();
1424  int win_y = QApplication::desktop ()->height ();
1425 
1426  if (win_x > 960)
1427  win_x = 960;
1428 
1429  if (win_y > 720)
1430  win_y = 720;
1431 
1432  setGeometry (0, 0, win_x, win_y);
1433 
1434  setStatusBar (status_bar);
1435 
1436 #if defined (HAVE_QSCINTILLA)
1437  connect (this,
1438  SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
1439  editor_window,
1440  SLOT (handle_insert_debugger_pointer_request (const QString&,
1441  int)));
1442 
1443  connect (this,
1444  SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
1445  editor_window,
1446  SLOT (handle_delete_debugger_pointer_request (const QString&,
1447  int)));
1448 
1449  connect (this,
1450  SIGNAL (update_breakpoint_marker_signal (bool, const QString&,
1451  int, const QString&)),
1452  editor_window,
1454  const QString&,
1455  int,
1456  const QString&)));
1457 #endif
1458 
1461 
1463  }
1464 }
1465 
1466 void
1468 {
1469  // actions after the startup files are executed
1470  QSettings *settings = resource_manager::get_settings ();
1471 
1472  QDir startup_dir = QDir (); // current octave dir after startup
1473 
1474  if (settings)
1475  {
1476  if (settings->value ("restore_octave_dir").toBool ())
1477  {
1478  // restore last dir from previous session
1479  QStringList curr_dirs
1480  = settings->value ("MainWindow/current_directory_list").toStringList ();
1481  startup_dir
1482  = QDir (curr_dirs.at (0)); // last dir in previous session
1483  }
1484  else if (! settings->value ("octave_startup_dir").toString ().isEmpty ())
1485  {
1486  // do not restore but there is a startup dir configured
1487  startup_dir
1488  = QDir (settings->value ("octave_startup_dir").toString ());
1489  }
1490  }
1491 
1492  if (! startup_dir.exists ())
1493  {
1494  // the configured startup dir does not exist, take actual one
1495  startup_dir = QDir ();
1496  }
1497 
1498  set_current_working_directory (startup_dir.absolutePath ());
1499 
1500  if (editor_window)
1501  {
1502 #if defined (HAVE_QSCINTILLA)
1503  // Octave ready, determine whether to create an empty script.
1504  // This can not be done when the editor is created because all functions
1505  // must be known for the lexer's auto completion informations
1506  editor_window->empty_script (true, false);
1507 #endif
1508  }
1509 
1510  if (_start_gui)
1511  focus_command_window (); // make sure that the command window has focus
1512 
1513 }
1514 
1515 void
1517 {
1519 
1520  connect (_octave_qt_link, SIGNAL (exit_app_signal (int)),
1521  this, SLOT (exit_app (int)));
1522 
1523  connect (_octave_qt_link, SIGNAL (confirm_shutdown_signal ()),
1524  this, SLOT (confirm_shutdown_octave ()));
1525 
1526  connect (_octave_qt_link,
1527  SIGNAL (copy_image_to_clipboard_signal (const QString&, bool)),
1528  this, SLOT (copy_image_to_clipboard (const QString&, bool)));
1529 
1530  if (_start_gui)
1531  {
1532  connect (_octave_qt_link,
1533  SIGNAL (set_workspace_signal
1534  (bool, bool, const QString&, const QStringList&,
1535  const QStringList&, const QStringList&,
1536  const QStringList&, const QIntList&)),
1538  SLOT (set_workspace
1539  (bool, bool, const QString&, const QStringList&,
1540  const QStringList&, const QStringList&,
1541  const QStringList&, const QIntList&)));
1542 
1543  connect (_octave_qt_link, SIGNAL (clear_workspace_signal ()),
1544  _workspace_model, SLOT (clear_workspace ()));
1545 
1546  connect (_octave_qt_link, SIGNAL (change_directory_signal (QString)),
1547  this, SLOT (change_directory (QString)));
1548  connect (_octave_qt_link, SIGNAL (change_directory_signal (QString)),
1549  file_browser_window, SLOT (update_octave_directory (QString)));
1550  connect (_octave_qt_link, SIGNAL (change_directory_signal (QString)),
1551  editor_window, SLOT (update_octave_directory (QString)));
1552 
1553  connect (_octave_qt_link,
1554  SIGNAL (execute_command_in_terminal_signal (QString)),
1555  this, SLOT (execute_command_in_terminal (QString)));
1556 
1557  connect (_octave_qt_link,
1558  SIGNAL (set_history_signal (const QStringList&)),
1559  history_window, SLOT (set_history (const QStringList&)));
1560 
1561  connect (_octave_qt_link,
1562  SIGNAL (append_history_signal (const QString&)),
1563  history_window, SLOT (append_history (const QString&)));
1564 
1565  connect (_octave_qt_link,
1566  SIGNAL (clear_history_signal (void)),
1567  history_window, SLOT (clear_history (void)));
1568 
1569  connect (_octave_qt_link, SIGNAL (enter_debugger_signal ()),
1570  this, SLOT (handle_enter_debugger ()));
1571 
1572  connect (_octave_qt_link, SIGNAL (exit_debugger_signal ()),
1573  this, SLOT (handle_exit_debugger ()));
1574 
1575  connect (_octave_qt_link,
1576  SIGNAL (show_preferences_signal (void)),
1577  this, SLOT (process_settings_dialog_request ()));
1578 
1579 #if defined (HAVE_QSCINTILLA)
1580  connect (_octave_qt_link,
1581  SIGNAL (edit_file_signal (const QString&)),
1582  editor_window,
1583  SLOT (handle_edit_file_request (const QString&)));
1584 #endif
1585 
1586  connect (_octave_qt_link,
1587  SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
1588  this,
1589  SLOT (handle_insert_debugger_pointer_request (const QString&,
1590  int)));
1591 
1592  connect (_octave_qt_link,
1593  SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
1594  this,
1595  SLOT (handle_delete_debugger_pointer_request (const QString&,
1596  int)));
1597 
1598  connect (_octave_qt_link,
1599  SIGNAL (update_breakpoint_marker_signal (bool, const QString&,
1600  int, const QString&)),
1601  this,
1603  const QString&,
1604  int,
1605  const QString&)));
1606 
1607  connect (_octave_qt_link,
1608  SIGNAL (show_doc_signal (const QString &)),
1609  this, SLOT (handle_show_doc (const QString &)));
1610 
1611  connect (_workspace_model,
1612  SIGNAL (rename_variable (const QString&, const QString&)),
1613  this,
1614  SLOT (handle_rename_variable_request (const QString&,
1615  const QString&)));
1616 
1617  connect (command_window, SIGNAL (interrupt_signal (void)),
1618  _octave_qt_link, SLOT (terminal_interrupt (void)));
1619  }
1620 
1622 
1623  // Defer initializing and executing the interpreter until after the main
1624  // window and QApplication are running to prevent race conditions
1625  QTimer::singleShot (0, this, SLOT (execute_octave_interpreter ()));
1626 }
1627 
1628 void
1630 {
1632 }
1633 
1634 void
1636 {
1637  QMenuBar *menu_bar = menuBar ();
1638 
1639  construct_file_menu (menu_bar);
1640 
1641  construct_edit_menu (menu_bar);
1642 
1643  construct_debug_menu (menu_bar);
1644 
1645  construct_window_menu (menu_bar);
1646 
1647  construct_help_menu (menu_bar);
1648 
1649  construct_news_menu (menu_bar);
1650 
1651 #if defined (HAVE_QSCINTILLA)
1652  // call the editor to add actions which should also be available in the
1653  // editor's menu and tool bar
1654  QList<QAction*> shared_actions;
1655  shared_actions << _new_script_action
1657  << _open_action
1659  << _undo_action
1660  << _copy_action
1661  << _paste_action
1663  editor_window->insert_global_actions (shared_actions);
1664 #endif
1665 }
1666 
1667 QAction*
1668 main_window::add_action (QMenu *menu, const QIcon &icon, const QString &text,
1669  const char *member, const QWidget *receiver)
1670 {
1671  QAction *a;
1672 
1673  if (receiver)
1674  a = menu->addAction (icon, text, receiver, member);
1675  else
1676  a = menu->addAction (icon, text, this, member);
1677 
1678  addAction (a); // important for shortcut context
1679  a->setShortcutContext (Qt::ApplicationShortcut);
1680  return a;
1681 }
1682 
1683 void
1685 {
1686  QHash<QMenu*, QStringList>::const_iterator i = _hash_menu_text.constBegin();
1687 
1688  while (i != _hash_menu_text.constEnd())
1689  {
1690  i.key ()->setTitle (i.value ().at (disable));
1691  ++i;
1692  }
1693 }
1694 
1695 QMenu*
1697 {
1698  QMenu *menu = p->addMenu (name);
1699 
1700  QString base_name = name; // get a copy
1701  // replace intended '&' ("&&") by a temp. string
1702  base_name.replace ("&&","___octave_amp_replacement___");
1703  // remove single '&' (shortcut)
1704  base_name.remove ("&");
1705  // restore intended '&'
1706  base_name.replace ("___octave_amp_replacement___","&&");
1707 
1708  // remember names with and without shortcut
1709  _hash_menu_text[menu] = QStringList () << name << base_name;
1710 
1711  return menu;
1712 }
1713 
1714 void
1716 {
1717  QMenu *file_menu = m_add_menu (p, tr ("&File"));
1718 
1719  construct_new_menu (file_menu);
1720 
1721  _open_action
1722  = file_menu->addAction (resource_manager::icon ("document-open"),
1723  tr ("Open..."));
1724  _open_action->setShortcutContext (Qt::ApplicationShortcut);
1725  _open_action->setToolTip (tr ("Open an existing file in editor"));
1726 
1727 #if defined (HAVE_QSCINTILLA)
1728  file_menu->addMenu (editor_window->get_mru_menu ());
1729 #endif
1730 
1731  file_menu->addSeparator ();
1732 
1734  = file_menu->addAction (tr ("Load Workspace..."));
1735 
1737  = file_menu->addAction (tr ("Save Workspace As..."));
1738 
1739  file_menu->addSeparator ();
1740 
1741  _exit_action = file_menu->addAction (tr ("Exit"));
1742  _exit_action->setShortcutContext (Qt::ApplicationShortcut);
1743 
1744 #if defined (HAVE_QSCINTILLA)
1745  connect (_open_action, SIGNAL (triggered ()),
1746  editor_window, SLOT (request_open_file ()));
1747 #endif
1748 
1749  connect (_load_workspace_action, SIGNAL (triggered ()),
1750  this, SLOT (handle_load_workspace_request ()));
1751 
1752  connect (_save_workspace_action, SIGNAL (triggered ()),
1753  this, SLOT (handle_save_workspace_request ()));
1754 
1755  connect (_exit_action, SIGNAL (triggered ()),
1756  this, SLOT (close ()));
1757 }
1758 
1759 void
1761 {
1762  QMenu *new_menu = p->addMenu (tr ("New"));
1763 
1765  = new_menu->addAction (resource_manager::icon ("document-new"),
1766  tr ("New Script"));
1767  _new_script_action->setShortcutContext (Qt::ApplicationShortcut);
1768 
1769  _new_function_action = new_menu->addAction (tr ("New Function..."));
1770  _new_function_action->setEnabled (true);
1771  _new_function_action->setShortcutContext (Qt::ApplicationShortcut);
1772 
1773  _new_figure_action = new_menu->addAction (tr ("New Figure"));
1774  _new_figure_action->setEnabled (true);
1775 
1776 #if defined (HAVE_QSCINTILLA)
1777  connect (_new_script_action, SIGNAL (triggered ()),
1778  editor_window, SLOT (request_new_script ()));
1779 
1780  connect (_new_function_action, SIGNAL (triggered ()),
1781  editor_window, SLOT (request_new_function ()));
1782 #endif
1783 
1784  connect (_new_figure_action, SIGNAL (triggered ()),
1785  this, SLOT (handle_new_figure_request ()));
1786 }
1787 
1788 void
1790 {
1791  QMenu *edit_menu = m_add_menu (p, tr ("&Edit"));
1792 
1793  QKeySequence ctrl_shift = Qt::ControlModifier + Qt::ShiftModifier;
1794 
1795  _undo_action
1796  = edit_menu->addAction (resource_manager::icon ("edit-undo"), tr ("Undo"));
1797  _undo_action->setShortcutContext (Qt::ApplicationShortcut);
1798 
1799  edit_menu->addSeparator ();
1800 
1801  _copy_action
1802  = edit_menu->addAction (resource_manager::icon ("edit-copy"),
1803  tr ("Copy"), this, SLOT (copyClipboard ()));
1804  _copy_action->setShortcutContext (Qt::ApplicationShortcut);
1805 
1807  = edit_menu->addAction (resource_manager::icon ("edit-paste"),
1808  tr ("Paste"), this, SLOT (pasteClipboard ()));
1809  _paste_action->setShortcutContext (Qt::ApplicationShortcut);
1810 
1812  = edit_menu->addAction (tr ("Select All"), this, SLOT (selectAll ()));
1813  _select_all_action->setShortcutContext (Qt::ApplicationShortcut);
1814 
1816  = edit_menu->addAction (tr ("Clear Clipboard"), this,
1817  SLOT (clear_clipboard ()));
1818 
1819  edit_menu->addSeparator ();
1820 
1822  = edit_menu->addAction (resource_manager::icon ("edit-find"),
1823  tr ("Find Files..."));
1824 
1825  edit_menu->addSeparator ();
1826 
1828  = edit_menu->addAction (tr ("Clear Command Window"));
1829 
1831  = edit_menu->addAction (tr ("Clear Command History"));
1832 
1834  = edit_menu->addAction (tr ("Clear Workspace"));
1835 
1836  edit_menu->addSeparator ();
1837 
1839  = edit_menu->addAction (resource_manager::icon ("preferences-system"),
1840  tr ("Preferences..."));
1841 
1842  connect (_find_files_action, SIGNAL (triggered ()),
1843  this, SLOT (find_files ()));
1844 
1845  connect (_clear_command_window_action, SIGNAL (triggered ()),
1846  this, SLOT (handle_clear_command_window_request ()));
1847 
1848  connect (_clear_command_history_action, SIGNAL (triggered ()),
1849  this, SLOT (handle_clear_history_request ()));
1850 
1851  connect (_clear_workspace_action, SIGNAL (triggered ()),
1852  this, SLOT (handle_clear_workspace_request ()));
1853 
1854  connect (_clipboard, SIGNAL (changed (QClipboard::Mode)),
1855  this, SLOT (clipboard_has_changed (QClipboard::Mode)));
1856  clipboard_has_changed (QClipboard::Clipboard);
1857 
1858  connect (_preferences_action, SIGNAL (triggered ()),
1859  this, SLOT (process_settings_dialog_request ()));
1860 }
1861 
1862 QAction *
1863 main_window::construct_debug_menu_item (const char *icon, const QString& item,
1864  const char *member)
1865 {
1866  QAction *action = add_action (_debug_menu,
1867  resource_manager::icon (QString (icon)),
1868  item, member);
1869 
1870  action->setEnabled (false);
1871 
1872 #if defined (HAVE_QSCINTILLA)
1873  editor_window->debug_menu ()->addAction (action);
1874  editor_window->toolbar ()->addAction (action);
1875 #endif
1876 
1877  return action;
1878 }
1879 
1880 void
1882 {
1883  _debug_menu = m_add_menu (p, tr ("De&bug"));
1884 
1886  "db-step", tr ("Step"),
1887  SLOT (debug_step_over ()));
1888 
1890  "db-step-in", tr ("Step In"),
1891  SLOT (debug_step_into ()));
1892 
1894  "db-step-out", tr ("Step Out"),
1895  SLOT (debug_step_out ()));
1896 
1898  "db-cont", tr ("Continue"),
1899  SLOT (debug_continue ()));
1900 
1901  _debug_menu->addSeparator ();
1902 #if defined (HAVE_QSCINTILLA)
1903  editor_window->debug_menu ()->addSeparator ();
1904 #endif
1905 
1907  "db-stop", tr ("Quit Debug Mode"),
1908  SLOT (debug_quit ()));
1909 }
1910 
1911 QAction *
1912 main_window::construct_window_menu_item (QMenu *p, const QString& item,
1913  bool checkable, QWidget *widget)
1914 {
1915  QAction *action = p->addAction (QIcon (), item);
1916 
1917  addAction (action); // important for shortcut context
1918  action->setCheckable (checkable);
1919  action->setShortcutContext (Qt::ApplicationShortcut);
1920 
1921  if (widget) // might be zero for editor_window
1922  {
1923  if (checkable)
1924  {
1925  // action for visibilty of dock widget
1926  connect (action, SIGNAL (toggled (bool)),
1927  widget, SLOT (setVisible (bool)));
1928 
1929  connect (widget, SIGNAL (active_changed (bool)),
1930  action, SLOT (setChecked (bool)));
1931  }
1932  else
1933  {
1934  // action for focus of dock widget
1935  connect (action, SIGNAL (triggered ()), widget, SLOT (focus ()));
1936  }
1937  }
1938 
1939  return action;
1940 }
1941 
1942 void
1944 {
1945  QMenu *window_menu = m_add_menu (p, tr ("&Window"));
1946 
1948  (window_menu, tr ("Show Command Window"), true, command_window);
1949 
1951  (window_menu, tr ("Show Command History"), true, history_window);
1952 
1954  (window_menu, tr ("Show File Browser"), true, file_browser_window);
1955 
1957  (window_menu, tr ("Show Workspace"), true, workspace_window);
1958 
1960  (window_menu, tr ("Show Editor"), true, editor_window);
1961 
1963  (window_menu, tr ("Show Documentation"), true, doc_browser_window);
1964 
1965  window_menu->addSeparator ();
1966 
1968  (window_menu, tr ("Command Window"), false, command_window);
1969 
1971  (window_menu, tr ("Command History"), false, history_window);
1972 
1974  (window_menu, tr ("File Browser"), false, file_browser_window);
1975 
1977  (window_menu, tr ("Workspace"), false, workspace_window);
1978 
1980  (window_menu, tr ("Editor"), false, editor_window);
1981 
1983  (window_menu, tr ("Documentation"), false, doc_browser_window);
1984 
1985  window_menu->addSeparator ();
1986 
1987  _reset_windows_action = add_action (window_menu, QIcon (),
1988  tr ("Reset Default Window Layout"), SLOT (reset_windows ()));
1989 }
1990 
1991 void
1993 {
1994  QMenu *help_menu = m_add_menu (p, tr ("&Help"));
1995 
1996  construct_documentation_menu (help_menu);
1997 
1998  help_menu->addSeparator ();
1999 
2000  _report_bug_action = add_action (help_menu, QIcon (),
2001  tr ("Report Bug"), SLOT (open_bug_tracker_page ()));
2002 
2003  _octave_packages_action = add_action (help_menu, QIcon (),
2004  tr ("Octave Packages"), SLOT (open_octave_packages_page ()));
2005 
2006  _contribute_action = add_action (help_menu, QIcon (),
2007  tr ("Contribute"), SLOT (open_contribute_page ()));
2008 
2009  _developer_action = add_action (help_menu, QIcon (),
2010  tr ("Donate to Octave"), SLOT (open_donate_page ()));
2011 
2012  help_menu->addSeparator ();
2013 
2014  _about_octave_action = add_action (help_menu, QIcon (),
2015  tr ("About Octave"), SLOT (show_about_octave ()));
2016 }
2017 
2018 void
2020 {
2021  QMenu *doc_menu = p->addMenu (tr ("Documentation"));
2022 
2023  _ondisk_doc_action = add_action (doc_menu, QIcon (),
2024  tr ("On Disk"), SLOT (focus ()), doc_browser_window);
2025 
2026  _online_doc_action = add_action (doc_menu, QIcon (),
2027  tr ("Online"), SLOT (open_online_documentation_page ()));
2028 }
2029 
2030 void
2032 {
2033  QMenu *news_menu = m_add_menu (p, tr ("&News"));
2034 
2035  _release_notes_action = add_action (news_menu, QIcon (),
2036  tr ("Release Notes"), SLOT (display_release_notes ()));
2037 
2038  _current_news_action = add_action (news_menu, QIcon (),
2039  tr ("Community News"), SLOT (load_and_display_community_news ()));
2040 }
2041 
2042 void
2044 {
2045  _main_tool_bar = addToolBar (tr ("Toolbar"));
2046 
2047  _main_tool_bar->setObjectName ("MainToolBar");
2048  _main_tool_bar->addAction (_new_script_action);
2049  _main_tool_bar->addAction (_open_action);
2050 
2051  _main_tool_bar->addSeparator ();
2052 
2053  _main_tool_bar->addAction (_copy_action);
2054  _main_tool_bar->addAction (_paste_action);
2055 
2056  _main_tool_bar->addSeparator ();
2057 
2058  _current_directory_combo_box = new QComboBox (this);
2059  QFontMetrics fm = _current_directory_combo_box->fontMetrics ();
2060  _current_directory_combo_box->setFixedWidth (48*fm.averageCharWidth ());
2061  _current_directory_combo_box->setEditable (true);
2062  _current_directory_combo_box->setInsertPolicy (QComboBox::NoInsert);
2063  _current_directory_combo_box->setToolTip (tr ("Enter directory name"));
2064  _current_directory_combo_box->setMaxVisibleItems (
2067  QSizePolicy sizePol (QSizePolicy::Preferred, QSizePolicy::Preferred);
2068  _current_directory_combo_box->setSizePolicy (sizePol);
2069 
2070  // addWidget takes ownership of the objects so there is no
2071  // need to delete these upon destroying this main_window.
2072  _main_tool_bar->addWidget (new QLabel (tr ("Current Directory: ")));
2074  QAction *current_dir_up = _main_tool_bar->addAction (
2075  resource_manager::icon ("go-up"),
2076  tr ("One directory up"));
2077  QAction *current_dir_search = _main_tool_bar->addAction (
2078  resource_manager::icon ("folder"),
2079  tr ("Browse directories"));
2080 
2081  connect (_current_directory_combo_box, SIGNAL (activated (QString)),
2082  this, SLOT (set_current_working_directory (QString)));
2083 
2084  connect (_current_directory_combo_box->lineEdit (), SIGNAL (returnPressed ()),
2085  this, SLOT (accept_directory_line_edit ()));
2086 
2087  connect (current_dir_search, SIGNAL (triggered ()),
2088  this, SLOT (browse_for_directory ()));
2089 
2090  connect (current_dir_up, SIGNAL (triggered ()),
2091  this, SLOT (change_directory_up ()));
2092 
2093  connect (_undo_action, SIGNAL (triggered ()),
2094  this, SLOT (handle_undo_request ()));
2095 }
2096 
2097 void
2099 {
2100  Fsave (ovl (file));
2101 }
2102 
2103 void
2105 {
2106  Fload (ovl (file));
2107 
2109 }
2110 
2111 void
2113 {
2114  Fclear ();
2115 }
2116 
2117 void
2119 {
2120  /* bool status = */ symbol_table::rename (names.first, names.second);
2121 
2122  // if (status)
2124 
2125  // else
2126  // ; // we need an octave_link action that runs a GUI error option.
2127 }
2128 
2129 void
2131 {
2134 }
2135 
2136 void
2138 {
2141 }
2142 
2143 void
2145 {
2147 }
2148 
2149 void
2151 {
2152  octave::command_editor::set_screen_size (sz.first, sz.second);
2153 }
2154 
2155 void
2157 {
2158  Fhistory (ovl ("-c"));
2159 }
2160 
2161 void
2163 {
2164  Fbuiltin (ovl ("figure"));
2165  Fdrawnow ();
2166 }
2167 
2168 void
2170 {
2171  Fcd (ovl (directory));
2173 }
2174 
2175 void
2176 main_window::find_files (const QString &start_dir)
2177 {
2178 
2179  if (! find_files_dlg)
2180  {
2181  find_files_dlg = new find_files_dialog (this);
2182 
2183  connect (find_files_dlg, SIGNAL (finished (int)),
2184  this, SLOT (find_files_finished (int)));
2185 
2186  connect (find_files_dlg, SIGNAL (dir_selected (const QString &)),
2188  SLOT (set_current_directory (const QString&)));
2189 
2190  connect (find_files_dlg, SIGNAL (file_selected (const QString &)),
2191  this, SLOT (open_file (const QString &)));
2192 
2193  find_files_dlg->setWindowModality (Qt::NonModal);
2194  }
2195 
2196  if (! find_files_dlg->isVisible ())
2197  {
2198  find_files_dlg->show ();
2199  }
2200 
2201  find_files_dlg->set_search_dir (start_dir);
2202 
2203  find_files_dlg->activateWindow ();
2204 
2205 }
2206 
2207 void
2209 {
2210 
2211 }
2212 
2213 void
2215 {
2216  // file menu
2217  shortcut_manager::set_shortcut (_open_action, "main_file:open_file");
2218  shortcut_manager::set_shortcut (_new_script_action, "main_file:new_file");
2219  shortcut_manager::set_shortcut (_new_function_action, "main_file:new_function");
2220  shortcut_manager::set_shortcut (_new_function_action, "main_file:new_figure");
2222  "main_file:load_workspace");
2224  "main_file:save_workspace");
2225  shortcut_manager::set_shortcut (_preferences_action, "main_file:preferences");
2226  shortcut_manager::set_shortcut (_exit_action,"main_file:exit");
2227 
2228  // edit menu
2229  shortcut_manager::set_shortcut (_copy_action, "main_edit:copy");
2230  shortcut_manager::set_shortcut (_paste_action, "main_edit:paste");
2231  shortcut_manager::set_shortcut (_undo_action, "main_edit:undo");
2232  shortcut_manager::set_shortcut (_select_all_action, "main_edit:select_all");
2234  "main_edit:clear_clipboard");
2235  shortcut_manager::set_shortcut (_find_files_action, "main_edit:find_in_files");
2237  "main_edit:clear_history");
2239  "main_edit:clear_command_window");
2241  "main_edit:clear_workspace");
2242 
2243  // debug menu
2244  shortcut_manager::set_shortcut (_debug_step_over, "main_debug:step_over");
2245  shortcut_manager::set_shortcut (_debug_step_into, "main_debug:step_into");
2246  shortcut_manager::set_shortcut (_debug_step_out, "main_debug:step_out");
2247  shortcut_manager::set_shortcut (_debug_continue, "main_debug:continue");
2248  shortcut_manager::set_shortcut (_debug_quit, "main_debug:quit");
2249 
2250  // window menu
2252  "main_window:show_command");
2254  "main_window:show_history");
2256  "main_window:show_workspace");
2258  "main_window:show_file_browser");
2259  shortcut_manager::set_shortcut (_show_editor_action, "main_window:show_editor");
2261  "main_window:show_doc");
2262  shortcut_manager::set_shortcut (_command_window_action, "main_window:command");
2263  shortcut_manager::set_shortcut (_history_action, "main_window:history");
2264  shortcut_manager::set_shortcut (_workspace_action, "main_window:workspace");
2266  "main_window:file_browser");
2267  shortcut_manager::set_shortcut (_editor_action, "main_window:editor");
2270 
2271  // help menu
2272  shortcut_manager::set_shortcut (_ondisk_doc_action, "main_help:ondisk_doc");
2273  shortcut_manager::set_shortcut (_online_doc_action, "main_help:online_doc");
2274  shortcut_manager::set_shortcut (_report_bug_action, "main_help:report_bug");
2276  shortcut_manager::set_shortcut (_contribute_action, "main_help:contribute");
2277  shortcut_manager::set_shortcut (_developer_action, "main_help:developer");
2279 
2280  // news menu
2282  "main_news:release_notes");
2284  "main_news:community_news");
2285 }
2286 
2287 void
2289 {
2290  // this slot is called when the terminal gets/loses focus
2291 
2292  // return if the user don't want to use readline shortcuts
2294  return;
2295 
2296  if (set_shortcuts)
2297  {
2298  // terminal loses focus: set the global shortcuts
2300  }
2301  else
2302  {
2303  // terminal gets focus: disable some shortcuts
2304  QKeySequence no_key = QKeySequence ();
2305 
2306  // file menu
2307  _open_action->setShortcut (no_key);
2308  _new_script_action->setShortcut (no_key);
2309  _new_function_action->setShortcut (no_key);
2310  _new_function_action->setShortcut (no_key);
2311  _load_workspace_action->setShortcut (no_key);
2312  _save_workspace_action->setShortcut (no_key);
2313  _preferences_action->setShortcut (no_key);
2314  _exit_action->setShortcut (no_key);
2315 
2316  // edit menu
2317  _select_all_action->setShortcut (no_key);
2318  _clear_clipboard_action->setShortcut (no_key);
2319  _find_files_action->setShortcut (no_key);
2320  _clear_command_history_action->setShortcut (no_key);
2321  _clear_command_window_action->setShortcut (no_key);
2322  _clear_workspace_action->setShortcut (no_key);
2323 
2324  // window menu
2325  _reset_windows_action->setShortcut (no_key);
2326 
2327  // help menu
2328  _ondisk_doc_action->setShortcut (no_key);
2329  _online_doc_action->setShortcut (no_key);
2330  _report_bug_action->setShortcut (no_key);
2331  _octave_packages_action->setShortcut (no_key);
2332  _contribute_action->setShortcut (no_key);
2333  _developer_action->setShortcut (no_key);
2334  _about_octave_action->setShortcut (no_key);
2335 
2336  // news menu
2337  _release_notes_action->setShortcut (no_key);
2338  _current_news_action->setShortcut (no_key);
2339  }
2340 }
2341 
2344 {
2346  list.append (static_cast<octave_dock_widget *> (command_window));
2347  list.append (static_cast<octave_dock_widget *> (history_window));
2348  list.append (static_cast<octave_dock_widget *> (file_browser_window));
2349  list.append (static_cast<octave_dock_widget *> (doc_browser_window));
2350 #if defined (HAVE_QSCINTILLA)
2351  list.append (static_cast<octave_dock_widget *> (editor_window));
2352 #endif
2353  list.append (static_cast<octave_dock_widget *> (workspace_window));
2354  return list;
2355 }
2356 
2357 void
2359 {
2361  int_pair (ht, wd));
2362 }
2363 
2364 void
2366 {
2367  doc_browser_window->setVisible (true);
2368  emit show_doc_signal (file);
2369 }
2370 
2371 void
2372 main_window::clipboard_has_changed (QClipboard::Mode cp_mode)
2373 {
2374  if (cp_mode == QClipboard::Clipboard)
2375  {
2376  if (_clipboard->text ().isEmpty ())
2377  {
2378  _paste_action->setEnabled (false);
2379  _clear_clipboard_action->setEnabled (false);
2380  }
2381  else
2382  {
2383  _paste_action->setEnabled (true);
2384  _clear_clipboard_action->setEnabled (true);
2385  }
2386  }
2387 }
2388 
2389 void
2391 {
2392  _clipboard->clear (QClipboard::Clipboard);
2393 }
QAction * _clear_command_history_action
Definition: main-window.h:341
void show_about_octave(void)
void handle_octave_ready()
void handle_undo_request(void)
Definition: main-window.cc:301
QAction * _octave_packages_action
Definition: main-window.h:363
void reset_windows(void)
Definition: main-window.cc:840
QAction * _open_action
Definition: main-window.h:329
QAction * _online_doc_action
Definition: main-window.h:361
QAction * _paste_action
Definition: main-window.h:337
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:120
void clear_history_callback(void)
void request_reload_settings()
Definition: main-window.cc:685
void handle_insert_debugger_pointer_request(const QString &file, int line)
Definition: main-window.cc:990
static void rename(const std::string &old_name, const std::string &new_name, scope_id scope=xcurrent_scope)
Definition: symtab.h:1320
OCTINTERP_API octave_value_list Fsave(const octave_value_list &=octave_value_list(), int=0)
Definition: load-save.cc:1576
static const int current_directory_max_visible
Definition: main-window.h:373
void debug_quit(void)
Definition: main-window.cc:982
void delete_debugger_pointer_signal(const QString &file, int line)
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:728
void pasteClipboard(void)
void disable_menu_shortcuts(bool disable)
virtual void insert_global_actions(QList< QAction * >)=0
QAction * _documentation_action
Definition: main-window.h:357
QString base_url
Definition: main-window.h:431
QAction * _workspace_action
Definition: main-window.h:354
virtual void empty_script(bool, bool)=0
void set_global_shortcuts(bool enable)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_type())
void set_search_dir(const QString &dir)
void construct_debug_menu(QMenuBar *p)
~main_window(void)
Definition: main-window.cc:132
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
virtual bool check_closing(void)=0
void rename_variable_callback(const name_pair &names)
void read_settings(void)
terminal_dock_widget * command_window
Definition: main-window.h:304
void handle_create_inputlayout(const QStringList &, const QString &, const QFloatList &, const QFloatList &, const QStringList &)
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:6386
void handle_create_filedialog(const QStringList &filters, const QString &title, const QString &filename, const QString &dirname, const QString &multimode)
void handle_clear_history_request(void)
Definition: main-window.cc:316
main_window(QWidget *parent, octave::gui_application *app_context)
Definition: main-window.cc:80
QAction * _reset_windows_action
Definition: main-window.h:358
void display_release_notes(void)
Definition: main-window.cc:366
void open_file(const QString &file_name=QString())
Definition: main-window.cc:240
OCTAVE_EXPORT octave_value_list page
Definition: sub2ind.cc:107
void clear_clipboard()
QAction * _debug_step_into
Definition: main-window.h:322
QAction * _about_octave_action
Definition: main-window.h:366
bool command_window_has_focus(void) const
Definition: main-window.cc:222
OCTINTERP_API octave_value_list Fdrawnow(const octave_value_list &=octave_value_list(), int=0)
Definition: graphics.cc:11032
QAction * construct_window_menu_item(QMenu *p, const QString &item, bool checkable, QWidget *)
bool _suppress_dbg_location
Definition: main-window.h:403
static QSettings * get_default_settings(void)
void selectAll(void)
void open_file_signal(const QString &)
void exit_app(int status)
Definition: main-window.cc:834
void copy_image_to_clipboard(const QString &file, bool remove_file)
Definition: main-window.cc:666
QMenu * m_add_menu(QMenuBar *p, QString text)
QString fromStdString(const std::string &s)
QAction * _command_window_action
Definition: main-window.h:352
void clear_command_window_callback(void)
void handle_load_workspace_request(const QString &file=QString())
Definition: main-window.cc:270
QAction * _show_documentation_action
Definition: main-window.h:351
QAction * _report_bug_action
Definition: main-window.h:362
octave::gui_application * m_app_context
Definition: main-window.h:294
std::string filename
Definition: urlwrite.cc:340
QAction * add_action(QMenu *menu, const QIcon &icon, const QString &text, const char *member, const QWidget *receiver=0)
void make_widget(bool dock=true)
void show_doc_signal(const QString &)
static shortcut_manager * instance
void confirm_shutdown_octave(void)
Definition: main-window.cc:783
QToolBar * _main_tool_bar
Definition: main-window.h:317
void display_community_news(const QString &news)
Definition: main-window.cc:576
void copyClipboard(void)
void write_settings(void)
void load_and_display_community_news(int serial=-1)
Definition: main-window.cc:540
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
static file_editor_interface * create_default_editor(QWidget *p)
Definition: main-window.cc:69
octave_dock_widget * _active_dock
Definition: main-window.h:313
file_editor_interface * editor_window
Definition: main-window.h:308
void browse_for_directory(void)
Definition: main-window.cc:865
i e
Definition: data.cc:2724
files_dock_widget * file_browser_window
Definition: main-window.h:306
void update_breakpoint_marker_signal(bool insert, const QString &file, int line, const QString &cond)
bool _prevent_readline_conflicts
Definition: main-window.h:402
workspace_view * workspace_window
Definition: main-window.h:309
octave_value arg
Definition: pr-output.cc:3440
void edit_mfile_request(const QString &, const QString &, const QString &, int)
void find_files_finished(int)
QAction * _preferences_action
Definition: main-window.h:333
QStatusBar * status_bar
Definition: main-window.h:301
void handle_clear_workspace_request(void)
Definition: main-window.cc:284
void change_directory_callback(const std::string &directory)
void construct(void)
void edit_mfile(const QString &, int)
Definition: main-window.cc:246
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:398
#define OCTAVE_RELEASE_DATE
Definition: version.h:47
static void set_screen_size(int ht, int wd)
Definition: cmd-edit.cc:1251
void accept_directory_line_edit(void)
Definition: main-window.cc:905
QUIWidgetCreator uiwidget_creator
Definition: dialog.cc:45
void message(const char *name, const char *fmt,...)
Definition: error.cc:430
void resize_command_window_callback(void)
workspace_model * _workspace_model
Definition: main-window.h:296
QAction * _clear_clipboard_action
Definition: main-window.h:338
void set_screen_size(int ht, int wd)
OCTINTERP_API octave_value_list Fclear(const octave_value_list &=octave_value_list(), int=0)
void debug_step_into(void)
Definition: main-window.cc:960
void construct_octave_qt_link(void)
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 any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
void setModel(workspace_model *model)
void command_window_undo_callback(void)
QHash< QMenu *, QStringList > _hash_menu_text
Definition: main-window.h:298
void handle_exit_debugger(void)
Definition: main-window.cc:936
void open_octave_packages_page(void)
Definition: main-window.cc:627
void change_directory(const QString &dir)
Definition: main-window.cc:849
documentation_dock_widget * doc_browser_window
Definition: main-window.h:307
void finished(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)
bool connect_to_web
Definition: main-window.h:434
void settings_changed(const QSettings *)
void open_donate_page(void)
Definition: main-window.cc:639
QAction * _copy_action
Definition: main-window.h:336
OCTINTERP_API octave_value_list Fbuiltin(const octave_value_list &=octave_value_list(), int=0)
void add_cmd(octave_cmd *cmd)
Adds a new octave command to the command queue.
Definition: octave-cmd.cc:115
void notice_settings(const QSettings *settings)
Definition: main-window.cc:694
static void resize_terminal(void)
Definition: cmd-edit.cc:1244
QAction * _debug_step_over
Definition: main-window.h:323
QAction * _contribute_action
Definition: main-window.h:364
void connect_visibility_changed(void)
QAction * _new_script_action
Definition: main-window.h:327
void execute_command_in_terminal(const QString &dir)
Definition: main-window.cc:329
void clipboard_has_changed(QClipboard::Mode)
virtual void enable_menu_shortcuts(bool enable)=0
OCTINTERP_API octave_value_list Fhistory(const octave_value_list &=octave_value_list(), int=0)
QComboBox * _current_directory_combo_box
Definition: main-window.h:372
QAction * _current_news_action
Definition: main-window.h:369
std::string str
Definition: hash.cc:118
QAction * _undo_action
Definition: main-window.h:339
void construct_file_menu(QMenuBar *p)
double tmp
Definition: data.cc:6300
void save_workspace_callback(const std::string &file)
QString page
Definition: main-window.h:432
QClipboard * _clipboard
Definition: main-window.h:390
void set_screen_size_callback(const int_pair &)
void set_predecessor_widget(octave_dock_widget *prev_widget)
void new_figure_callback(void)
void copyClipboard_signal(void)
void clear_workspace_callback(void)
void closeEvent(QCloseEvent *closeEvent)
static const int current_directory_max_count
Definition: main-window.h:374
QPointer< settings_dialog > _settings_dlg
Definition: main-window.h:378
void configure_shortcuts()
QAction * _select_all_action
Definition: main-window.h:344
Array< std::string > param
Definition: urlwrite.cc:343
void handle_update_breakpoint_marker_request(bool insert, const QString &file, int line, const QString &cond)
void process_settings_dialog_request(const QString &desired_tab=QString())
Definition: main-window.cc:645
sz
Definition: data.cc:5342
void display_news_signal(const QString &news)
QAction * _new_figure_action
Definition: main-window.h:330
void handle_rename_variable_request(const QString &old_name, const QString &new_name)
Definition: main-window.cc:290
void connect_uiwidget_links(void)
QString _release_notes_icon
Definition: main-window.h:315
static QSettings * get_settings(void)
void load_workspace_callback(const std::string &file)
QAction * _show_editor_action
Definition: main-window.h:350
void construct_documentation_menu(QMenu *p)
void run_file_callback(const QFileInfo &info)
Definition: main-window.cc:346
std::string url
Definition: urlwrite.cc:337
void selectAll_signal(void)
QAction * _show_file_browser_action
Definition: main-window.h:349
bool has_focus(void) const
QAction * _new_function_action
Definition: main-window.h:328
void debug_continue(void)
Definition: main-window.cc:952
static bool undo(void)
Definition: cmd-edit.cc:1480
void open_online_documentation_page(void)
Definition: main-window.cc:359
void handle_show_doc(const QString &file)
QAction * _clear_workspace_action
Definition: main-window.h:342
void execute_octave_interpreter(void)
void undo_signal(void)
QAction * _debug_step_out
Definition: main-window.h:324
std::string octave_name_version_copyright_copying_warranty_and_bugs(bool html, const std::string &extra_info)
Definition: version.cc:96
QAction * _developer_action
Definition: main-window.h:365
virtual QMenu * debug_menu()=0
std::pair< int, int > int_pair
Definition: main-window.h:76
void editor_focus_changed(bool)
bool focus_console_after_command()
Definition: main-window.cc:322
QAction * _file_browser_action
Definition: main-window.h:355
static resource_manager * instance
virtual QMenu * get_mru_menu()=0
QAction * _release_notes_action
Definition: main-window.h:368
static void redisplay(void)
Definition: cmd-edit.cc:1216
QAction * _clear_command_window_action
Definition: main-window.h:340
QAction * _find_files_action
Definition: main-window.h:343
octave::sys::time start
Definition: graphics.cc:11731
void focus_command_window(void)
Definition: main-window.cc:228
void set_window_layout(QSettings *settings)
void run_file_in_terminal(const QFileInfo &info)
Definition: main-window.cc:338
void handle_new_figure_request(void)
Definition: main-window.cc:353
void open_contribute_page(void)
Definition: main-window.cc:633
QWidget * release_notes_window
Definition: main-window.h:384
void debug_step_over(void)
Definition: main-window.cc:967
void open_bug_tracker_page(void)
Definition: main-window.cc:621
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
void construct_news_menu(QMenuBar *p)
p
Definition: lu.cc:138
void debug_step_out(void)
Definition: main-window.cc:975
history_dock_widget * history_window
Definition: main-window.h:305
QAction * _show_command_window_action
Definition: main-window.h:346
virtual void handle_enter_debug_mode(void)=0
void construct_menu_bar(void)
void construct_window_menu(QMenuBar *p)
void find_files(const QString &startdir=QDir::currentPath())
QAction * _exit_action
Definition: main-window.h:334
std::string Voct_etc_dir
Definition: defaults.cc:75
static QIcon icon(const QString &icon_name, bool fallback=true)
QAction * _history_action
Definition: main-window.h:353
QAction * _show_workspace_action
Definition: main-window.h:348
Dock widget to display files in the current directory.
b
Definition: cellfun.cc:398
void handle_clear_command_window_request(void)
Definition: main-window.cc:310
virtual void handle_exit_debug_mode(void)=0
static void kill_full_line(void)
Definition: cmd-edit.cc:1452
static void update_network_settings(void)
void set_current_working_directory(const QString &dir)
Definition: main-window.cc:881
void init_terminal_size(void)
QList< int > QIntList
Definition: dialog.h:38
void new_file(const QString &commands=QString())
Definition: main-window.cc:234
QAction * _show_history_action
Definition: main-window.h:347
void process(void)
Definition: main-window.cc:429
void construct_help_menu(QMenuBar *p)
void init_terminal_size_signal(void)
void active_dock_changed(octave_dock_widget *, octave_dock_widget *)
void construct_tool_bar(void)
QAction * _load_workspace_action
Definition: main-window.h:331
QAction * _debug_continue
Definition: main-window.h:321
QAction * construct_debug_menu_item(const char *icon, const QString &item, const char *member)
void focus_changed(QWidget *w_old, QWidget *w_new)
Definition: main-window.cc:170
virtual QToolBar * toolbar()=0
QList< octave_dock_widget * > dock_widget_list()
QMenu * _debug_menu
Definition: main-window.h:319
QAction * _debug_quit
Definition: main-window.h:325
void construct_new_menu(QMenu *p)
static std::list< workspace_element > workspace_info(scope_id scope=xcurrent_scope)
Definition: symtab.h:2217
std::pair< std::string, std::string > name_pair
Definition: main-window.h:75
bool _start_gui
Definition: main-window.h:404
void new_file_signal(const QString &)
octave_command_queue _cmd_queue
Definition: main-window.h:399
void construct_edit_menu(QMenuBar *p)
void handle_enter_debugger(void)
Definition: main-window.cc:920
void change_directory_up(void)
Definition: main-window.cc:895
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:854
find_files_dialog * find_files_dlg
Definition: main-window.h:381
void pasteClipboard_signal(void)
static void set_shortcut(QAction *action, const QString &key)
QWidget * community_news_window
Definition: main-window.h:386
QAction * _ondisk_doc_action
Definition: main-window.h:360
void prepare_to_exit(void)
Definition: main-window.cc:822
void handle_save_workspace_request(void)
Definition: main-window.cc:258
virtual void connect_visibility_changed(void)
octave_qt_link * _octave_qt_link
Definition: main-window.h:388
charNDArray min(char d, const charNDArray &m)
Definition: chNDArray.cc:205
static void clear_screen(bool skip_redisplay=false)
Definition: cmd-edit.cc:1237
OCTINTERP_API octave_value_list Fload(const octave_value_list &=octave_value_list(), int=0)
Definition: load-save.cc:629
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
QAction * _editor_action
Definition: main-window.h:356
OCTINTERP_API octave_value_list Fcd(const octave_value_list &=octave_value_list(), int=0)
Definition: dirfns.cc:120
void handle_delete_debugger_pointer_request(const QString &file, int line)
QAction * _save_workspace_action
Definition: main-window.h:332
void insert_debugger_pointer_signal(const QString &file, int line)
OCTAVE_EXPORT octave_value_list directory
Definition: variables.cc:582
void report_status_message(const QString &statusMessage)
Definition: main-window.cc:252