Mercurial > octave-libgccjit
comparison libgui/src/shortcut-manager.cc @ 18624:a827fc5fe59d gui-release
handle actions from the editors file and edit menu via the shortcut manager
* file-editor.cc (set_shortcuts): set shortcuts via shortcut manager
* shortcut-manager.cc (do_init_data): initialization of new shortcuts
(init): code optimization and index check
author | Torsten <ttl@justmail.de> |
---|---|
date | Fri, 04 Apr 2014 22:59:08 +0200 |
parents | 086093fbdc1a |
children | a811d45b7ca7 |
comparison
equal
deleted
inserted
replaced
18619:f1b91e3137b9 | 18624:a827fc5fe59d |
---|---|
96 init (tr ("Clear Command Window"), "main_edit:clear_command_window", QKeySequence () ); | 96 init (tr ("Clear Command Window"), "main_edit:clear_command_window", QKeySequence () ); |
97 init (tr ("Clear Command History"), "main_edit:clear_history", QKeySequence () ); | 97 init (tr ("Clear Command History"), "main_edit:clear_history", QKeySequence () ); |
98 init (tr ("Clear Workspace"), "main_edit:clear_workspace", QKeySequence () ); | 98 init (tr ("Clear Workspace"), "main_edit:clear_workspace", QKeySequence () ); |
99 | 99 |
100 // actions of the editor | 100 // actions of the editor |
101 init (tr ("Edit Function"), "editor_file:edit_function", QKeySequence (Qt::ControlModifier + Qt::Key_E) ); | |
101 init (tr ("Save File"), "editor_file:save", QKeySequence::Save ); | 102 init (tr ("Save File"), "editor_file:save", QKeySequence::Save ); |
102 init (tr ("Save File As"), "editor_file:save_as", QKeySequence::SaveAs ); | 103 init (tr ("Save File As"), "editor_file:save_as", QKeySequence::SaveAs ); |
104 init (tr ("Close"), "editor_file:close", QKeySequence::Close ); | |
105 init (tr ("Close All"), "editor_file:close_all", QKeySequence () ); | |
106 init (tr ("Close Other"), "editor_file:close_other", QKeySequence () ); | |
107 init (tr ("Print"), "editor_file:print", QKeySequence::Print ); | |
108 | |
109 init (tr ("Undo"), "editor_edit:undo", QKeySequence::Undo ); | |
110 init (tr ("Redo"), "editor_edit:redo", QKeySequence::Redo ); | |
111 init (tr ("Copy"), "editor_edit:copy", QKeySequence::Copy ); | |
112 init (tr ("Cuy"), "editor_edit:cut", QKeySequence::Cut ); | |
113 init (tr ("Paste"), "editor_edit:paste", QKeySequence::Paste ); | |
114 init (tr ("Select All"), "editor_edit:select_all", QKeySequence::SelectAll ); | |
115 init (tr ("Find and Replace"), "editor_edit:find_replace", QKeySequence::Find ); | |
116 init (tr ("Comment Selection"), "editor_edit:comment_selection", QKeySequence (Qt::ControlModifier + Qt::Key_R) ); | |
117 init (tr ("Uncomment Selection"), "editor_edit:uncomment_selection", QKeySequence (Qt::SHIFT + Qt::ControlModifier + Qt::Key_R) ); | |
118 init (tr ("Indent Selection"), "editor_edit:indent_selection", QKeySequence (Qt::ControlModifier + Qt::Key_Tab) ); | |
119 init (tr ("Unindent Selection"), "editor_edit:unindent_selection", QKeySequence (Qt::SHIFT + Qt::ControlModifier + Qt::Key_Tab) ); | |
120 init (tr ("Completion List"), "editor_edit:completion_list", QKeySequence (Qt::ControlModifier + Qt::Key_Space) ); | |
121 init (tr ("Toggle Bookmark"), "editor_edit:toggle_bookmark", QKeySequence (Qt::Key_F7) ); | |
122 init (tr ("Next Bookmark"), "editor_edit:next_bookmark", QKeySequence (Qt::Key_F2) ); | |
123 init (tr ("Previous Bookmark"), "editor_edit:previous_bookmark", QKeySequence (Qt::SHIFT + Qt::Key_F2) ); | |
124 init (tr ("Remove All Bookmark"), "editor_edit:remove_bookmark", QKeySequence () ); | |
125 init (tr ("Goto Line"), "editor_edit:goto_line", QKeySequence (Qt::ControlModifier+ Qt::Key_G) ); | |
126 init (tr ("Preferences"), "editor_edit:preferences", QKeySequence () ); | |
127 init (tr ("Styles Preferences"), "editor_edit:styles_preferences", QKeySequence () ); | |
128 | |
103 } | 129 } |
104 | 130 |
105 void | 131 void |
106 shortcut_manager::init (QString description, QString key, QKeySequence def_sc) | 132 shortcut_manager::init (QString description, QString key, QKeySequence def_sc) |
107 { | 133 { |
108 QSettings *settings = resource_manager::get_settings (); | 134 QSettings *settings = resource_manager::get_settings (); |
109 | 135 |
110 settings->beginGroup ("shortcuts"); | 136 QKeySequence actual = QKeySequence (settings->value ("shortcuts/"+key, def_sc).toString ()); |
111 QKeySequence actual = QKeySequence (settings->value (key, def_sc).toString ()); | |
112 settings->endGroup (); | |
113 | 137 |
114 shortcut_t shortcut_info; | 138 shortcut_t shortcut_info; |
115 shortcut_info.description = description; | 139 shortcut_info.description = description; |
116 shortcut_info.settings_key = key; | 140 shortcut_info.settings_key = key; |
117 shortcut_info.actual_sc = actual; | 141 shortcut_info.actual_sc = actual; |
215 shortcut_manager::do_set_shortcut (QAction* action, const QString& key) | 239 shortcut_manager::do_set_shortcut (QAction* action, const QString& key) |
216 { | 240 { |
217 QSettings *settings = resource_manager::get_settings (); | 241 QSettings *settings = resource_manager::get_settings (); |
218 | 242 |
219 int index = _action_hash[key] - 1; | 243 int index = _action_hash[key] - 1; |
220 | 244 if (index > -1 && index < _sc.count ()) |
221 action->setShortcut ( | 245 action->setShortcut ( |
222 settings->value ("shortcuts/" + key, _sc.at (index).default_sc).toString ()); | 246 settings->value ("shortcuts/" + key, _sc.at (index).default_sc).toString ()); |
247 else | |
248 qDebug () << "Key: " << key << " not found in _action_hash"; | |
223 } | 249 } |
224 | 250 |
225 void | 251 void |
226 shortcut_manager::handle_double_clicked (QTreeWidgetItem* item, int) | 252 shortcut_manager::handle_double_clicked (QTreeWidgetItem* item, int) |
227 { | 253 { |