comparison libgui/src/main-window.cc @ 16454:246d25c8761b

split main_window::construct for clarity * main-window.h, main-window.cc (_new_script_action, _open_action, _cut_action, _copy_action, _paste_action, _undo_action, _redo_action): New data members. (construct_octave_qt_link, construct_menu_bar, construct_file_menu, construct_new_menu, construct_edit_menu, construct_debug_menu_item, construct_debug_menu_item, construct_debug_menu, construct_desktop_menu, construct_window_menu_item, construct_window_menu, construct_help_menu, construct_documentation_menu, construct_tool_bar): New functions. (main_window::construct): Use them.
author John W. Eaton <jwe@octave.org>
date Sun, 07 Apr 2013 04:14:31 -0400
parents 2e3c652c89d1
children 38ed6bdd1f7f
comparison
equal deleted inserted replaced
16453:2e3c652c89d1 16454:246d25c8761b
585 _workspace_view->setStatusTip (tr ("View the variables in the active workspace.")); 585 _workspace_view->setStatusTip (tr ("View the variables in the active workspace."));
586 586
587 connect (_workspace_model, SIGNAL (model_changed ()), 587 connect (_workspace_model, SIGNAL (model_changed ()),
588 _workspace_view, SLOT (model_changed ())); 588 _workspace_view, SLOT (model_changed ()));
589 589
590 // Create and set the central widget. QMainWindow takes ownership of
591 // the widget (pointer) so there is no need to delete the object upon
592 // destroying this main_window.
593
594 QWidget *dummyWidget = new QWidget ();
595 dummyWidget->setObjectName ("CentralDummyWidget");
596 dummyWidget->resize (10, 10);
597 dummyWidget->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum);
598 dummyWidget->hide ();
599 setCentralWidget (dummyWidget);
600
601 #ifdef HAVE_QSCINTILLA
602 _file_editor = new file_editor (this);
603 #endif
604
605 construct_menu_bar ();
606
607 construct_tool_bar ();
608
609 connect (qApp, SIGNAL (aboutToQuit ()),
610 this, SLOT (prepare_for_quit ()));
611
612 #ifdef HAVE_QSCINTILLA
613 connect (this, SIGNAL (settings_changed (const QSettings *)),
614 _file_editor, SLOT (notice_settings (const QSettings *)));
615 #endif
616
617 connect (this, SIGNAL (settings_changed (const QSettings *)),
618 command_window, SLOT (notice_settings (const QSettings *)));
619
620 connect (this, SIGNAL (settings_changed (const QSettings *)),
621 file_browser_window, SLOT (notice_settings (const QSettings *)));
622
623 connect (this, SIGNAL (settings_changed (const QSettings *)),
624 this, SLOT (notice_settings (const QSettings *)));
625
626 connect (file_browser_window, SIGNAL (open_file (QString)),
627 this, SLOT (open_file (QString)));
628
629 connect (file_browser_window, SIGNAL (displayed_directory_changed(QString)),
630 this, SLOT (set_current_working_directory(QString)));
631
632 connect (this, SIGNAL (relay_command_signal (const QString&)),
633 command_window, SLOT (relay_command (const QString&)));
634
635 connect (history_window, SIGNAL (command_create_script (const QString&)),
636 this, SLOT (new_file (const QString&)));
637
638 setWindowTitle ("Octave");
639
640 setDockOptions (QMainWindow::AnimatedDocks
641 | QMainWindow::AllowNestedDocks
642 | QMainWindow::AllowTabbedDocks);
643
644 addDockWidget (Qt::RightDockWidgetArea, command_window);
645 addDockWidget (Qt::RightDockWidgetArea, doc_browser_window);
646 tabifyDockWidget (command_window, doc_browser_window);
647
648 #ifdef HAVE_QSCINTILLA
649 addDockWidget (Qt::RightDockWidgetArea, _file_editor);
650 tabifyDockWidget (command_window, _file_editor);
651 #endif
652
653 addDockWidget (Qt::LeftDockWidgetArea, file_browser_window);
654 addDockWidget (Qt::LeftDockWidgetArea, _workspace_view);
655 addDockWidget (Qt::LeftDockWidgetArea, history_window);
656
657 int win_x = QApplication::desktop()->width();
658 int win_y = QApplication::desktop()->height();
659
660 if (win_x > 960)
661 win_x = 960;
662
663 if (win_y > 720)
664 win_y = 720;
665
666 setGeometry (0, 0, win_x, win_y);
667
668 setStatusBar (status_bar);
669
670 _octave_qt_event_listener = new octave_qt_event_listener ();
671
672 connect (_octave_qt_event_listener, SIGNAL (update_workspace_signal ()),
673 this, SLOT (update_workspace ()));
674
675 // FIXME -- is it possible to eliminate the event_listenter?
676
677 construct_octave_qt_link ();
678
679 QDir curr_dir;
680 set_current_working_directory (curr_dir.absolutePath ());
681 }
682
683 void
684 main_window::construct_octave_qt_link (void)
685 {
686 _octave_qt_link = new octave_qt_link ();
687
688 connect (_octave_qt_link, SIGNAL (change_directory_signal (QString)),
689 this, SLOT (change_directory (QString)));
690
691 connect (_octave_qt_link,
692 SIGNAL (set_history_signal (const QStringList&)),
693 history_window, SLOT (set_history (const QStringList&)));
694
695 connect (_octave_qt_link,
696 SIGNAL (append_history_signal (const QString&)),
697 history_window, SLOT (append_history (const QString&)));
698
699 connect (_octave_qt_link,
700 SIGNAL (clear_history_signal (void)),
701 history_window, SLOT (clear_history (void)));
702
703 connect (_octave_qt_link, SIGNAL (enter_debugger_signal ()),
704 this, SLOT (handle_enter_debugger ()));
705
706 connect (_octave_qt_link, SIGNAL (exit_debugger_signal ()),
707 this, SLOT (handle_exit_debugger ()));
708
709 connect (_octave_qt_link,
710 SIGNAL (update_breakpoint_marker_signal (bool, const QString&, int)),
711 _file_editor,
712 SLOT (handle_update_breakpoint_marker_request (bool, const QString&, int)));
713
714 connect (_octave_qt_link,
715 SIGNAL (edit_file_signal (const QString&)),
716 _file_editor,
717 SLOT (handle_edit_file_request (const QString&)));
718
719 connect (_octave_qt_link,
720 SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
721 _file_editor,
722 SLOT (handle_insert_debugger_pointer_request (const QString&, int)));
723
724 connect (_octave_qt_link,
725 SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
726 _file_editor,
727 SLOT (handle_delete_debugger_pointer_request (const QString&, int)));
728
729 _octave_qt_link->execute_interpreter ();
730
731 octave_link::connect_link (_octave_qt_link);
732
733 octave_link::register_event_listener (_octave_qt_event_listener);
734 }
735
736 void
737 main_window::construct_menu_bar (void)
738 {
739 QMenuBar *menu_bar = menuBar ();
740
741 construct_file_menu (menu_bar);
742
743 construct_edit_menu (menu_bar);
744
745 construct_debug_menu (menu_bar);
746
747 construct_desktop_menu (menu_bar);
748
749 construct_window_menu (menu_bar);
750
751 construct_help_menu (menu_bar);
752 }
753
754 void
755 main_window::construct_file_menu (QMenuBar *p)
756 {
757 QMenu *file_menu = p->addMenu (tr ("&File"));
758
759 construct_new_menu (file_menu);
760
761 _open_action
762 = file_menu->addAction (QIcon(":/actions/icons/fileopen.png"),
763 tr ("Open..."));
764 _open_action->setShortcut (QKeySequence::Open);
765 _open_action->setShortcutContext (Qt::ApplicationShortcut);
766
767 #ifdef HAVE_QSCINTILLA
768 file_menu->addMenu (_file_editor->get_mru_menu ());
769 #endif
770
771 QAction *close_command_window_action
772 = file_menu->addAction (tr ("Close Command Window"));
773 close_command_window_action->setShortcut (QKeySequence::Close);
774 close_command_window_action->setEnabled (false); // TODO: Make this work.
775
776 file_menu->addSeparator ();
777
778 QAction *import_data_action
779 = file_menu->addAction (tr ("Import Data"));
780 import_data_action->setEnabled (false); // TODO: Make this work.
781
782 QAction *save_workspace_action
783 = file_menu->addAction (tr ("Save Workspace As"));
784
785 file_menu->addSeparator ();
786
787 QAction *preferences_action
788 = file_menu->addAction (QIcon(":/actions/icons/configure.png"),
789 tr ("Preferences..."));
790
791 file_menu->addSeparator ();
792
793 QAction *page_setup_action
794 = file_menu->addAction (tr ("Page Setup..."));
795 page_setup_action->setEnabled (false); // TODO: Make this work.
796
797 QAction *print_action
798 = file_menu->addAction (tr ("Print"));
799 print_action->setShortcut (QKeySequence::Print);
800 print_action->setEnabled (false); // TODO: Make this work.
801
802 QAction *print_selection_action
803 = file_menu->addAction (tr ("Print Selection..."));
804 print_selection_action->setEnabled (false); // TODO: Make this work.
805
806 file_menu->addSeparator ();
807
808 QAction *exit_action = file_menu->addAction (tr ("Exit"));
809 exit_action->setShortcut (QKeySequence::Quit);
810
811 connect (preferences_action, SIGNAL (triggered ()),
812 this, SLOT (process_settings_dialog_request ()));
813
814 connect (_open_action, SIGNAL (triggered ()),
815 this, SLOT (open_file ()));
816
817 connect (save_workspace_action, SIGNAL (triggered ()),
818 this, SLOT (handle_save_workspace_request ()));
819
820 connect (exit_action, SIGNAL (triggered ()),
821 this, SLOT (close ()));
822 }
823
824 void
825 main_window::construct_new_menu (QMenu *p)
826 {
827 QMenu *new_menu = p->addMenu (tr ("New"));
828
829 _new_script_action
830 = new_menu->addAction (QIcon(":/actions/icons/filenew.png"), tr ("Script"));
831 _new_script_action->setShortcut (QKeySequence::New);
832 _new_script_action->setShortcutContext (Qt::ApplicationShortcut);
833
834 QAction *new_function_action = new_menu->addAction (tr ("Function"));
835 new_function_action->setEnabled (false); // TODO: Make this work.
836
837 QAction *new_class_action = new_menu->addAction (tr ("Class"));
838 new_class_action->setEnabled (false); // TODO: Make this work.
839
840 QAction *new_enumeration_action = new_menu->addAction (tr ("Enumeration"));
841 new_enumeration_action->setEnabled (false); // TODO: Make this work.
842
843 QAction *new_figure_action = new_menu->addAction (tr ("Figure"));
844 new_figure_action->setEnabled (false); // TODO: Make this work.
845
846 QAction *new_variable_action = new_menu->addAction (tr ("Variable"));
847 new_variable_action->setEnabled (false); // TODO: Make this work.
848
849 QAction *new_model_action = new_menu->addAction (tr ("Model"));
850 new_model_action->setEnabled (false); // TODO: Make this work.
851
852 QAction *new_gui_action = new_menu->addAction (tr ("GUI"));
853 new_gui_action->setEnabled (false); // TODO: Make this work.
854
855 connect (_new_script_action, SIGNAL (triggered ()),
856 this, SLOT (new_file ()));
857 }
858
859 void
860 main_window::construct_edit_menu (QMenuBar *p)
861 {
862 QMenu *edit_menu = p->addMenu (tr ("&Edit"));
863
864 QKeySequence ctrl_shift = Qt::ControlModifier + Qt::ShiftModifier;
865
866 _undo_action
867 = edit_menu->addAction (QIcon(":/actions/icons/undo.png"), tr ("Undo"));
868 _undo_action->setShortcut (QKeySequence::Undo);
869
870 _redo_action
871 = edit_menu->addAction (QIcon(":/actions/icons/redo.png"), tr ("Redo"));
872 _redo_action->setShortcut (QKeySequence::Redo);
873
874 edit_menu->addSeparator ();
875
876 _cut_action
877 = edit_menu->addAction (QIcon(":/actions/icons/editcut.png"), tr ("Cut"));
878 _cut_action->setShortcut (ctrl_shift + Qt::Key_X);
879
880 _copy_action
881 = edit_menu->addAction (QIcon(":/actions/icons/editcopy.png"), tr ("Copy"));
882 _copy_action->setShortcut (ctrl_shift + Qt::Key_C);
883
884 _paste_action
885 = edit_menu->addAction (QIcon(":/actions/icons/editpaste.png"), tr ("Paste"));
886 _paste_action->setShortcut (ctrl_shift + Qt::Key_V);
887
888 QAction *paste_to_workspace_action
889 = edit_menu->addAction (tr ("Paste To Workspace..."));
890 paste_to_workspace_action->setEnabled (false); // TODO: Make this work.
891
892 edit_menu->addSeparator ();
893
894 QAction *select_all_action
895 = edit_menu->addAction (tr ("Select All"));
896 select_all_action->setEnabled (false); // TODO: Make this work.
897
898 QAction *delete_action
899 = edit_menu->addAction (tr ("Delete"));
900 delete_action->setShortcut (Qt::Key_Delete);
901 delete_action->setEnabled (false); // TODO: Make this work.
902
903 edit_menu->addSeparator ();
904
905 QAction *find_action
906 = edit_menu->addAction (tr ("Find..."));
907 find_action->setEnabled (false); // TODO: Make this work.
908
909 QAction *find_files_action
910 = edit_menu->addAction (tr ("Find Files..."));
911 find_files_action->setShortcut (ctrl_shift + Qt::Key_F);
912 find_files_action->setEnabled (false); // TODO: Make this work.
913
914 edit_menu->addSeparator ();
915
916 QAction *clear_command_window_action
917 = edit_menu->addAction (tr ("Clear Command Window"));
918 clear_command_window_action->setEnabled (false); // TODO: Make this work.
919
920 QAction *clear_command_history
921 = edit_menu->addAction(tr ("Clear Command History"));
922
923 QAction *clear_workspace_action
924 = edit_menu->addAction (tr ("Clear Workspace"));
925
926 connect (_copy_action, SIGNAL (triggered()),
927 command_window, SLOT (copyClipboard ()));
928
929 connect (_paste_action, SIGNAL (triggered()),
930 command_window, SLOT (pasteClipboard ()));
931
932 connect (clear_command_history, SIGNAL (triggered ()),
933 this, SLOT (handle_clear_history_request ()));
934
935 connect (clear_workspace_action, SIGNAL (triggered ()),
936 this, SLOT (handle_clear_workspace_request ()));
937 }
938
939 QAction *
940 main_window::construct_debug_menu_item (const char *icon_file,
941 const QString& item,
942 const QKeySequence& key)
943 {
944 QAction *action = _debug_menu->addAction (QIcon (icon_file), item);
945
946 action->setEnabled (false);
947 action->setShortcut (Qt::Key_F10);
948
949 #ifdef HAVE_QSCINTILLA
950 _file_editor->debug_menu ()->addAction (action);
951 _file_editor->toolbar ()->addAction (action);
952 #endif
953
954 return action;
955 }
956
957 void
958 main_window::construct_debug_menu (QMenuBar *p)
959 {
960 _debug_menu = p->addMenu (tr ("De&bug"));
961
962 _debug_step_over = construct_debug_menu_item
963 (":/actions/icons/db_step.png", tr ("Step"), Qt::Key_F10);
964
965 _debug_step_into = construct_debug_menu_item
966 (":/actions/icons/db_step_in.png", tr ("Step in"), Qt::Key_F11);
967
968 _debug_step_out = construct_debug_menu_item
969 (":/actions/icons/db_step_out.png", tr ("Step out"),
970 Qt::ShiftModifier + Qt::Key_F11);
971
972 _debug_continue = construct_debug_menu_item
973 (":/actions/icons/db_cont.png", tr ("Continue"), Qt::Key_F5);
974
975 _debug_menu->addSeparator ();
976 #ifdef HAVE_QSCINTILLA
977 _file_editor->debug_menu ()->addSeparator ();
978 #endif
979
980 _debug_quit = construct_debug_menu_item
981 (":/actions/icons/db_stop.png", tr ("Exit Debug Mode"),
982 Qt::ShiftModifier + Qt::Key_F5);
983
984 connect (_debug_step_over, SIGNAL (triggered ()),
985 this, SLOT (debug_step_over ()));
986
987 connect (_debug_step_into, SIGNAL (triggered ()),
988 this, SLOT (debug_step_into ()));
989
990 connect (_debug_step_out, SIGNAL (triggered ()),
991 this, SLOT (debug_step_out ()));
992
993 connect (_debug_continue, SIGNAL (triggered ()),
994 this, SLOT (debug_continue ()));
995
996 connect (_debug_quit, SIGNAL (triggered ()),
997 this, SLOT (debug_quit ()));
998 }
999
1000 void
1001 main_window::construct_desktop_menu (QMenuBar *p)
1002 {
1003 QMenu *desktop_menu = p->addMenu (tr ("&Desktop"));
1004
1005 QAction *load_workspace_action = desktop_menu->addAction (tr ("Load workspace"));
1006
1007 connect (load_workspace_action, SIGNAL (triggered ()),
1008 this, SLOT (handle_load_workspace_request ()));
1009 }
1010
1011 QAction *
1012 main_window::construct_window_menu_item (QMenu *p, const QString& item,
1013 bool checkable,
1014 const QKeySequence& key)
1015 {
1016 QAction *action = p->addAction (item);
1017
1018 action->setCheckable (checkable);
1019 action->setShortcut (key);
1020 action->setShortcutContext (Qt::ApplicationShortcut);
1021
1022 return action;
1023 }
1024
1025 void
1026 main_window::construct_window_menu (QMenuBar *p)
1027 {
1028 QMenu *window_menu = p->addMenu (tr ("&Window"));
1029
1030 QKeySequence ctrl = Qt::ControlModifier;
1031 QKeySequence ctrl_shift = Qt::ControlModifier + Qt::ShiftModifier;
1032
1033 QAction *show_command_window_action = construct_window_menu_item
1034 (window_menu, tr ("Show Command Window"), true, ctrl_shift + Qt::Key_0);
1035
1036 QAction *show_history_action = construct_window_menu_item
1037 (window_menu, tr ("Show Command History"), true, ctrl_shift + Qt::Key_1);
1038
1039 QAction *show_file_browser_action = construct_window_menu_item
1040 (window_menu, tr ("Show Current Directory"), true, ctrl_shift + Qt::Key_2);
1041
1042 QAction *show_workspace_action = construct_window_menu_item
1043 (window_menu, tr ("Show Workspace"), true, ctrl_shift + Qt::Key_3);
1044
1045 QAction *show_editor_action = construct_window_menu_item
1046 (window_menu, tr ("Show Editor"), true, ctrl_shift + Qt::Key_4);
1047
1048 QAction *show_documentation_action = construct_window_menu_item
1049 (window_menu, tr ("Show Documentation"), true, ctrl_shift + Qt::Key_5);
1050
1051 window_menu->addSeparator ();
1052
1053 QAction *command_window_action = construct_window_menu_item
1054 (window_menu, tr ("Command Window"), false, ctrl + Qt::Key_0);
1055
1056 QAction *history_action = construct_window_menu_item
1057 (window_menu, tr ("Command History"), false, ctrl + Qt::Key_1);
1058
1059 QAction *file_browser_action = construct_window_menu_item
1060 (window_menu, tr ("Current Directory"), false, ctrl + Qt::Key_2);
1061
1062 QAction *workspace_action = construct_window_menu_item
1063 (window_menu, tr ("Workspace"), false, ctrl + Qt::Key_3);
1064
1065 QAction *editor_action = construct_window_menu_item
1066 (window_menu, tr ("Editor"), false, ctrl + Qt::Key_4);
1067
1068 QAction *documentation_action = construct_window_menu_item
1069 (window_menu, tr ("Documentation"), false, ctrl + Qt::Key_5);
1070
1071 window_menu->addSeparator ();
1072
1073 QAction *reset_windows_action
1074 = window_menu->addAction (tr ("Reset Windows"));
1075
1076 reset_windows_action->setEnabled (false); // TODO: Make this work.
1077
1078 connect (show_command_window_action, SIGNAL (toggled (bool)),
1079 command_window, SLOT (setVisible (bool)));
1080
1081 connect (command_window, SIGNAL (active_changed (bool)),
1082 show_command_window_action, SLOT (setChecked (bool)));
1083
1084 connect (show_workspace_action, SIGNAL (toggled (bool)),
1085 _workspace_view, SLOT (setVisible (bool)));
1086
1087 connect (_workspace_view, SIGNAL (active_changed (bool)),
1088 show_workspace_action, SLOT (setChecked (bool)));
1089
1090 connect (show_history_action, SIGNAL (toggled (bool)),
1091 history_window, SLOT (setVisible (bool)));
1092
1093 connect (history_window, SIGNAL (active_changed (bool)),
1094 show_history_action, SLOT (setChecked (bool)));
1095
1096 connect (show_file_browser_action, SIGNAL (toggled (bool)),
1097 file_browser_window, SLOT (setVisible (bool)));
1098
1099 connect (file_browser_window, SIGNAL (active_changed (bool)),
1100 show_file_browser_action, SLOT (setChecked (bool)));
1101
1102 #ifdef HAVE_QSCINTILLA
1103 connect (show_editor_action, SIGNAL (toggled (bool)),
1104 _file_editor, SLOT (setVisible (bool)));
1105
1106 connect (_file_editor, SIGNAL (active_changed (bool)),
1107 show_editor_action, SLOT (setChecked (bool)));
1108 #endif
1109
1110 connect (show_documentation_action, SIGNAL (toggled (bool)),
1111 doc_browser_window, SLOT (setVisible (bool)));
1112
1113 connect (doc_browser_window, SIGNAL (active_changed (bool)),
1114 show_documentation_action, SLOT (setChecked (bool)));
1115
1116 connect (command_window_action, SIGNAL (triggered ()),
1117 command_window, SLOT (focus ()));
1118
1119 connect (workspace_action, SIGNAL (triggered ()),
1120 this, SLOT (focus_workspace ()));
1121
1122 connect (history_action, SIGNAL (triggered ()),
1123 history_window, SLOT (focus ()));
1124
1125 connect (file_browser_action, SIGNAL (triggered ()),
1126 file_browser_window, SLOT (focus ()));
1127
1128 connect (editor_action, SIGNAL (triggered ()),
1129 this, SLOT (focus_editor ()));
1130
1131 connect (documentation_action, SIGNAL (triggered ()),
1132 doc_browser_window, SLOT (focus ()));
1133
1134 connect (reset_windows_action, SIGNAL (triggered ()),
1135 this, SLOT (reset_windows ()));
1136 }
1137
1138 void
1139 main_window::construct_help_menu (QMenuBar *p)
1140 {
1141 QMenu *help_menu = p->addMenu (tr ("&Help"));
1142
1143 construct_documentation_menu (help_menu);
1144
1145 help_menu->addSeparator ();
1146
1147 QAction *report_bug_action
1148 = help_menu->addAction (tr ("Report Bug"));
1149
1150 QAction *octave_forge_action
1151 = help_menu->addAction (tr ("Visit Octave Forge"));
1152
1153 QAction *agora_action
1154 = help_menu->addAction (tr ("Visit Agora"));
1155
1156 help_menu->addSeparator ();
1157
1158 QAction *about_octave_action
1159 = help_menu->addAction (tr ("About Octave"));
1160
1161 connect (report_bug_action, SIGNAL (triggered ()),
1162 this, SLOT (open_bug_tracker_page ()));
1163
1164 connect (octave_forge_action, SIGNAL (triggered ()),
1165 this, SLOT (open_octave_forge_page ()));
1166
1167 connect (agora_action, SIGNAL (triggered ()),
1168 this, SLOT (open_agora_page ()));
1169
1170 connect (about_octave_action, SIGNAL (triggered ()),
1171 this, SLOT (show_about_octave ()));
1172 }
1173
1174 void
1175 main_window::construct_documentation_menu (QMenu *p)
1176 {
1177 QMenu *documentation_menu = p->addMenu (tr ("Documentation"));
1178
1179 QAction *ondisk_documentation_action
1180 = documentation_menu->addAction (tr ("On Disk"));
1181
1182 QAction *online_documentation_action
1183 = documentation_menu->addAction (tr ("Online"));
1184
1185 connect (ondisk_documentation_action, SIGNAL (triggered ()),
1186 doc_browser_window, SLOT (focus ()));
1187
1188 connect (online_documentation_action, SIGNAL (triggered ()),
1189 this, SLOT (open_online_documentation_page ()));
1190 }
1191
1192 void
1193 main_window::construct_tool_bar (void)
1194 {
1195 QToolBar *main_tool_bar = addToolBar ("Main");
1196
1197 main_tool_bar->setObjectName ("MainToolBar");
1198 main_tool_bar->addAction (_new_script_action);
1199 main_tool_bar->addAction (_open_action);
1200
1201 main_tool_bar->addSeparator ();
1202
1203 main_tool_bar->addAction (_cut_action);
1204 main_tool_bar->addAction (_copy_action);
1205 main_tool_bar->addAction (_paste_action);
1206 main_tool_bar->addAction (_undo_action);
1207 main_tool_bar->addAction (_redo_action);
1208
1209 main_tool_bar->addSeparator ();
1210
590 _current_directory_line_edit = new QLineEdit (this); 1211 _current_directory_line_edit = new QLineEdit (this);
591 _current_directory_combo_box = new QComboBox (this); 1212 _current_directory_combo_box = new QComboBox (this);
592 _current_directory_combo_box->setFixedWidth (current_directory_width); 1213 _current_directory_combo_box->setFixedWidth (current_directory_width);
593 _current_directory_combo_box->setEditable (true); 1214 _current_directory_combo_box->setEditable (true);
594 // setLineEdit takes ownership -> no need to delete line_edit in ~main_window 1215 // setLineEdit takes ownership -> no need to delete line_edit in ~main_window
601 current_directory_tool_button->setIcon (QIcon(":/actions/icons/search.png")); 1222 current_directory_tool_button->setIcon (QIcon(":/actions/icons/search.png"));
602 1223
603 QToolButton *current_directory_up_tool_button = new QToolButton (this); 1224 QToolButton *current_directory_up_tool_button = new QToolButton (this);
604 current_directory_up_tool_button->setIcon (QIcon(":/actions/icons/up.png")); 1225 current_directory_up_tool_button->setIcon (QIcon(":/actions/icons/up.png"));
605 1226
606 // Create and set the central widget. QMainWindow takes ownership of
607 // the widget (pointer) so there is no need to delete the object upon
608 // destroying this main_window.
609 QWidget *dummyWidget = new QWidget ();
610 dummyWidget->setObjectName ("CentralDummyWidget");
611 dummyWidget->resize (10, 10);
612 dummyWidget->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum);
613 dummyWidget->hide ();
614 setCentralWidget (dummyWidget);
615
616 #ifdef HAVE_QSCINTILLA
617 _file_editor = new file_editor (this);
618 #endif
619
620 QMenu *file_menu = menuBar ()->addMenu (tr ("&File"));
621
622 QMenu *new_menu = file_menu->addMenu(tr ("New"));
623
624 QAction *new_script_action
625 = new_menu->addAction (QIcon(":/actions/icons/filenew.png"), tr ("Script"));
626 new_script_action->setShortcut (QKeySequence::New);
627 new_script_action->setShortcutContext (Qt::ApplicationShortcut);
628
629 QAction *new_function_action = new_menu->addAction (tr ("Function"));
630 new_function_action->setEnabled (false); // TODO: Make this work.
631 QAction *new_class_action = new_menu->addAction (tr ("Class"));
632 new_class_action->setEnabled (false); // TODO: Make this work.
633 QAction *new_enumeration_action = new_menu->addAction (tr ("Enumeration"));
634 new_enumeration_action->setEnabled (false); // TODO: Make this work.
635 QAction *new_figure_action = new_menu->addAction (tr ("Figure"));
636 new_figure_action->setEnabled (false); // TODO: Make this work.
637 QAction *new_variable_action = new_menu->addAction (tr ("Variable"));
638 new_variable_action->setEnabled (false); // TODO: Make this work.
639 QAction *new_model_action = new_menu->addAction (tr ("Model"));
640 new_model_action->setEnabled (false); // TODO: Make this work.
641 QAction *new_gui_action = new_menu->addAction (tr ("GUI"));
642 new_gui_action->setEnabled (false); // TODO: Make this work.
643
644 QAction *open_action
645 = file_menu->addAction (QIcon(":/actions/icons/fileopen.png"), tr ("Open..."));
646 open_action->setShortcut (QKeySequence::Open);
647 open_action->setShortcutContext (Qt::ApplicationShortcut);
648
649 #ifdef HAVE_QSCINTILLA
650 file_menu->addMenu(_file_editor->get_mru_menu ());
651 #endif
652
653 QAction *close_command_window_action
654 = file_menu->addAction (tr ("Close Command Window"));
655 close_command_window_action->setShortcut (QKeySequence::Close);
656 close_command_window_action->setEnabled (false); // TODO: Make this work.
657
658 file_menu->addSeparator (); /////
659
660 QAction *import_data_action
661 = file_menu->addAction (tr ("Import Data"));
662 import_data_action->setEnabled (false); // TODO: Make this work.
663
664 QAction *save_workspace_action
665 = file_menu->addAction (tr ("Save Workspace As"));
666
667 file_menu->addSeparator (); /////
668
669 QAction *preferences_action
670 = file_menu->addAction (QIcon(":/actions/icons/configure.png"),
671 tr ("Preferences..."));
672
673 file_menu->addSeparator (); /////
674
675 QAction *page_setup_action
676 = file_menu->addAction (tr ("Page Setup..."));
677 page_setup_action->setEnabled (false); // TODO: Make this work.
678 QAction *print_action
679 = file_menu->addAction (tr ("Print"));
680 print_action->setShortcut (QKeySequence::Print);
681 print_action->setEnabled (false); // TODO: Make this work.
682 QAction *print_selection_action
683 = file_menu->addAction (tr ("Print Selection..."));
684 print_selection_action->setEnabled (false); // TODO: Make this work.
685
686 file_menu->addSeparator (); /////
687
688 QAction *exit_action = file_menu->addAction (tr ("Exit"));
689 exit_action->setShortcut (QKeySequence::Quit);
690
691
692 QMenu *edit_menu = menuBar ()->addMenu (tr ("&Edit"));
693 QAction *undo_action
694 = edit_menu->addAction (QIcon(":/actions/icons/undo.png"), tr ("Undo"));
695 undo_action->setShortcut (QKeySequence::Undo);
696
697 QAction *redo_action
698 = edit_menu->addAction (QIcon(":/actions/icons/redo.png"), tr ("Redo"));
699 redo_action->setShortcut (QKeySequence::Redo);
700
701 edit_menu->addSeparator (); /////
702
703 QAction *cut_action
704 = edit_menu->addAction (QIcon(":/actions/icons/editcut.png"), tr ("Cut"));
705 cut_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_X);
706
707 QAction *copy_action
708 = edit_menu->addAction (QIcon(":/actions/icons/editcopy.png"), tr ("Copy"));
709 copy_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_C);
710
711 QAction *paste_action
712 = edit_menu->addAction (QIcon(":/actions/icons/editpaste.png"), tr ("Paste"));
713 paste_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_V);
714
715 QAction *paste_to_workspace_action
716 = edit_menu->addAction (tr ("Paste To Workspace..."));
717 paste_to_workspace_action->setEnabled (false); // TODO: Make this work.
718
719 edit_menu->addSeparator (); /////
720
721 QAction *select_all_action
722 = edit_menu->addAction (tr ("Select All"));
723 select_all_action->setEnabled (false); // TODO: Make this work.
724 QAction *delete_action
725 = edit_menu->addAction (tr ("Delete"));
726 delete_action->setShortcut (Qt::Key_Delete);
727 delete_action->setEnabled (false); // TODO: Make this work.
728
729 edit_menu->addSeparator (); /////
730
731 QAction *find_action
732 = edit_menu->addAction (tr ("Find..."));
733 find_action->setEnabled (false); // TODO: Make this work.
734 QAction *find_files_action
735 = edit_menu->addAction (tr ("Find Files..."));
736 find_files_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier
737 + Qt::Key_F);
738 find_files_action->setEnabled (false); // TODO: Make this work.
739
740 edit_menu->addSeparator (); /////
741
742 QAction *clear_command_window_action
743 = edit_menu->addAction (tr ("Clear Command Window"));
744 clear_command_window_action->setEnabled (false); // TODO: Make this work.
745 QAction *clear_command_history
746 = edit_menu->addAction(tr ("Clear Command History"));
747 QAction * clear_workspace_action
748 = edit_menu->addAction (tr ("Clear Workspace"));
749
750 _debug_menu = menuBar ()->addMenu (tr ("De&bug"));
751
752 _debug_step_over = _debug_menu->addAction (QIcon (":/actions/icons/db_step.png"), tr ("Step"));
753 _debug_step_over->setEnabled (false);
754 #ifdef HAVE_QSCINTILLA
755 _file_editor->debug_menu ()->addAction (_debug_step_over);
756 _file_editor->toolbar ()->addAction (_debug_step_over);
757 #endif
758 _debug_step_over->setShortcut (Qt::Key_F10);
759
760 _debug_step_into = _debug_menu->addAction (QIcon (":/actions/icons/db_step_in.png"), tr ("Step in"));
761 _debug_step_into->setEnabled (false);
762 #ifdef HAVE_QSCINTILLA
763 _file_editor->debug_menu ()->addAction (_debug_step_into);
764 _file_editor->toolbar ()->addAction (_debug_step_into);
765 #endif
766 _debug_step_into->setShortcut (Qt::Key_F11);
767
768 _debug_step_out = _debug_menu->addAction (QIcon (":/actions/icons/db_step_out.png"), tr ("Step out"));
769 _debug_step_out->setEnabled (false);
770 #ifdef HAVE_QSCINTILLA
771 _file_editor->debug_menu ()->addAction (_debug_step_out);
772 _file_editor->toolbar ()->addAction (_debug_step_out);
773 #endif
774 _debug_step_out->setShortcut (Qt::ShiftModifier + Qt::Key_F11);
775
776 _debug_continue = _debug_menu->addAction (QIcon (":/actions/icons/db_cont.png"), tr ("Continue"));
777 _debug_continue->setEnabled (false);
778 #ifdef HAVE_QSCINTILLA
779 _file_editor->debug_menu ()->addAction (_debug_continue);
780 _file_editor->toolbar ()->addAction (_debug_continue);
781 #endif
782 _debug_continue->setShortcut (Qt::Key_F5);
783
784 _debug_menu->addSeparator (); /////
785 #ifdef HAVE_QSCINTILLA
786 _file_editor->debug_menu ()->addSeparator (); /////
787 #endif
788
789 _debug_quit = _debug_menu->addAction (QIcon (":/actions/icons/db_stop.png"), tr ("Exit Debug Mode"));
790 _debug_quit->setEnabled (false);
791 #ifdef HAVE_QSCINTILLA
792 _file_editor->debug_menu ()->addAction (_debug_quit);
793 _file_editor->toolbar ()->addAction (_debug_quit);
794 #endif
795 _debug_quit->setShortcut (Qt::ShiftModifier + Qt::Key_F5);
796
797 //QMenu *parallelMenu = menuBar ()->addMenu (tr ("&Parallel"));
798
799 QMenu * desktop_menu = menuBar ()->addMenu (tr ("&Desktop"));
800 QAction * load_workspace_action = desktop_menu->addAction (tr ("Load workspace"));
801
802
803 // Window menu
804 QMenu * window_menu = menuBar ()->addMenu (tr ("&Window"));
805 QAction * show_command_window_action
806 = window_menu->addAction (tr ("Show Command Window"));
807 show_command_window_action->setCheckable (true);
808 show_command_window_action->setShortcut (Qt::ControlModifier
809 + Qt::ShiftModifier + Qt::Key_0);
810 show_command_window_action->setShortcutContext (Qt::ApplicationShortcut);
811 QAction * show_history_action
812 = window_menu->addAction (tr ("Show Command History"));
813 show_history_action->setCheckable (true);
814 show_history_action->setShortcut (Qt::ControlModifier
815 + Qt::ShiftModifier + Qt::Key_1);
816 show_history_action->setShortcutContext (Qt::ApplicationShortcut);
817 QAction * show_file_browser_action
818 = window_menu->addAction (tr ("Show Current Directory"));
819 show_file_browser_action->setCheckable (true);
820 show_file_browser_action->setShortcut (Qt::ControlModifier
821 + Qt::ShiftModifier + Qt::Key_2);
822 show_file_browser_action->setShortcutContext (Qt::ApplicationShortcut);
823 QAction * show_workspace_action
824 = window_menu->addAction (tr ("Show Workspace"));
825 show_workspace_action->setCheckable (true);
826 show_workspace_action->setShortcut (Qt::ControlModifier
827 + Qt::ShiftModifier + Qt::Key_3);
828 show_workspace_action->setShortcutContext (Qt::ApplicationShortcut);
829 QAction * show_editor_action = window_menu->addAction (tr ("Show Editor"));
830 show_editor_action->setCheckable (true);
831 show_editor_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier
832 + Qt::Key_4);
833 show_editor_action->setShortcutContext (Qt::ApplicationShortcut);
834 QAction * show_documentation_action = window_menu->addAction (tr ("Show Documentation"));
835 show_documentation_action->setCheckable (true);
836 show_documentation_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier
837 + Qt::Key_5);
838 show_documentation_action->setShortcutContext (Qt::ApplicationShortcut);
839 window_menu->addSeparator (); /////
840
841 QAction * command_window_action
842 = window_menu->addAction (tr ("Command Window"));
843 command_window_action->setShortcut (Qt::ControlModifier + Qt::Key_0);
844 command_window_action->setShortcutContext (Qt::ApplicationShortcut);
845 QAction * history_action
846 = window_menu->addAction (tr ("Command History"));
847 history_action->setShortcut (Qt::ControlModifier + Qt::Key_1);
848 history_action->setShortcutContext (Qt::ApplicationShortcut);
849 QAction * file_browser_action
850 = window_menu->addAction (tr ("Current Directory"));
851 file_browser_action->setShortcut (Qt::ControlModifier + Qt::Key_2);
852 file_browser_action->setShortcutContext (Qt::ApplicationShortcut);
853 QAction * workspace_action
854 = window_menu->addAction (tr ("Workspace"));
855 workspace_action->setShortcut (Qt::ControlModifier + Qt::Key_3);
856 workspace_action->setShortcutContext (Qt::ApplicationShortcut);
857 QAction * editor_action
858 = window_menu->addAction (tr ("Editor"));
859 editor_action->setShortcut (Qt::ControlModifier + Qt::Key_4);
860 editor_action->setShortcutContext (Qt::ApplicationShortcut);
861 QAction * documentation_action
862 = window_menu->addAction (tr ("Documentation"));
863 documentation_action->setShortcut (Qt::ControlModifier + Qt::Key_5);
864 documentation_action->setShortcutContext (Qt::ApplicationShortcut);
865
866 window_menu->addSeparator (); /////
867
868 QAction * reset_windows_action
869 = window_menu->addAction (tr ("Reset Windows"));
870 reset_windows_action->setEnabled (false); // TODO: Make this work.
871
872 // Help menu
873 QMenu * help_menu = menuBar ()->addMenu (tr ("&Help"));
874 QMenu * documentation_menu
875 = help_menu->addMenu (tr ("Documentation"));
876 QAction * ondisk_documentation_action
877 = documentation_menu->addAction (tr ("On Disk"));
878 QAction * online_documentation_action
879 = documentation_menu->addAction (tr ("Online"));
880
881 help_menu->addSeparator (); /////
882
883 QAction * report_bug_action
884 = help_menu->addAction (tr ("Report Bug"));
885 QAction * octave_forge_action
886 = help_menu->addAction (tr ("Visit Octave Forge"));
887 QAction * agora_action
888 = help_menu->addAction (tr ("Visit Agora"));
889
890 help_menu->addSeparator (); /////
891
892 QAction * about_octave_action
893 = help_menu->addAction (tr ("About Octave"));
894
895 // Toolbars
896 QToolBar *main_tool_bar = addToolBar ("Main");
897 main_tool_bar->setObjectName ("MainToolBar");
898 main_tool_bar->addAction (new_script_action);
899 main_tool_bar->addAction (open_action);
900
901 main_tool_bar->addSeparator (); /////
902
903 main_tool_bar->addAction (cut_action);
904 main_tool_bar->addAction (copy_action);
905 main_tool_bar->addAction (paste_action);
906 main_tool_bar->addAction (undo_action);
907 main_tool_bar->addAction (redo_action);
908
909 main_tool_bar->addSeparator (); /////
910
911 // addWidget takes ownership of the objects so there is no 1227 // addWidget takes ownership of the objects so there is no
912 // need to delete these upon destroying this main_window. 1228 // need to delete these upon destroying this main_window.
913 main_tool_bar->addWidget (new QLabel (tr ("Current Directory:"))); 1229 main_tool_bar->addWidget (new QLabel (tr ("Current Directory:")));
914 main_tool_bar->addWidget (_current_directory_combo_box); 1230 main_tool_bar->addWidget (_current_directory_combo_box);
915 main_tool_bar->addWidget (current_directory_tool_button); 1231 main_tool_bar->addWidget (current_directory_tool_button);
916 main_tool_bar->addWidget (current_directory_up_tool_button); 1232 main_tool_bar->addWidget (current_directory_up_tool_button);
917 1233
918 connect (qApp, SIGNAL (aboutToQuit ()), 1234 connect (_current_directory_combo_box, SIGNAL (activated (QString)),
919 this, SLOT (prepare_for_quit ())); 1235 this, SLOT (set_current_working_directory (QString)));
920 connect (preferences_action, SIGNAL (triggered ()), 1236
921 this, SLOT (process_settings_dialog_request ())); 1237 connect (_current_directory_line_edit, SIGNAL (returnPressed ()),
922 connect (exit_action, SIGNAL (triggered ()), 1238 this, SLOT (accept_directory_line_edit ()));
923 this, SLOT (close ())); 1239
924 connect (new_script_action, SIGNAL (triggered ()),
925 this, SLOT (new_file ()));
926 connect (open_action, SIGNAL (triggered ()),
927 this, SLOT (open_file ()));
928 connect (online_documentation_action, SIGNAL (triggered ()),
929 this, SLOT (open_online_documentation_page ()));
930 connect (report_bug_action, SIGNAL (triggered ()),
931 this, SLOT (open_bug_tracker_page ()));
932 connect (octave_forge_action, SIGNAL (triggered ()),
933 this, SLOT (open_octave_forge_page ()));
934 connect (agora_action, SIGNAL (triggered ()),
935 this, SLOT (open_agora_page ()));
936 connect (about_octave_action, SIGNAL (triggered ()),
937 this, SLOT (show_about_octave ()));
938 connect (show_command_window_action, SIGNAL (toggled (bool)),
939 command_window, SLOT (setVisible (bool)));
940 connect (command_window, SIGNAL (active_changed (bool)),
941 show_command_window_action, SLOT (setChecked (bool)));
942 connect (show_workspace_action, SIGNAL (toggled (bool)),
943 _workspace_view, SLOT (setVisible (bool)));
944 connect (_workspace_view, SIGNAL (active_changed (bool)),
945 show_workspace_action, SLOT (setChecked (bool)));
946 connect (show_history_action, SIGNAL (toggled (bool)),
947 history_window, SLOT (setVisible (bool)));
948 connect (history_window, SIGNAL (active_changed (bool)),
949 show_history_action, SLOT (setChecked (bool)));
950 connect (show_file_browser_action, SIGNAL (toggled (bool)),
951 file_browser_window, SLOT (setVisible (bool)));
952 connect (file_browser_window, SIGNAL (active_changed (bool)),
953 show_file_browser_action, SLOT (setChecked (bool)));
954 #ifdef HAVE_QSCINTILLA
955 connect (show_editor_action, SIGNAL (toggled (bool)),
956 _file_editor, SLOT (setVisible (bool)));
957 connect (_file_editor, SIGNAL (active_changed (bool)),
958 show_editor_action, SLOT (setChecked (bool)));
959 #endif
960 connect (show_documentation_action, SIGNAL (toggled (bool)),
961 doc_browser_window, SLOT (setVisible (bool)));
962 connect (doc_browser_window, SIGNAL (active_changed (bool)),
963 show_documentation_action, SLOT (setChecked (bool)));
964
965 connect (command_window_action, SIGNAL (triggered ()),
966 command_window, SLOT (focus ()));
967
968 connect (workspace_action, SIGNAL (triggered ()),
969 this, SLOT (focus_workspace ()));
970 connect (history_action, SIGNAL (triggered ()),
971 history_window, SLOT (focus ()));
972 connect (file_browser_action, SIGNAL (triggered ()),
973 file_browser_window, SLOT (focus ()));
974 connect (editor_action, SIGNAL (triggered ()),
975 this, SLOT (focus_editor ()));
976 connect (documentation_action, SIGNAL (triggered ()),
977 doc_browser_window, SLOT (focus ()));
978 connect (ondisk_documentation_action, SIGNAL (triggered ()),
979 doc_browser_window, SLOT (focus ()));
980
981 connect (reset_windows_action, SIGNAL (triggered ()),
982 this, SLOT (reset_windows ()));
983 #ifdef HAVE_QSCINTILLA
984 connect (this, SIGNAL (settings_changed (const QSettings *)),
985 _file_editor, SLOT (notice_settings (const QSettings *)));
986 #endif
987 connect (this, SIGNAL (settings_changed (const QSettings *)),
988 command_window, SLOT (notice_settings (const QSettings *)));
989 connect (this, SIGNAL (settings_changed (const QSettings *)),
990 file_browser_window, SLOT (notice_settings (const QSettings *)));
991 connect (this, SIGNAL (settings_changed (const QSettings *)),
992 this, SLOT (notice_settings (const QSettings *)));
993 connect (file_browser_window, SIGNAL (open_file (QString)),
994 this, SLOT (open_file (QString)));
995 connect (file_browser_window, SIGNAL (displayed_directory_changed(QString)),
996 this, SLOT (set_current_working_directory(QString)));
997 connect (this, SIGNAL (relay_command_signal (const QString&)),
998 command_window, SLOT (relay_command (const QString&)));
999 connect (history_window, SIGNAL (command_create_script (const QString&)),
1000 this, SLOT (new_file (const QString&)));
1001 connect (save_workspace_action, SIGNAL (triggered ()),
1002 this, SLOT (handle_save_workspace_request ()));
1003 connect (load_workspace_action, SIGNAL (triggered ()),
1004 this, SLOT (handle_load_workspace_request ()));
1005 connect (clear_workspace_action, SIGNAL (triggered ()),
1006 this, SLOT (handle_clear_workspace_request ()));
1007 connect (current_directory_tool_button, SIGNAL (clicked ()), 1240 connect (current_directory_tool_button, SIGNAL (clicked ()),
1008 this, SLOT (browse_for_directory ())); 1241 this, SLOT (browse_for_directory ()));
1242
1009 connect (current_directory_up_tool_button, SIGNAL (clicked ()), 1243 connect (current_directory_up_tool_button, SIGNAL (clicked ()),
1010 this, SLOT (change_directory_up ())); 1244 this, SLOT (change_directory_up ()));
1011 connect (copy_action, SIGNAL (triggered()),
1012 command_window, SLOT (copyClipboard ()));
1013 connect (paste_action, SIGNAL (triggered()),
1014 command_window, SLOT (pasteClipboard ()));
1015 connect (_current_directory_combo_box, SIGNAL (activated (QString)),
1016 this, SLOT (set_current_working_directory (QString)));
1017 connect (_current_directory_line_edit, SIGNAL (returnPressed ()),
1018 this, SLOT (accept_directory_line_edit ()));
1019 connect (_debug_continue, SIGNAL (triggered ()),
1020 this, SLOT (debug_continue ()));
1021 connect (_debug_step_into, SIGNAL (triggered ()),
1022 this, SLOT (debug_step_into ()));
1023 connect (_debug_step_over, SIGNAL (triggered ()),
1024 this, SLOT (debug_step_over ()));
1025 connect (_debug_step_out, SIGNAL (triggered ()),
1026 this, SLOT (debug_step_out ()));
1027 connect (_debug_quit, SIGNAL (triggered ()),
1028 this, SLOT (debug_quit ()));
1029
1030 connect (clear_command_history, SIGNAL (triggered ()),
1031 this, SLOT (handle_clear_history_request ()));
1032
1033 setWindowTitle ("Octave");
1034 setDockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks);
1035 addDockWidget (Qt::RightDockWidgetArea, command_window);
1036 addDockWidget (Qt::RightDockWidgetArea, doc_browser_window);
1037 tabifyDockWidget (command_window, doc_browser_window);
1038 #ifdef HAVE_QSCINTILLA
1039 addDockWidget (Qt::RightDockWidgetArea, _file_editor);
1040 tabifyDockWidget (command_window, _file_editor);
1041 #endif
1042 addDockWidget (Qt::LeftDockWidgetArea, file_browser_window);
1043 addDockWidget (Qt::LeftDockWidgetArea, _workspace_view);
1044 addDockWidget (Qt::LeftDockWidgetArea, history_window);
1045
1046 int win_x = QApplication::desktop()->width();
1047 int win_y = QApplication::desktop()->height();
1048 if (win_x > 960)
1049 win_x = 960;
1050 if (win_y > 720)
1051 win_y = 720;
1052 setGeometry (0,0,win_x,win_y);
1053
1054 setStatusBar (status_bar);
1055
1056 _octave_qt_event_listener = new octave_qt_event_listener ();
1057
1058 connect (_octave_qt_event_listener,
1059 SIGNAL (update_workspace_signal ()),
1060 this,
1061 SLOT (update_workspace ()));
1062
1063 // FIXME -- is it possible to eliminate the event_listenter?
1064
1065 _octave_qt_link = new octave_qt_link ();
1066
1067 connect (_octave_qt_link, SIGNAL (change_directory_signal (QString)),
1068 this, SLOT (change_directory (QString)));
1069
1070 connect (_octave_qt_link,
1071 SIGNAL (set_history_signal (const QStringList&)),
1072 history_window, SLOT (set_history (const QStringList&)));
1073
1074 connect (_octave_qt_link,
1075 SIGNAL (append_history_signal (const QString&)),
1076 history_window, SLOT (append_history (const QString&)));
1077
1078 connect (_octave_qt_link,
1079 SIGNAL (clear_history_signal (void)),
1080 history_window, SLOT (clear_history (void)));
1081
1082 connect (_octave_qt_link, SIGNAL (enter_debugger_signal ()),
1083 this, SLOT (handle_enter_debugger ()));
1084
1085 connect (_octave_qt_link, SIGNAL (exit_debugger_signal ()),
1086 this, SLOT (handle_exit_debugger ()));
1087
1088 connect (_octave_qt_link,
1089 SIGNAL (update_breakpoint_marker_signal (bool, const QString&, int)),
1090 _file_editor,
1091 SLOT (handle_update_breakpoint_marker_request (bool, const QString&, int)));
1092
1093 connect (_octave_qt_link,
1094 SIGNAL (edit_file_signal (const QString&)),
1095 _file_editor,
1096 SLOT (handle_edit_file_request (const QString&)));
1097
1098 connect (_octave_qt_link,
1099 SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
1100 _file_editor,
1101 SLOT (handle_insert_debugger_pointer_request (const QString&, int)));
1102
1103 connect (_octave_qt_link,
1104 SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
1105 _file_editor,
1106 SLOT (handle_delete_debugger_pointer_request (const QString&, int)));
1107
1108 _octave_qt_link->execute_interpreter ();
1109
1110 octave_link::connect_link (_octave_qt_link);
1111
1112 octave_link::register_event_listener (_octave_qt_event_listener);
1113
1114 QDir curr_dir;
1115 set_current_working_directory (curr_dir.absolutePath ());
1116 } 1245 }
1117 1246
1118 void 1247 void
1119 main_window::save_workspace_callback (const std::string& file) 1248 main_window::save_workspace_callback (const std::string& file)
1120 { 1249 {