Mercurial > hg > octave-lojdl
changeset 14812:9d9eb9bac65e gui
Improved menu structure of file, edit and window menu. Removed ambiguous shortcuts, improved focus handling for operating the GUI with the keyboard. Added new shortcuts to focus subwindows directly.
* files-dockwidget: Set focus proxy to the current directory line edit.
* history-dockwidget: Set focus proxy to the inline search bar.
* file-editor: Removed and improved shortcuts.
* main-window: Added new slots for not only showing/hiding subwindows, but also for focussing them directly with Ctrl+0,1..4. Improved menu structure.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Thu, 28 Jun 2012 11:04:37 +0200 |
parents | a565c560e654 |
children | 2de56de8953a |
files | gui/src/files-dockwidget.cc gui/src/history-dockwidget.cc gui/src/m-editor/file-editor.cc gui/src/main-window.cc gui/src/main-window.h |
diffstat | 5 files changed, 239 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/files-dockwidget.cc +++ b/gui/src/files-dockwidget.cc @@ -97,6 +97,8 @@ connect (this, SIGNAL (visibilityChanged (bool)), this, SLOT (handle_visibility_changed (bool))); + + setFocusProxy (_current_directory); } void
--- a/gui/src/history-dockwidget.cc +++ b/gui/src/history-dockwidget.cc @@ -106,6 +106,8 @@ SLOT (request_history_model_update ())); _update_history_model_timer.start (); + + setFocusProxy (_filter_line_edit); } void
--- a/gui/src/m-editor/file-editor.cc +++ b/gui/src/m-editor/file-editor.cc @@ -274,6 +274,7 @@ bool copy_available = f->copy_available (); _copy_action->setEnabled (copy_available); _cut_action->setEnabled (copy_available); + setFocusProxy (f); } } @@ -329,25 +330,26 @@ _cut_action->setEnabled(false); // short cuts - new_action->setShortcut (QKeySequence::New); - new_action->setShortcutContext (Qt::WindowShortcut); - open_action->setShortcut (QKeySequence::Open); - open_action->setShortcutContext (Qt::WindowShortcut); - save_action->setShortcut (QKeySequence::Save); - save_action->setShortcutContext (Qt::WindowShortcut); - save_as_action->setShortcut (QKeySequence::SaveAs); - save_as_action->setShortcutContext (Qt::WindowShortcut); - undo_action->setShortcut (QKeySequence::Undo); - undo_action->setShortcutContext (Qt::WindowShortcut); - redo_action->setShortcut (QKeySequence::Redo); - redo_action->setShortcutContext (Qt::WindowShortcut); - _copy_action->setShortcut (QKeySequence::Copy); - _copy_action->setShortcutContext (Qt::WindowShortcut); - _cut_action->setShortcut (QKeySequence::Cut); - _cut_action->setShortcutContext (Qt::WindowShortcut); - paste_action->setShortcut (QKeySequence::Paste); - paste_action->setShortcutContext (Qt::WindowShortcut); - run_action->setShortcut (Qt::SHIFT + Qt::Key_R); + // TODO: These shortcuts are ambiguous and lead to bugs. +// new_action->setShortcut (QKeySequence::New); +// new_action->setShortcutContext (Qt::WindowShortcut); +// open_action->setShortcut (QKeySequence::Open); +// open_action->setShortcutContext (Qt::WindowShortcut); +// save_action->setShortcut (QKeySequence::Save); +// save_action->setShortcutContext (Qt::WindowShortcut); +// save_as_action->setShortcut (QKeySequence::SaveAs); +// save_as_action->setShortcutContext (Qt::WindowShortcut); +// undo_action->setShortcut (QKeySequence::Undo); +// undo_action->setShortcutContext (Qt::WindowShortcut); +// redo_action->setShortcut (QKeySequence::Redo); +// redo_action->setShortcutContext (Qt::WindowShortcut); +// _copy_action->setShortcut (QKeySequence::Copy); +// _copy_action->setShortcutContext (Qt::WindowShortcut); +// _cut_action->setShortcut (QKeySequence::Cut); +// _cut_action->setShortcutContext (Qt::WindowShortcut); +// paste_action->setShortcut (QKeySequence::Paste); +// paste_action->setShortcutContext (Qt::WindowShortcut); + run_action->setShortcut (Qt::ControlModifier+ Qt::Key_R); run_action->setShortcutContext (Qt::WindowShortcut); next_bookmark_action->setShortcut (Qt::Key_F2); next_bookmark_action->setShortcutContext (Qt::WindowShortcut); @@ -355,9 +357,9 @@ previous_bookmark_action->setShortcutContext (Qt::WindowShortcut); toggle_bookmark_action->setShortcut (Qt::Key_F7); toggle_bookmark_action->setShortcutContext (Qt::WindowShortcut); - comment_selection_action->setShortcut (Qt::CTRL + Qt::Key_R); + comment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_7); comment_selection_action->setShortcutContext (Qt::WindowShortcut); - uncomment_selection_action->setShortcut (Qt::CTRL + Qt::Key_T); + uncomment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_8); uncomment_selection_action->setShortcutContext(Qt::WindowShortcut); // toolbar
--- a/gui/src/main-window.cc +++ b/gui/src/main-window.cc @@ -208,6 +208,71 @@ } void +main_window::focus_command_window () +{ + if (!_terminal_dock_widget->isVisible ()) + { + _terminal_dock_widget->setVisible (true); + } + + _terminal->setFocus (); + _terminal->activateWindow (); + _terminal->raise (); +} + +void +main_window::focus_command_history () +{ + if (!_history_dock_widget->isVisible ()) + { + _history_dock_widget->setVisible (true); + } + + _history_dock_widget->setFocus (); + _history_dock_widget->activateWindow (); + _history_dock_widget->raise (); +} + +void +main_window::focus_current_directory () +{ + if (!_files_dock_widget->isVisible ()) + { + _files_dock_widget->setVisible (true); + } + + _files_dock_widget->setFocus (); + _files_dock_widget->activateWindow (); + _files_dock_widget->raise (); +} + +void +main_window::focus_workspace () +{ + if (!_workspace_view->isVisible ()) + { + _workspace_view->setVisible (true); + } + + _workspace_view->setFocus (); + _workspace_view->activateWindow (); + _workspace_view->raise (); +} + +void +main_window::focus_editor () +{ + if (!_file_editor->isVisible ()) + { + _file_editor->setVisible (true); + } + + _file_editor->setFocus (); + _file_editor->activateWindow (); + _file_editor->raise (); +} + +void main_window::handle_entered_debug_mode () { setWindowTitle ("Octave (Debugging)"); @@ -363,6 +428,7 @@ // Octave Terminal subwindow. _terminal = new QTerminal (this); _terminal->setObjectName ("OctaveTerminal"); + _terminal->setFocusPolicy (Qt::StrongFocus); _terminal_dock_widget = new terminal_dock_widget (_terminal, this); QWidget *dummyWidget = new QWidget (); @@ -375,21 +441,79 @@ _file_editor = new file_editor (_terminal, this); QMenu *file_menu = menuBar ()->addMenu (tr ("&File")); - QAction *new_file_action - = file_menu->addAction (QIcon(":/actions/icons/filenew.png"), tr ("New File")); + + QMenu *new_menu = file_menu->addMenu(tr ("New")); + + QAction *new_script_action + = new_menu->addAction (QIcon(":/actions/icons/filenew.png"), tr ("Script")); + new_script_action->setShortcut (Qt::ControlModifier + Qt::Key_N); + + QAction *new_function_action = new_menu->addAction (tr ("Function")); + new_function_action->setEnabled (false); // TODO: Make this work. + QAction *new_class_action = new_menu->addAction (tr ("Class")); + new_class_action->setEnabled (false); // TODO: Make this work. + QAction *new_enumeration_action = new_menu->addAction (tr ("Enumeration")); + new_enumeration_action->setEnabled (false); // TODO: Make this work. + QAction *new_figure_action = new_menu->addAction (tr ("Figure")); + new_figure_action->setEnabled (false); // TODO: Make this work. + QAction *new_variable_action = new_menu->addAction (tr ("Variable")); + new_variable_action->setEnabled (false); // TODO: Make this work. + QAction *new_model_action = new_menu->addAction (tr ("Model")); + new_model_action->setEnabled (false); // TODO: Make this work. + QAction *new_gui_action = new_menu->addAction (tr ("GUI")); + new_gui_action->setEnabled (false); // TODO: Make this work. + + QAction *open_action + = file_menu->addAction (QIcon(":/actions/icons/fileopen.png"), tr ("Open...")); + open_action->setShortcut (Qt::ControlModifier + Qt::Key_O); - QAction *open_file_action - = file_menu->addAction (QIcon(":/actions/icons/fileopen.png"), tr ("Open File")); + QAction *close_command_window_action + = file_menu->addAction (tr ("Close Command Window")); + close_command_window_action->setShortcut (Qt::ControlModifier + Qt::Key_W); + close_command_window_action->setEnabled (false); // TODO: Make this work. + + file_menu->addSeparator (); + QAction *import_data_action + = file_menu->addAction (tr ("Import Data...")); + import_data_action->setEnabled (false); // TODO: Make this work. + + QAction *save_workspace_action + = file_menu->addAction (tr ("Save Workspace...")); + save_workspace_action->setShortcut (Qt::ControlModifier + Qt::Key_S); + file_menu->addSeparator (); - QAction *settings_action - = file_menu->addAction (QIcon(":/actions/icons/configure.png"), tr ("Settings")); + QAction *preferences_action + = file_menu->addAction (QIcon(":/actions/icons/configure.png"), tr ("Preferences...")); + file_menu->addSeparator (); + QAction *page_setup_action + = file_menu->addAction (tr ("Page Setup...")); + page_setup_action->setEnabled (false); // TODO: Make this work. + QAction *print_action + = file_menu->addAction (tr ("Print")); + print_action->setShortcut (Qt::ControlModifier + Qt::Key_P); + print_action->setEnabled (false); // TODO: Make this work. + QAction *print_selection_action + = file_menu->addAction (tr ("Print Selection...")); + print_selection_action->setEnabled (false); // TODO: Make this work. + file_menu->addSeparator (); QAction *exit_action = file_menu->addAction (tr ("Exit")); + exit_action->setShortcut (Qt::ControlModifier + Qt::Key_Q); + QMenu *edit_menu = menuBar ()->addMenu (tr ("&Edit")); + QAction *undo_action + = edit_menu->addAction (QIcon(":/actions/icons/undo.png"), tr ("Undo")); + undo_action->setShortcut (QKeySequence::Undo); + + QAction *redo_action + = edit_menu->addAction (QIcon(":/actions/icons/redo.png"), tr ("Redo")); + redo_action->setShortcut (QKeySequence::Redo); + edit_menu->addSeparator (); + QAction *cut_action = edit_menu->addAction (QIcon(":/actions/icons/editcut.png"), tr ("Cut")); - cut_action->setShortcut (QKeySequence::Cut); + cut_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_X); QAction *copy_action = edit_menu->addAction (QIcon(":/actions/icons/editcopy.png"), tr ("Copy")); @@ -399,13 +523,37 @@ = edit_menu->addAction (QIcon(":/actions/icons/editpaste.png"), tr ("Paste")); paste_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_V); - QAction *undo_action - = edit_menu->addAction (QIcon(":/actions/icons/undo.png"), tr ("Undo")); - undo_action->setShortcut (QKeySequence::Undo); + QAction *paste_to_workspace_action + = edit_menu->addAction (tr ("Paste To Workspace...")); + paste_to_workspace_action->setEnabled (false); // TODO: Make this work. + edit_menu->addSeparator (); + + QAction *select_all_action + = edit_menu->addAction (tr ("Select All")); + select_all_action->setEnabled (false); // TODO: Make this work. + QAction *delete_action + = edit_menu->addAction (tr ("Delete")); + delete_action->setShortcut (Qt::Key_Delete); + delete_action->setEnabled (false); // TODO: Make this work. + edit_menu->addSeparator (); - QAction *redo_action - = edit_menu->addAction (QIcon(":/actions/icons/redo.png"), tr ("Redo")); - redo_action->setShortcut (QKeySequence::Redo); + QAction *find_action + = edit_menu->addAction (tr ("Find...")); + find_action->setEnabled (false); // TODO: Make this work. + QAction *find_files_action + = edit_menu->addAction (tr ("Find Files...")); + find_files_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_F); + find_files_action->setEnabled (false); // TODO: Make this work. + edit_menu->addSeparator (); + + QAction *clear_command_window_action + = edit_menu->addAction (tr ("Clear Command Window")); + clear_command_window_action->setEnabled (false); // TODO: Make this work. + QAction *clear_command_history + = edit_menu->addAction(tr ("Clear Command History")); + clear_command_history->setEnabled (false); // TODO: Make this work. + QAction * clear_workspace_action + = edit_menu->addAction (tr ("Clear Workspace")); _debug_menu = menuBar ()->addMenu (tr ("De&bug")); @@ -440,23 +588,39 @@ QMenu * desktop_menu = menuBar ()->addMenu (tr ("&Desktop")); QAction * load_workspace_action = desktop_menu->addAction (tr ("Load workspace")); - QAction * save_workspace_action = desktop_menu->addAction (tr ("Save workspace")); - QAction * clear_workspace_action = desktop_menu->addAction (tr ("Clear workspace")); + // Window menu QMenu * window_menu = menuBar ()->addMenu (tr ("&Window")); - QAction * show_command_window_action = window_menu->addAction (tr ("Command Window")); - show_command_window_action->setCheckable (true); - QAction * show_workspace_action = window_menu->addAction (tr ("Workspace")); - show_workspace_action->setCheckable (true); - QAction * show_history_action = window_menu->addAction (tr ("Command History")); - show_history_action->setCheckable (true); - QAction * show_file_browser_action = window_menu->addAction (tr ("Current Directory")); - show_file_browser_action->setCheckable (true); - QAction * show_editor_action = window_menu->addAction (tr ("Editor")); - show_editor_action->setCheckable (true); + QAction * show_command_window_action = window_menu->addAction (tr ("Show Command Window")); + show_command_window_action->setCheckable (true); + show_command_window_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_0); + QAction * show_history_action = window_menu->addAction (tr ("Show Command History")); + show_history_action->setCheckable (true); + show_history_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_1); + QAction * show_file_browser_action = window_menu->addAction (tr ("Show Current Directory")); + show_file_browser_action->setCheckable (true); + show_file_browser_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_2); + QAction * show_workspace_action = window_menu->addAction (tr ("Show Workspace")); + show_workspace_action->setCheckable (true); + show_workspace_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_3); + QAction * show_editor_action = window_menu->addAction (tr ("Show Editor")); + show_editor_action->setCheckable (true); + show_editor_action->setShortcut (Qt::ControlModifier + Qt::ShiftModifier + Qt::Key_4); + window_menu->addSeparator (); + QAction * command_window_action = window_menu->addAction (tr ("Command Window")); + command_window_action->setShortcut (Qt::ControlModifier + Qt::Key_0); + QAction * history_action = window_menu->addAction (tr ("Command History")); + history_action->setShortcut (Qt::ControlModifier + Qt::Key_1); + QAction * file_browser_action = window_menu->addAction (tr ("Current Directory")); + file_browser_action->setShortcut (Qt::ControlModifier + Qt::Key_2); + QAction * workspace_action = window_menu->addAction (tr ("Workspace")); + workspace_action->setShortcut (Qt::ControlModifier + Qt::Key_3); + QAction * editor_action = window_menu->addAction (tr ("Editor")); + editor_action->setShortcut (Qt::ControlModifier + Qt::Key_4); window_menu->addSeparator (); QAction * reset_windows_action = window_menu->addAction (tr ("Reset Windows")); + reset_windows_action->setEnabled (false); // TODO: Make this work. // Help menu QMenu * help_menu = menuBar ()->addMenu (tr ("&Help")); @@ -468,8 +632,8 @@ // Toolbars QToolBar *main_tool_bar = addToolBar ("Main"); - main_tool_bar->addAction (new_file_action); - main_tool_bar->addAction (open_file_action); + main_tool_bar->addAction (new_script_action); + main_tool_bar->addAction (open_action); main_tool_bar->addSeparator (); main_tool_bar->addAction (cut_action); main_tool_bar->addAction (copy_action); @@ -484,13 +648,13 @@ connect (qApp, SIGNAL (aboutToQuit ()), this, SLOT (prepare_for_quit ())); - connect (settings_action, SIGNAL (triggered ()), + connect (preferences_action, SIGNAL (triggered ()), this, SLOT (process_settings_dialog_request ())); connect (exit_action, SIGNAL (triggered ()), this, SLOT (close ())); - connect (new_file_action, SIGNAL (triggered ()), + connect (new_script_action, SIGNAL (triggered ()), this, SLOT (new_file ())); - connect (open_file_action, SIGNAL (triggered ()), + connect (open_action, SIGNAL (triggered ()), this, SLOT (open_file ())); connect (report_bug_action, SIGNAL (triggered ()), this, SLOT (open_bug_tracker_page ())); @@ -520,6 +684,18 @@ _file_editor, SLOT (setVisible (bool))); connect (_file_editor, SIGNAL (active_changed (bool)), show_editor_action, SLOT (setChecked (bool))); + + connect (command_window_action, SIGNAL (triggered ()), + this, SLOT (focus_command_window ())); + connect (workspace_action, SIGNAL (triggered ()), + this, SLOT (focus_workspace ())); + connect (history_action, SIGNAL (triggered ()), + this, SLOT (focus_command_history ())); + connect (file_browser_action, SIGNAL (triggered ()), + this, SLOT (focus_current_directory ())); + connect (editor_action, SIGNAL (triggered ()), + this, SLOT (focus_editor ())); + connect (reset_windows_action, SIGNAL (triggered ()), this, SLOT (reset_windows ())); connect (this, SIGNAL (settings_changed ()),
--- a/gui/src/main-window.h +++ b/gui/src/main-window.h @@ -92,6 +92,12 @@ void set_current_working_directory (QString directory); void current_working_directory_up (); + void focus_command_window (); + void focus_command_history (); + void focus_current_directory (); + void focus_workspace (); + void focus_editor (); + void handle_entered_debug_mode (); void handle_quit_debug_mode (); void debug_continue ();