Mercurial > hg > octave-nkf
comparison libgui/src/m-editor/file-editor.cc @ 17790:86c6ae5f969e
Use GNU style coding conventions for code in libgui/
* libgui/qterminal/libqterminal/QTerminal.h, libgui/src/color-picker.cc,
libgui/src/color-picker.h, libgui/src/dialog.cc, libgui/src/dialog.h,
libgui/src/documentation-dock-widget.cc, libgui/src/files-dock-widget.cc,
libgui/src/files-dock-widget.h, libgui/src/find-files-dialog.cc,
libgui/src/find-files-dialog.h, libgui/src/find-files-model.cc,
libgui/src/find-files-model.h, libgui/src/history-dock-widget.cc,
libgui/src/history-dock-widget.h, libgui/src/m-editor/file-editor-interface.h,
libgui/src/m-editor/file-editor-tab.cc, libgui/src/m-editor/file-editor-tab.h,
libgui/src/m-editor/file-editor.cc, libgui/src/m-editor/find-dialog.cc,
libgui/src/m-editor/find-dialog.h, libgui/src/m-editor/octave-qscintilla.cc,
libgui/src/main-window.cc, libgui/src/main-window.h,
libgui/src/news-dock-widget.h, libgui/src/octave-dock-widget.cc,
libgui/src/octave-dock-widget.h, libgui/src/octave-gui.cc,
libgui/src/octave-qt-link.cc, libgui/src/octave-qt-link.h,
libgui/src/qtinfo/parser.cc, libgui/src/qtinfo/parser.h,
libgui/src/qtinfo/webinfo.cc, libgui/src/qtinfo/webinfo.h,
libgui/src/resource-manager.cc, libgui/src/settings-dialog.cc,
libgui/src/settings-dialog.h, libgui/src/terminal-dock-widget.cc,
libgui/src/welcome-wizard.cc, libgui/src/workspace-model.cc,
libgui/src/workspace-model.h, libgui/src/workspace-view.cc,
libgui/src/workspace-view.h:
Use GNU style coding conventions for code in libgui/
author | Rik <rik@octave.org> |
---|---|
date | Tue, 29 Oct 2013 09:54:40 -0700 |
parents | d63878346099 |
children | 2c241092b47b |
comparison
equal
deleted
inserted
replaced
17789:f2b047f9b605 | 17790:86c6ae5f969e |
---|---|
73 | 73 |
74 settings->setValue ("editor/savedSessionTabs", fetFileNames); | 74 settings->setValue ("editor/savedSessionTabs", fetFileNames); |
75 settings->sync (); | 75 settings->sync (); |
76 | 76 |
77 for (int index = _tab_widget->count ()-1; index >= 0; index--) | 77 for (int index = _tab_widget->count ()-1; index >= 0; index--) |
78 emit fetab_close_request (_tab_widget->widget (index),true); // true: app closing | 78 { |
79 // true: app closing | |
80 emit fetab_close_request (_tab_widget->widget (index), true); | |
81 } | |
79 | 82 |
80 if (_mru_file_menu) | 83 if (_mru_file_menu) |
81 delete _mru_file_menu; | 84 delete _mru_file_menu; |
82 } | 85 } |
83 | 86 |
211 break; | 214 break; |
212 } | 215 } |
213 } | 216 } |
214 | 217 |
215 return retval; | 218 return retval; |
216 } | 219 } |
217 | 220 |
218 void | 221 void |
219 file_editor::request_open_file (const QString& openFileName, int line, | 222 file_editor::request_open_file (const QString& openFileName, int line, |
220 bool debug_pointer, | 223 bool debug_pointer, |
221 bool breakpoint_marker, bool insert) | 224 bool breakpoint_marker, bool insert) |
296 { | 299 { |
297 delete fileEditorTab; | 300 delete fileEditorTab; |
298 | 301 |
299 if (QFile::exists (openFileName)) | 302 if (QFile::exists (openFileName)) |
300 { | 303 { |
301 // File not readable: create a NonModal message about error. | 304 // File not readable: |
305 // create a NonModal message about error. | |
302 QMessageBox *msgBox | 306 QMessageBox *msgBox |
303 = new QMessageBox (QMessageBox::Critical, | 307 = new QMessageBox (QMessageBox::Critical, |
304 tr ("Octave Editor"), | 308 tr ("Octave Editor"), |
305 tr ("Could not open file\n%1\nfor read: %2."). | 309 tr ("Could not open file\n%1\nfor read: %2."). |
306 arg (openFileName).arg (result), | 310 arg (openFileName).arg (result), |
307 QMessageBox::Ok, this); | 311 QMessageBox::Ok, this); |
308 | 312 |
309 msgBox->setWindowModality (Qt::NonModal); | 313 msgBox->setWindowModality (Qt::NonModal); |
310 msgBox->setAttribute (Qt::WA_DeleteOnClose); | 314 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
311 msgBox->show (); | 315 msgBox->show (); |
312 } | 316 } |
313 else | 317 else |
314 { | 318 { |
315 // File does not exist, should it be crated? | 319 // File does not exist, should it be crated? |
316 QMessageBox *msgBox; | 320 QMessageBox *msgBox; |
317 int answer; | 321 int answer; |
318 if (settings->value ("editor/create_new_file",false).toBool ()) | 322 if (settings->value ("editor/create_new_file", |
323 false).toBool ()) | |
319 { | 324 { |
320 answer = QMessageBox::Yes; | 325 answer = QMessageBox::Yes; |
321 } | 326 } |
322 else | 327 else |
323 { | 328 { |
324 msgBox = new QMessageBox (QMessageBox::Question, | 329 msgBox = new QMessageBox (QMessageBox::Question, |
325 tr ("Octave Editor"), | 330 tr ("Octave Editor"), |
326 tr ("File\n%1\ndoes not exist. " | 331 tr ("File\n%1\ndoes not exist. " |
327 "Do you want to create it?").arg (openFileName), | 332 "Do you want to create it?").arg (openFileName), |
328 QMessageBox::Yes | QMessageBox::No, this); | 333 QMessageBox::Yes |
334 | QMessageBox::No, this); | |
329 | 335 |
330 msgBox->setAttribute (Qt::WA_DeleteOnClose); | 336 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
331 answer = msgBox->exec (); | 337 answer = msgBox->exec (); |
332 } | 338 } |
333 | 339 |
337 QFile file (openFileName); | 343 QFile file (openFileName); |
338 if (!file.open (QIODevice::WriteOnly)) | 344 if (!file.open (QIODevice::WriteOnly)) |
339 { | 345 { |
340 // error opening the file | 346 // error opening the file |
341 msgBox = new QMessageBox (QMessageBox::Critical, | 347 msgBox = new QMessageBox (QMessageBox::Critical, |
342 tr ("Octave Editor"), | 348 tr ("Octave Editor"), |
343 tr ("Could not open file\n%1\nfor write: %2."). | 349 tr ("Could not open file\n%1\nfor write: %2."). |
344 arg (openFileName).arg (file.errorString ()), | 350 arg (openFileName).arg (file.errorString ()), |
345 QMessageBox::Ok, this); | 351 QMessageBox::Ok, this); |
346 | 352 |
347 msgBox->setWindowModality (Qt::NonModal); | 353 msgBox->setWindowModality (Qt::NonModal); |
348 msgBox->setAttribute (Qt::WA_DeleteOnClose); | 354 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
349 msgBox->show (); | 355 msgBox->show (); |
350 } | 356 } |
374 } | 380 } |
375 } | 381 } |
376 | 382 |
377 | 383 |
378 void | 384 void |
379 file_editor::check_conflict_save (const QString& saveFileName, bool remove_on_success) | 385 file_editor::check_conflict_save (const QString& saveFileName, |
386 bool remove_on_success) | |
380 { | 387 { |
381 // Have all file editor tabs signal what their file names are. | 388 // Have all file editor tabs signal what their file names are. |
382 editor_tab_map.clear (); | 389 editor_tab_map.clear (); |
383 emit fetab_file_name_query (0); | 390 emit fetab_file_name_query (0); |
384 | 391 |
540 } | 547 } |
541 | 548 |
542 void | 549 void |
543 file_editor::request_save_file_as (void) | 550 file_editor::request_save_file_as (void) |
544 { | 551 { |
545 emit fetab_save_file_as (_tab_widget->currentWidget ()); | 552 emit fetab_save_file_as (_tab_widget->currentWidget ()); |
546 } | 553 } |
547 | 554 |
548 void | 555 void |
549 file_editor::request_print_file (void) | 556 file_editor::request_print_file (void) |
550 { | 557 { |
551 emit fetab_print_file (_tab_widget->currentWidget ()); | 558 emit fetab_print_file (_tab_widget->currentWidget ()); |
552 } | 559 } |
553 | 560 |
554 | 561 |
555 void | 562 void |
556 file_editor::request_run_file (void) | 563 file_editor::request_run_file (void) |
652 | 659 |
653 // configure and show active actions of mru-menu | 660 // configure and show active actions of mru-menu |
654 for (int i = 0; i < num_files; ++i) | 661 for (int i = 0; i < num_files; ++i) |
655 { | 662 { |
656 QString text = tr ("&%1 %2"). | 663 QString text = tr ("&%1 %2"). |
657 arg ((i+1) % int (MaxMRUFiles)).arg (_mru_files.at (i)); | 664 arg ((i+1) % int (MaxMRUFiles)).arg (_mru_files.at (i)); |
658 _mru_file_actions[i]->setText (text); | 665 _mru_file_actions[i]->setText (text); |
659 _mru_file_actions[i]->setData (_mru_files.at (i)); | 666 _mru_file_actions[i]->setData (_mru_files.at (i)); |
660 _mru_file_actions[i]->setVisible (true); | 667 _mru_file_actions[i]->setVisible (true); |
661 } | 668 } |
662 | 669 |
663 // hide unused mru-menu entries | 670 // hide unused mru-menu entries |
664 for (int j = num_files; j < MaxMRUFiles; ++j) | 671 for (int j = num_files; j < MaxMRUFiles; ++j) |
665 _mru_file_actions[j]->setVisible (false); | 672 _mru_file_actions[j]->setVisible (false); |
666 | 673 |
667 // delete entries in string-list beyond MaxMRUFiles | 674 // delete entries in string-list beyond MaxMRUFiles |
668 while (_mru_files.size () > MaxMRUFiles) | 675 while (_mru_files.size () > MaxMRUFiles) |
669 _mru_files.removeLast (); | 676 _mru_files.removeLast (); |
670 | 677 |
671 // save actual mru-list in settings | 678 // save actual mru-list in settings |
672 QSettings *settings = resource_manager::get_settings (); | 679 QSettings *settings = resource_manager::get_settings (); |
673 | 680 |
674 // FIXME -- what should happen if settings is 0? | 681 // FIXME: what should happen if settings is 0? |
675 settings->setValue ("editor/mru_file_list", _mru_files); | 682 settings->setValue ("editor/mru_file_list", _mru_files); |
676 settings->sync (); | 683 settings->sync (); |
677 } | 684 } |
678 | 685 |
679 void | 686 void |
680 file_editor::handle_file_name_changed (const QString& fname, | 687 file_editor::handle_file_name_changed (const QString& fname, |
681 const QString& tip) | 688 const QString& tip) |
745 _tab_widget->removeTab (i); | 752 _tab_widget->removeTab (i); |
746 delete fileEditorTab; | 753 delete fileEditorTab; |
747 } | 754 } |
748 } | 755 } |
749 } | 756 } |
750 check_actions (); | 757 check_actions (); |
751 } | 758 } |
752 | 759 |
753 void | 760 void |
754 file_editor::handle_add_filename_to_list (const QString& fileName, QWidget *ID) | 761 file_editor::handle_add_filename_to_list (const QString& fileName, QWidget *ID) |
755 { | 762 { |
815 void | 822 void |
816 file_editor::construct (void) | 823 file_editor::construct (void) |
817 { | 824 { |
818 QWidget *editor_widget = new QWidget (this); | 825 QWidget *editor_widget = new QWidget (this); |
819 | 826 |
820 // FIXME -- what was the intended purpose of this unused variable? | 827 // FIXME: what was the intended purpose of this unused variable? |
821 // QStyle *editor_style = QApplication::style (); | 828 // QStyle *editor_style = QApplication::style (); |
822 | 829 |
823 _menu_bar = new QMenuBar (editor_widget); | 830 _menu_bar = new QMenuBar (editor_widget); |
824 _tool_bar = new QToolBar (editor_widget); | 831 _tool_bar = new QToolBar (editor_widget); |
825 _tab_widget = new QTabWidget (editor_widget); | 832 _tab_widget = new QTabWidget (editor_widget); |
830 | 837 |
831 QAction *open_action = new QAction (QIcon (":/actions/icons/fileopen.png"), | 838 QAction *open_action = new QAction (QIcon (":/actions/icons/fileopen.png"), |
832 tr ("&Open File"), _tool_bar); | 839 tr ("&Open File"), _tool_bar); |
833 | 840 |
834 _save_action = new QAction (QIcon (":/actions/icons/filesave.png"), | 841 _save_action = new QAction (QIcon (":/actions/icons/filesave.png"), |
835 tr ("&Save File"), _tool_bar); | 842 tr ("&Save File"), _tool_bar); |
836 | 843 |
837 _save_as_action = new QAction (QIcon (":/actions/icons/filesaveas.png"), | 844 _save_as_action = new QAction (QIcon (":/actions/icons/filesaveas.png"), |
838 tr ("Save File &As"), _tool_bar); | 845 tr ("Save File &As"), _tool_bar); |
839 | 846 |
840 _print_action = new QAction ( QIcon (":/actions/icons/fileprint.png"), | 847 _print_action = new QAction ( QIcon (":/actions/icons/fileprint.png"), |
841 tr ("Print"), _tool_bar); | 848 tr ("Print"), _tool_bar); |
842 | 849 |
843 _undo_action = new QAction (QIcon (":/actions/icons/undo.png"), | 850 _undo_action = new QAction (QIcon (":/actions/icons/undo.png"), |
844 tr ("&Undo"), _tool_bar); | 851 tr ("&Undo"), _tool_bar); |
845 | 852 |
846 _redo_action = new QAction (QIcon (":/actions/icons/redo.png"), | 853 _redo_action = new QAction (QIcon (":/actions/icons/redo.png"), |
847 tr ("&Redo"), _tool_bar); | 854 tr ("&Redo"), _tool_bar); |
848 | 855 |
849 _copy_action = new QAction (QIcon (":/actions/icons/editcopy.png"), | 856 _copy_action = new QAction (QIcon (":/actions/icons/editcopy.png"), |
850 tr ("&Copy"), _tool_bar); | 857 tr ("&Copy"), _tool_bar); |
851 _copy_action->setEnabled (false); | 858 _copy_action->setEnabled (false); |
852 | 859 |
853 _cut_action = new QAction (QIcon (":/actions/icons/editcut.png"), | 860 _cut_action = new QAction (QIcon (":/actions/icons/editcut.png"), |
854 tr ("Cu&t"), _tool_bar); | 861 tr ("Cu&t"), _tool_bar); |
855 _cut_action->setEnabled (false); | 862 _cut_action->setEnabled (false); |
856 | 863 |
857 _paste_action | 864 _paste_action |
858 = new QAction (QIcon (":/actions/icons/editpaste.png"), | 865 = new QAction (QIcon (":/actions/icons/editpaste.png"), |
859 tr ("Paste"), _tool_bar); | 866 tr ("Paste"), _tool_bar); |
860 | 867 |
861 _next_bookmark_action = new QAction (tr ("&Next Bookmark"), _tool_bar); | 868 _next_bookmark_action = new QAction (tr ("&Next Bookmark"), _tool_bar); |
862 | 869 |
863 _previous_bookmark_action = new QAction (tr ("Pre&vious Bookmark"), _tool_bar); | 870 _previous_bookmark_action = new QAction (tr ("Pre&vious Bookmark"), |
871 _tool_bar); | |
864 | 872 |
865 _toggle_bookmark_action = new QAction (tr ("Toggle &Bookmark"), _tool_bar); | 873 _toggle_bookmark_action = new QAction (tr ("Toggle &Bookmark"), _tool_bar); |
866 | 874 |
867 _remove_bookmark_action | 875 _remove_bookmark_action |
868 = new QAction (tr ("&Remove All Bookmarks"), _tool_bar); | 876 = new QAction (tr ("&Remove All Bookmarks"), _tool_bar); |
884 = new QAction (tr ("&Comment"), _tool_bar); | 892 = new QAction (tr ("&Comment"), _tool_bar); |
885 _uncomment_selection_action | 893 _uncomment_selection_action |
886 = new QAction (tr ("&Uncomment"), _tool_bar); | 894 = new QAction (tr ("&Uncomment"), _tool_bar); |
887 | 895 |
888 _find_action = new QAction (QIcon (":/actions/icons/search.png"), | 896 _find_action = new QAction (QIcon (":/actions/icons/search.png"), |
889 tr ("&Find and Replace"), _tool_bar); | 897 tr ("&Find and Replace"), _tool_bar); |
890 | 898 |
891 _run_action = new QAction (QIcon (":/actions/icons/artsbuilderexecute.png"), | 899 _run_action = new QAction (QIcon (":/actions/icons/artsbuilderexecute.png"), |
892 tr ("Save File And Run"), _tool_bar); | 900 tr ("Save File And Run"), _tool_bar); |
893 | 901 |
894 _goto_line_action = new QAction (tr ("Go&to Line"), _tool_bar); | 902 _goto_line_action = new QAction (tr ("Go&to Line"), _tool_bar); |
895 | 903 |
896 // the mru-list and an empty array of actions | 904 // the mru-list and an empty array of actions |
897 QSettings *settings = resource_manager::get_settings (); | 905 QSettings *settings = resource_manager::get_settings (); |
898 // FIXME -- what should happen if settings is 0? | 906 // FIXME: what should happen if settings is 0? |
899 _mru_files = settings->value ("editor/mru_file_list").toStringList (); | 907 _mru_files = settings->value ("editor/mru_file_list").toStringList (); |
900 for (int i = 0; i < MaxMRUFiles; ++i) | 908 for (int i = 0; i < MaxMRUFiles; ++i) |
901 { | 909 { |
902 _mru_file_actions[i] = new QAction (this); | 910 _mru_file_actions[i] = new QAction (this); |
903 _mru_file_actions[i]->setVisible (false); | 911 _mru_file_actions[i]->setVisible (false); |
904 } | 912 } |
905 | 913 |
906 // some actions are disabled from the beginning | 914 // some actions are disabled from the beginning |
907 _copy_action->setEnabled (false); | 915 _copy_action->setEnabled (false); |
908 _cut_action->setEnabled (false); | 916 _cut_action->setEnabled (false); |
961 fileMenu->addAction (_save_action); | 969 fileMenu->addAction (_save_action); |
962 fileMenu->addAction (_save_as_action); | 970 fileMenu->addAction (_save_as_action); |
963 | 971 |
964 fileMenu->addSeparator (); | 972 fileMenu->addSeparator (); |
965 _close_action = | 973 _close_action = |
966 fileMenu->addAction (QIcon::fromTheme("window-close", | 974 fileMenu->addAction (QIcon::fromTheme("window-close", |
967 QIcon (":/actions/icons/fileclose.png")), | 975 QIcon (":/actions/icons/fileclose.png")), |
968 tr ("&Close"), this, SLOT (request_close_file (bool))); | 976 tr ("&Close"), this, SLOT (request_close_file (bool))); |
969 _close_all_action = | 977 _close_all_action = |
970 fileMenu->addAction (QIcon::fromTheme("window-close", | 978 fileMenu->addAction (QIcon::fromTheme("window-close", |
971 QIcon (":/actions/icons/fileclose.png")), | 979 QIcon (":/actions/icons/fileclose.png")), |
972 tr ("Close All"), | 980 tr ("Close All"), |
973 this, SLOT (request_close_all_files (bool))); | 981 this, SLOT (request_close_all_files (bool))); |
974 _close_others_action = | 982 _close_others_action = |
975 fileMenu->addAction (QIcon::fromTheme("window-close", | 983 fileMenu->addAction (QIcon::fromTheme("window-close", |
976 QIcon (":/actions/icons/fileclose.png")), | 984 QIcon (":/actions/icons/fileclose.png")), |
977 tr ("Close Other Files"), | 985 tr ("Close Other Files"), |
978 this, SLOT (request_close_other_files (bool))); | 986 this, SLOT (request_close_other_files (bool))); |
979 | 987 |
980 fileMenu->addSeparator (); | 988 fileMenu->addSeparator (); |
981 fileMenu->addAction (_print_action); | 989 fileMenu->addAction (_print_action); |
982 | 990 |
983 _menu_bar->addMenu (fileMenu); | 991 _menu_bar->addMenu (fileMenu); |
1002 editMenu->addAction (_remove_bookmark_action); | 1010 editMenu->addAction (_remove_bookmark_action); |
1003 editMenu->addSeparator (); | 1011 editMenu->addSeparator (); |
1004 editMenu->addAction (_goto_line_action); | 1012 editMenu->addAction (_goto_line_action); |
1005 editMenu->addSeparator (); | 1013 editMenu->addSeparator (); |
1006 _preferences_action = | 1014 _preferences_action = |
1007 editMenu->addAction (QIcon (":/actions/icons/configure.png"), | 1015 editMenu->addAction (QIcon (":/actions/icons/configure.png"), |
1008 tr ("&Preferences"), this, SLOT (request_preferences (bool))); | 1016 tr ("&Preferences"), |
1017 this, SLOT (request_preferences (bool))); | |
1009 _styles_preferences_action = | 1018 _styles_preferences_action = |
1010 editMenu->addAction (QIcon (":/actions/icons/configure.png"), | 1019 editMenu->addAction (QIcon (":/actions/icons/configure.png"), |
1011 tr ("&Styles Preferences"), this, SLOT (request_styles_preferences (bool))); | 1020 tr ("&Styles Preferences"), |
1021 this, SLOT (request_styles_preferences (bool))); | |
1012 _menu_bar->addMenu (editMenu); | 1022 _menu_bar->addMenu (editMenu); |
1013 | 1023 |
1014 _debug_menu = new QMenu (tr ("&Debug"), _menu_bar); | 1024 _debug_menu = new QMenu (tr ("&Debug"), _menu_bar); |
1015 _debug_menu->addAction (toggle_breakpoint_action); | 1025 _debug_menu->addAction (toggle_breakpoint_action); |
1016 _debug_menu->addAction (next_breakpoint_action); | 1026 _debug_menu->addAction (next_breakpoint_action); |
1022 | 1032 |
1023 QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar); | 1033 QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar); |
1024 _run_menu->addAction (_run_action); | 1034 _run_menu->addAction (_run_action); |
1025 _context_run_action = | 1035 _context_run_action = |
1026 _run_menu->addAction (QIcon (), tr ("Run &Selection"), | 1036 _run_menu->addAction (QIcon (), tr ("Run &Selection"), |
1027 this, SLOT (request_context_run (bool))); | 1037 this, SLOT (request_context_run (bool))); |
1028 _context_run_action->setEnabled (false); | 1038 _context_run_action->setEnabled (false); |
1029 _menu_bar->addMenu (_run_menu); | 1039 _menu_bar->addMenu (_run_menu); |
1030 | 1040 |
1031 QMenu *_help_menu = new QMenu (tr ("&Help"), _menu_bar); | 1041 QMenu *_help_menu = new QMenu (tr ("&Help"), _menu_bar); |
1032 _context_help_action = | 1042 _context_help_action = |
1049 editor_widget->setLayout (vbox_layout); | 1059 editor_widget->setLayout (vbox_layout); |
1050 setWidget (editor_widget); | 1060 setWidget (editor_widget); |
1051 | 1061 |
1052 // signals | 1062 // signals |
1053 connect (this, SIGNAL (request_settings_dialog (const QString&)), | 1063 connect (this, SIGNAL (request_settings_dialog (const QString&)), |
1054 main_win (), SLOT (process_settings_dialog_request (const QString&))); | 1064 main_win (), |
1065 SLOT (process_settings_dialog_request (const QString&))); | |
1055 | 1066 |
1056 connect (main_win (), SIGNAL (new_file_signal (const QString&)), | 1067 connect (main_win (), SIGNAL (new_file_signal (const QString&)), |
1057 this, SLOT (request_new_file (const QString&))); | 1068 this, SLOT (request_new_file (const QString&))); |
1058 | 1069 |
1059 connect (main_win (), SIGNAL (open_file_signal (const QString&)), | 1070 connect (main_win (), SIGNAL (open_file_signal (const QString&)), |
1145 | 1156 |
1146 //restore previous session | 1157 //restore previous session |
1147 if (settings->value ("editor/restoreSession", true).toBool ()) | 1158 if (settings->value ("editor/restoreSession", true).toBool ()) |
1148 { | 1159 { |
1149 QStringList sessionFileNames | 1160 QStringList sessionFileNames |
1150 = settings->value ("editor/savedSessionTabs", QStringList ()).toStringList (); | 1161 = settings->value ("editor/savedSessionTabs", |
1162 QStringList ()).toStringList (); | |
1151 | 1163 |
1152 for (int n = 0; n < sessionFileNames.count (); ++n) | 1164 for (int n = 0; n < sessionFileNames.count (); ++n) |
1153 request_open_file (sessionFileNames.at (n)); | 1165 request_open_file (sessionFileNames.at (n)); |
1154 } | 1166 } |
1155 | 1167 |
1156 check_actions (); | 1168 check_actions (); |
1157 } | 1169 } |
1158 | 1170 |
1159 void | 1171 void |
1160 file_editor::add_file_editor_tab (file_editor_tab *f, const QString& fn) | 1172 file_editor::add_file_editor_tab (file_editor_tab *f, const QString& fn) |
1161 { | 1173 { |
1181 connect (f, SIGNAL (mru_add_file (const QString&)), | 1193 connect (f, SIGNAL (mru_add_file (const QString&)), |
1182 this, SLOT (handle_mru_add_file (const QString&))); | 1194 this, SLOT (handle_mru_add_file (const QString&))); |
1183 | 1195 |
1184 connect (f, SIGNAL (run_file_signal (const QFileInfo&)), | 1196 connect (f, SIGNAL (run_file_signal (const QFileInfo&)), |
1185 main_win (), SLOT (run_file_in_terminal (const QFileInfo&))); | 1197 main_win (), SLOT (run_file_in_terminal (const QFileInfo&))); |
1186 | 1198 |
1187 connect (f, SIGNAL (execute_command_in_terminal_signal (const QString&)), | 1199 connect (f, SIGNAL (execute_command_in_terminal_signal (const QString&)), |
1188 main_win (), SLOT (execute_command_in_terminal (const QString&))); | 1200 main_win (), SLOT (execute_command_in_terminal (const QString&))); |
1189 | 1201 |
1190 // Signals from the file_editor non-trivial operations | 1202 // Signals from the file_editor non-trivial operations |
1191 connect (this, SIGNAL (fetab_settings_changed (const QSettings *)), | 1203 connect (this, SIGNAL (fetab_settings_changed (const QSettings *)), |
1298 void | 1310 void |
1299 file_editor::copyClipboard () | 1311 file_editor::copyClipboard () |
1300 { | 1312 { |
1301 QWidget * foc_w = focusWidget (); | 1313 QWidget * foc_w = focusWidget (); |
1302 | 1314 |
1303 if(foc_w && foc_w->inherits ("octave_qscintilla")) | 1315 if (foc_w && foc_w->inherits ("octave_qscintilla")) |
1304 { | 1316 { |
1305 request_copy (); | 1317 request_copy (); |
1306 } | 1318 } |
1307 } | 1319 } |
1308 void | 1320 void |
1309 file_editor::pasteClipboard () | 1321 file_editor::pasteClipboard () |
1310 { | 1322 { |
1311 QWidget * foc_w = focusWidget (); | 1323 QWidget * foc_w = focusWidget (); |
1312 | 1324 |
1313 if(foc_w && foc_w->inherits ("octave_qscintilla")) | 1325 if (foc_w && foc_w->inherits ("octave_qscintilla")) |
1314 { | 1326 { |
1315 request_paste (); | 1327 request_paste (); |
1316 } | 1328 } |
1317 } | 1329 } |
1318 | 1330 |
1319 void | 1331 void |
1320 file_editor::set_shortcuts (bool set) | 1332 file_editor::set_shortcuts (bool set) |
1321 { | 1333 { |
1322 if (set) | 1334 if (set) |
1323 { | 1335 { |
1324 _comment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_R); | 1336 _comment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_R); |
1325 _uncomment_selection_action->setShortcut (Qt::SHIFT + Qt::ControlModifier + Qt::Key_R); | 1337 _uncomment_selection_action->setShortcut (Qt::SHIFT |
1338 + Qt::ControlModifier | |
1339 + Qt::Key_R); | |
1326 | 1340 |
1327 _copy_action->setShortcut (QKeySequence::Copy); | 1341 _copy_action->setShortcut (QKeySequence::Copy); |
1328 _cut_action->setShortcut (QKeySequence::Cut); | 1342 _cut_action->setShortcut (QKeySequence::Cut); |
1329 _paste_action->setShortcut (QKeySequence::Paste); | 1343 _paste_action->setShortcut (QKeySequence::Paste); |
1330 _context_help_action->setShortcut (QKeySequence::HelpContents); | 1344 _context_help_action->setShortcut (QKeySequence::HelpContents); |