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