comparison libgui/src/main-window.cc @ 16648:b04413e5a811

improve handling of interrupts, copy and paste shortcuts * QTerminal.h (QTerminal::report_status_message): New signal. (QTerminal::QTerminal): Set shortcuts for copy and paste actions. Add copy and paste actions to QTerminal widget. Connect settings_changed, report_status_message, copyClipboard_signal, and pasteClipboard_signal. * QWinTerminalImpl.cpp (QWinTerminalImpl::copyClipboard): If selection is set, copy it and report status message. Otherwise, interrupt. * TerminalView.cpp (TerminalView::copyClipboard): Likewise. * main-window.cc (main_menu::construct_file_menu): Don't set shortcut for open action. (main_window::construct_edit_menu): Delete unimplemented cut, select all, and delete actions. Connect copy and paste actions to signals. (main_window::copyClipboard_signal, main_window::pasteClipboard_signal): New signals. (main_window::copyClipboard, main_window::pasteClipboard): New slots. (main_window::_cut_action): Delete member variable. * octave-qt-link.cc (octave_qt_link::do_pre_input_event): Disable input processing by the windows console. (octave_qt_link::do_post_input_event): Enable input processing by the windows console. * terminal-dock-widget.h, terminal-dock-widget.cc: Delete notice_settings, copyClipboard, and pasteClipboard signals, slots, and connections. (terminal_dock_widget::terminal_dock_widget): Don't connect visibilityChanged signal.
author John W. Eaton <jwe@octave.org>
date Mon, 13 May 2013 07:26:37 -0400
parents e3a0ca9c8836
children de1f8e4b6b9b
comparison
equal deleted inserted replaced
16647:d446e99f89f7 16648:b04413e5a811
23 23
24 #ifdef HAVE_CONFIG_H 24 #ifdef HAVE_CONFIG_H
25 #include <config.h> 25 #include <config.h>
26 #endif 26 #endif
27 27
28 #include <QKeySequence>
28 #include <QApplication> 29 #include <QApplication>
29 #include <QLabel> 30 #include <QLabel>
30 #include <QMenuBar> 31 #include <QMenuBar>
31 #include <QMenu> 32 #include <QMenu>
32 #include <QAction> 33 #include <QAction>
628 editor_window->connect_visibility_changed (); 629 editor_window->connect_visibility_changed ();
629 #endif 630 #endif
630 workspace_window->connect_visibility_changed (); 631 workspace_window->connect_visibility_changed ();
631 } 632 }
632 633
634 void
635 main_window::copyClipboard (void)
636 {
637 emit copyClipboard_signal ();
638 }
639
640 void
641 main_window::pasteClipboard (void)
642 {
643 emit pasteClipboard_signal ();
644 }
645
633 // Connect the signals emitted when the Octave thread wants to create 646 // Connect the signals emitted when the Octave thread wants to create
634 // a dialog box of some sort. Perhaps a better place for this would be 647 // a dialog box of some sort. Perhaps a better place for this would be
635 // as part of the QUIWidgetCreator class. However, mainWindow currently 648 // as part of the QUIWidgetCreator class. However, mainWindow currently
636 // is not a global variable and not accessible for connecting. 649 // is not a global variable and not accessible for connecting.
637 650
944 construct_new_menu (file_menu); 957 construct_new_menu (file_menu);
945 958
946 _open_action 959 _open_action
947 = file_menu->addAction (QIcon (":/actions/icons/fileopen.png"), 960 = file_menu->addAction (QIcon (":/actions/icons/fileopen.png"),
948 tr ("Open...")); 961 tr ("Open..."));
949 _open_action->setShortcut (QKeySequence::Open);
950 _open_action->setShortcutContext (Qt::ApplicationShortcut);
951 962
952 #ifdef HAVE_QSCINTILLA 963 #ifdef HAVE_QSCINTILLA
953 file_menu->addMenu (editor_window->get_mru_menu ()); 964 file_menu->addMenu (editor_window->get_mru_menu ());
954 #endif 965 #endif
955 966
1024 = edit_menu->addAction (QIcon (":/actions/icons/undo.png"), tr ("Undo")); 1035 = edit_menu->addAction (QIcon (":/actions/icons/undo.png"), tr ("Undo"));
1025 _undo_action->setShortcut (QKeySequence::Undo); 1036 _undo_action->setShortcut (QKeySequence::Undo);
1026 1037
1027 edit_menu->addSeparator (); 1038 edit_menu->addSeparator ();
1028 1039
1029 _cut_action
1030 = edit_menu->addAction (QIcon (":/actions/icons/editcut.png"), tr ("Cut"));
1031 _cut_action->setShortcut (ctrl_shift + Qt::Key_X);
1032
1033 _copy_action 1040 _copy_action
1034 = edit_menu->addAction (QIcon (":/actions/icons/editcopy.png"), tr ("Copy")); 1041 = edit_menu->addAction (QIcon (":/actions/icons/editcopy.png"),
1042 tr ("Copy"));
1035 _copy_action->setShortcut (ctrl_shift + Qt::Key_C); 1043 _copy_action->setShortcut (ctrl_shift + Qt::Key_C);
1036 1044
1037 _paste_action 1045 _paste_action
1038 = edit_menu->addAction (QIcon (":/actions/icons/editpaste.png"), tr ("Paste")); 1046 = edit_menu->addAction (QIcon (":/actions/icons/editpaste.png"),
1047 tr ("Paste"));
1039 _paste_action->setShortcut (ctrl_shift + Qt::Key_V); 1048 _paste_action->setShortcut (ctrl_shift + Qt::Key_V);
1040
1041 QAction *select_all_action
1042 = edit_menu->addAction (tr ("Select All"));
1043 select_all_action->setEnabled (false); // TODO: Make this work.
1044
1045 QAction *delete_action
1046 = edit_menu->addAction (tr ("Delete"));
1047 delete_action->setShortcut (Qt::Key_Delete);
1048 delete_action->setEnabled (false); // TODO: Make this work.
1049 1049
1050 edit_menu->addSeparator (); 1050 edit_menu->addSeparator ();
1051 1051
1052 QAction *find_files_action 1052 QAction *find_files_action
1053 = edit_menu->addAction (tr ("Find Files...")); 1053 = edit_menu->addAction (tr ("Find Files..."));
1063 1063
1064 QAction *clear_workspace_action 1064 QAction *clear_workspace_action
1065 = edit_menu->addAction (tr ("Clear Workspace")); 1065 = edit_menu->addAction (tr ("Clear Workspace"));
1066 1066
1067 connect (_copy_action, SIGNAL (triggered()), 1067 connect (_copy_action, SIGNAL (triggered()),
1068 command_window, SLOT (copyClipboard ())); 1068 this, SLOT (copyClipboard ()));
1069 1069
1070 connect (_paste_action, SIGNAL (triggered()), 1070 connect (_paste_action, SIGNAL (triggered()),
1071 command_window, SLOT (pasteClipboard ())); 1071 this, SLOT (pasteClipboard ()));
1072 1072
1073 connect (find_files_action, SIGNAL (triggered()), 1073 connect (find_files_action, SIGNAL (triggered()),
1074 this, SLOT (find_files ())); 1074 this, SLOT (find_files ()));
1075 1075
1076 connect (clear_command_window_action, SIGNAL (triggered ()), 1076 connect (clear_command_window_action, SIGNAL (triggered ()),
1332 _main_tool_bar->addAction (_new_script_action); 1332 _main_tool_bar->addAction (_new_script_action);
1333 _main_tool_bar->addAction (_open_action); 1333 _main_tool_bar->addAction (_open_action);
1334 1334
1335 _main_tool_bar->addSeparator (); 1335 _main_tool_bar->addSeparator ();
1336 1336
1337 _main_tool_bar->addAction (_cut_action);
1338 _main_tool_bar->addAction (_copy_action); 1337 _main_tool_bar->addAction (_copy_action);
1339 _main_tool_bar->addAction (_paste_action); 1338 _main_tool_bar->addAction (_paste_action);
1340 _main_tool_bar->addAction (_undo_action); 1339 _main_tool_bar->addAction (_undo_action);
1341 1340
1342 _main_tool_bar->addSeparator (); 1341 _main_tool_bar->addSeparator ();