annotate libgui/src/shortcut-manager.cc @ 31639:ca7d58406f82

eliminate unnecessary uses of octave_qobject in GUI classes * BaseControl.cc, BaseControl.h, ButtonControl.cc, ButtonControl.h, ButtonGroup.cc, ButtonGroup.h, Canvas.cc, Canvas.h, CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc, Figure.h, GLCanvas.cc, GLCanvas.h, ListBoxControl.cc, ListBoxControl.h, Menu.cc, Menu.h, Object.cc, Object.h, Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h, RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc, SliderControl.h, Table.cc, Table.h, TextControl.cc, TextControl.h, ToggleButtonControl.cc, ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, ToolBarButton.h, annotation-dialog.cc, annotation-dialog.h, qt-graphics-toolkit.cc, qt-graphics-toolkit.h, command-widget.h, community-news.cc, community-news.h, documentation-bookmarks.cc, documentation-bookmarks.h, documentation.cc, external-editor-interface.cc, external-editor-interface.h, find-files-dialog.cc, find-files-dialog.h, graphics-init.cc, graphics-init.h, interpreter-qobject.cc, file-editor.cc, find-dialog.cc, find-dialog.h, main-window.cc, main-window.h, news-reader.cc, news-reader.h, octave-qobject.cc, release-notes.cc, resource-manager.cc, set-path-dialog.cc, set-path-dialog.h, shortcut-manager.cc, shortcut-manager.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc: Don't store references to octave_qobject in GUI classes where it is no longer needed. Eliminate unnecessary octave_qobject constructor arguments. Change all uses.
author John W. Eaton <jwe@octave.org>
date Sun, 04 Dec 2022 22:57:02 -0500
parents ad014fc78bd6
children 431f80aba37a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30432
diff changeset
3 // Copyright (C) 2014-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21568
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
27 # include "config.h"
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
28 #endif
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
29
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27330
diff changeset
30 #include <QAction>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27330
diff changeset
31 #include <QApplication>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27330
diff changeset
32 #include <QCheckBox>
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
33 #include <QDebug>
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
34 #include <QDialogButtonBox>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27330
diff changeset
35 #include <QFileDialog>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27330
diff changeset
36 #include <QGridLayout>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27330
diff changeset
37 #include <QHeaderView>
22250
2fd4f1a3f4a8 allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents: 22177
diff changeset
38 #include <QKeySequence>
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
39 #include <QLineEdit>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27330
diff changeset
40 #include <QMessageBox>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27330
diff changeset
41 #include <QPushButton>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27330
diff changeset
42 #include <QVBoxLayout>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27330
diff changeset
43 #include <QtCore>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27330
diff changeset
44
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27330
diff changeset
45 #include "shortcut-manager.h"
27805
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27630
diff changeset
46 #include "gui-preferences-global.h"
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
47 #include "gui-preferences-sc.h"
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
48 #include "gui-settings.h"
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
49 #include "error.h"
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
50
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
51 namespace octave
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
52 {
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
53 // enter_shortcut:
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
54 // class derived from QLineEdit for directly entering key sequences which
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
55
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
56 enter_shortcut::enter_shortcut (QWidget *p) : QLineEdit (p)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
57 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
58 m_direct_shortcut = true; // the shortcut is directly entered
26830
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
59 m_shift_modifier = false; // the shift modifier is not added
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
60 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
61
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
62 // new keyPressEvent
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
63 void enter_shortcut::keyPressEvent (QKeyEvent *e)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
64 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
65 if (! m_direct_shortcut)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
66 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
67 QLineEdit::keyPressEvent (e);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
68 return;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
69 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
70
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
71 if (e->type () == QEvent::KeyPress)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
72 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
73 int key = e->key ();
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
74
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
75 if (key == Qt::Key_unknown || key == 0)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
76 return;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
77
26830
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
78 Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers (); //e->modifiers ();
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
79
26830
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
80 if (m_shift_modifier || (modifiers & Qt::ShiftModifier))
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
81 key += Qt::SHIFT;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
82 if (modifiers & Qt::ControlModifier)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
83 key += Qt::CTRL;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
84 if (modifiers & Qt::AltModifier)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
85 key += Qt::ALT;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
86 if (modifiers & Qt::MetaModifier)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
87 key += Qt::META;
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
88
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
89 setText (QKeySequence (key).toString ());
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
90 }
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
91 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
92
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
93 // slot for checkbox whether the shortcut is directly entered or not
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
94 void enter_shortcut::handle_direct_shortcut (int state)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
95 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
96 if (state)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
97 m_direct_shortcut = true; // the shortcut is directly entered
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
98 else
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
99 m_direct_shortcut = false; // the shortcut has to be written as text
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
100 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
101
26830
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
102 // slot for checkbox whether the shift modifier should be added
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
103 void enter_shortcut::handle_shift_modifier (int state)
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
104 {
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
105 if (state)
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
106 m_shift_modifier = true; // the shortcut is directly entered
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
107 else
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
108 m_shift_modifier = false; // the shortcut has to be written as text
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
109 }
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
110
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
111
31639
ca7d58406f82 eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents: 31619
diff changeset
112 shortcut_manager::shortcut_manager (void)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
113 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
114 setObjectName ("Shortcut_Manager");
19595
be7ac98fab43 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19251
diff changeset
115
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
116 // Mac: don't let Qt interpret CMD key ("Meta" in Qt terminology) as Ctrl
18923
58f1178f49ef Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents: 18922
diff changeset
117 #if defined (Q_OS_MAC)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
118 QCoreApplication::setAttribute (Qt::AA_MacDontSwapCtrlAndMeta, true);
18923
58f1178f49ef Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents: 18922
diff changeset
119 #endif
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
120 }
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
121
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
122 void shortcut_manager::init_data (void)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
123 {
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
124 gui_settings settings;
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
125
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
126 settings.setValue (sc_main_ctrld.key, false); // reset use fo ctrl-d
20987
f99cbd86a0f9 Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
127
27937
8dc5b36f1245 include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27935
diff changeset
128 // actions not related to specific menus or widgets
8dc5b36f1245 include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27935
diff changeset
129
8dc5b36f1245 include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27935
diff changeset
130 // dock widgets
8dc5b36f1245 include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27935
diff changeset
131 init (tr ("Undock/Dock Widget"), sc_dock_widget_dock);
8dc5b36f1245 include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27935
diff changeset
132 init (tr ("Close Widget"), sc_dock_widget_close);
8dc5b36f1245 include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27935
diff changeset
133
8dc5b36f1245 include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27935
diff changeset
134 // actions of the main window
8dc5b36f1245 include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27935
diff changeset
135
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
136 // file
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
137 init (tr ("New File"), sc_main_file_new_file);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
138 init (tr ("New Function"), sc_main_file_new_function);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
139 init (tr ("New Figure"), sc_main_file_new_figure);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
140 init (tr ("Open File"), sc_main_file_open_file);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
141 init (tr ("Load Workspace"), sc_main_file_load_workspace);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
142 init (tr ("Save Workspace As"), sc_main_file_save_workspace);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
143 init (tr ("Exit Octave"), sc_main_file_exit);
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
144
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
145 // edit
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
146 init (tr ("Copy"), sc_main_edit_copy);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
147 init (tr ("Paste"), sc_main_edit_paste);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
148 init (tr ("Undo"), sc_main_edit_undo);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
149 init (tr ("Select All"), sc_main_edit_select_all);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
150 init (tr ("Clear Clipboard"), sc_main_edit_clear_clipboard);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
151 init (tr ("Find in Files"), sc_main_edit_find_in_files);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
152 init (tr ("Clear Command Window"), sc_main_edit_clear_command_window);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
153 init (tr ("Clear Command History"), sc_main_edit_clear_history);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
154 init (tr ("Clear Workspace"), sc_main_edit_clear_workspace);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
155 init (tr ("Set Path"), sc_main_edit_set_path);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
156 init (tr ("Preferences"), sc_main_edit_preferences);
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
157
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
158 // debug
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
159 init (tr ("Step"), sc_main_debug_step_over);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
160 init (tr ("Step Into"), sc_main_debug_step_into);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
161 init (tr ("Step Out"), sc_main_debug_step_out);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
162 init (tr ("Continue"), sc_main_debug_continue);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
163 init (tr ("Quit Debug Mode"), sc_main_debug_quit);
18697
908523bd79b4 use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents: 18685
diff changeset
164
29068
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28499
diff changeset
165 // tools
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28499
diff changeset
166 init (tr ("Start/Stop Profiler Session"), sc_main_tools_start_profiler);
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28499
diff changeset
167 init (tr ("Resume Profiler Session"), sc_main_tools_resume_profiler);
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28499
diff changeset
168 init (tr ("Show Profile Data"), sc_main_tools_show_profiler);
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28499
diff changeset
169
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
170 // window
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
171 init (tr ("Show Command Window"), sc_main_window_show_command);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
172 init (tr ("Show Command History"), sc_main_window_show_history);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
173 init (tr ("Show File Browser"), sc_main_window_show_file_browser);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
174 init (tr ("Show Workspace"), sc_main_window_show_workspace);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
175 init (tr ("Show Editor"), sc_main_window_show_editor);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
176 init (tr ("Show Documentation"), sc_main_window_show_doc);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
177 init (tr ("Show Variable Editor"), sc_main_window_show_variable_editor);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
178 init (tr ("Command Window"), sc_main_window_command);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
179 init (tr ("Command History"), sc_main_window_history);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
180 init (tr ("File Browser"), sc_main_window_file_browser);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
181 init (tr ("Workspace"), sc_main_window_workspace);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
182 init (tr ("Editor"), sc_main_window_editor);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
183 init (tr ("Documentation"), sc_main_window_doc);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
184 init (tr ("Variable Editor"), sc_main_window_variable_editor);
27860
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27818
diff changeset
185 init (tr ("Previous Widget"), sc_main_window_previous_dock);
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
186 init (tr ("Reset Default Window Layout"), sc_main_window_reset);
18707
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
187
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
188 // help
30432
db045364dca9 Fixed typos before string freeze
Torsten Lilge <ttl-octave@mailbox.org>
parents: 30398
diff changeset
189 init (tr ("Show On-disk Documentation"), sc_main_help_ondisk_doc);
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
190 init (tr ("Show Online Documentation"), sc_main_help_online_doc);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
191 init (tr ("Report Bug"), sc_main_help_report_bug);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
192 init (tr ("Octave Packages"), sc_main_help_packages);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
193 init (tr ("Contribute to Octave"), sc_main_help_contribute);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
194 init (tr ("Octave Developer Resources"), sc_main_help_developer);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
195 init (tr ("About Octave"), sc_main_help_about);
18710
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18707
diff changeset
196
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
197 // news
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
198 init (tr ("Release Notes"), sc_main_news_release_notes);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
199 init (tr ("Community News"), sc_main_news_community_news);
18711
9ef65c422f53 use shortcut manager for the main news menu
Torsten <ttl@justmail.de>
parents: 18710
diff changeset
200
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
201 // Tab handling
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27860
diff changeset
202 // The following shortcuts are moved into a separate tab. The key names
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27860
diff changeset
203 // are not changed, to preserve compatibility with older versions.
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
204 init (tr ("Close Tab"), sc_edit_file_close);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
205 init (tr ("Close All Tabs"), sc_edit_file_close_all);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
206 init (tr ("Close Other Tabs"), sc_edit_file_close_other);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
207 init (tr ("Switch to Left Tab"), sc_edit_tabs_switch_left_tab);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
208 init (tr ("Switch to Right Tab"), sc_edit_tabs_switch_right_tab);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
209 init (tr ("Move Tab Left"), sc_edit_tabs_move_tab_left);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
210 init (tr ("Move Tab Right"), sc_edit_tabs_move_tab_right);
24712
95815fc93a3a move shortcuts for tab closing into a separate global settings-section
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
211
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
212 // Zooming
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
213 init (tr ("Zoom In"), sc_edit_view_zoom_in);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
214 init (tr ("Zoom Out"), sc_edit_view_zoom_out);
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
215 #if defined (Q_OS_MAC)
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
216 init (tr ("Zoom Normal"), sc_edit_view_zoom_normal);
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
217 #else
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
218 init (tr ("Zoom Normal"), sc_edit_view_zoom_normal);
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
219 #endif
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
220
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
221 // actions of the editor
18665
777281eeb3d4 add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
222
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
223 // file
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
224 init (tr ("Edit Function"), sc_edit_file_edit_function);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
225 init (tr ("Save File"), sc_edit_file_save);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
226 init (tr ("Save File As"), sc_edit_file_save_as);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
227 init (tr ("Print"), sc_edit_file_print);
18624
a827fc5fe59d handle actions from the editors file and edit menu via the shortcut manager
Torsten <ttl@justmail.de>
parents: 18611
diff changeset
228
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
229 // edit
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
230 init (tr ("Redo"), sc_edit_edit_redo);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
231 init (tr ("Cut"), sc_edit_edit_cut);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
232 init (tr ("Find and Replace"), sc_edit_edit_find_replace);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
233 init (tr ("Find Next"), sc_edit_edit_find_next);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
234 init (tr ("Find Previous"), sc_edit_edit_find_previous);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
235 init (tr ("Delete to Start of Word"), sc_edit_edit_delete_start_word);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
236 init (tr ("Delete to End of Word"), sc_edit_edit_delete_end_word);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
237 init (tr ("Delete to Start of Line"), sc_edit_edit_delete_start_line);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
238 init (tr ("Delete to End of Line"), sc_edit_edit_delete_end_line);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
239 init (tr ("Delete Line"), sc_edit_edit_delete_line);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
240 init (tr ("Copy Line"), sc_edit_edit_copy_line);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
241 init (tr ("Cut Line"), sc_edit_edit_cut_line);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
242 init (tr ("Duplicate Selection/Line"), sc_edit_edit_duplicate_selection);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
243 init (tr ("Transpose Line"), sc_edit_edit_transpose_line);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
244 init (tr ("Show Completion List"), sc_edit_edit_completion_list);
18656
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18631
diff changeset
245
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
246 init (tr ("Comment Selection"), sc_edit_edit_comment_selection);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
247 init (tr ("Uncomment Selection"), sc_edit_edit_uncomment_selection);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
248 init (tr ("Comment Selection (Choosing String)"), sc_edit_edit_comment_var_selection);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
249 init (tr ("Uppercase Selection"), sc_edit_edit_upper_case);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
250 init (tr ("Lowercase Selection"), sc_edit_edit_lower_case);
18656
1b289f45187f add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents: 18631
diff changeset
251
18923
58f1178f49ef Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents: 18922
diff changeset
252 #if defined (Q_OS_MAC)
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
253 init (tr ("Indent Selection Rigidly"), sc_edit_edit_indent_selection);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
254 init (tr ("Unindent Selection Rigidly"), sc_edit_edit_unindent_selection);
18923
58f1178f49ef Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents: 18922
diff changeset
255 #else
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
256 init (tr ("Indent Selection Rigidly"), sc_edit_edit_indent_selection);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
257 init (tr ("Unindent Selection Rigidly"), sc_edit_edit_unindent_selection);
18923
58f1178f49ef Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents: 18922
diff changeset
258 #endif
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
259 init (tr ("Indent Code"), sc_edit_edit_smart_indent_line_or_selection);
18923
58f1178f49ef Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents: 18922
diff changeset
260
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
261 init (tr ("Convert Line Endings to Windows"), sc_edit_edit_conv_eol_winows);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
262 init (tr ("Convert Line Endings to Unix"), sc_edit_edit_conv_eol_unix);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
263 init (tr ("Convert Line Endings to Mac"), sc_edit_edit_conv_eol_mac);
19247
9582fad68730 add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents: 19246
diff changeset
264
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
265 init (tr ("Goto Line"), sc_edit_edit_goto_line);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
266 init (tr ("Move to Matching Brace"), sc_edit_edit_move_to_brace);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
267 init (tr ("Select to Matching Brace"), sc_edit_edit_select_to_brace);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
268 init (tr ("Toggle Bookmark"), sc_edit_edit_toggle_bookmark);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
269 init (tr ("Next Bookmark"), sc_edit_edit_next_bookmark);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
270 init (tr ("Previous Bookmark"), sc_edit_edit_previous_bookmark);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
271 init (tr ("Remove All Bookmark"), sc_edit_edit_remove_bookmark);
18665
777281eeb3d4 add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
272
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
273 init (tr ("Preferences"), sc_edit_edit_preferences);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
274 init (tr ("Styles Preferences"), sc_edit_edit_styles_preferences);
18665
777281eeb3d4 add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
275
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
276 // view
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
277 init (tr ("Show Line Numbers"), sc_edit_view_show_line_numbers);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
278 init (tr ("Show Whitespace Characters"), sc_edit_view_show_white_spaces);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
279 init (tr ("Show Line Endings"), sc_edit_view_show_eol_chars);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
280 init (tr ("Show Indentation Guides"), sc_edit_view_show_ind_guides);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
281 init (tr ("Show Long Line Marker"), sc_edit_view_show_long_line);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
282 init (tr ("Show Toolbar"), sc_edit_view_show_toolbar);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
283 init (tr ("Show Statusbar"), sc_edit_view_show_statusbar);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
284 init (tr ("Show Horizontal Scrollbar"), sc_edit_view_show_hscrollbar);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
285 init (tr ("Sort Tabs Alphabetically"), sc_edit_view_sort_tabs);
18665
777281eeb3d4 add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
286
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
287 // debug
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
288 init (tr ("Toggle Breakpoint"), sc_edit_debug_toggle_breakpoint);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
289 init (tr ("Next Breakpoint"), sc_edit_debug_next_breakpoint);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
290 init (tr ("Previous Breakpoint"), sc_edit_debug_previous_breakpoint);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
291 init (tr ("Remove All Breakpoints"), sc_edit_debug_remove_breakpoints);
18665
777281eeb3d4 add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
292
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
293 // run
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
294 init (tr ("Run File"), sc_edit_run_run_file);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
295 init (tr ("Run Selection"), sc_edit_run_run_selection);
18665
777281eeb3d4 add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents: 18656
diff changeset
296
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
297 // help
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
298 init (tr ("Help on Keyword"), sc_edit_help_help_keyword);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
299 init (tr ("Document on Keyword"), sc_edit_help_doc_keyword);
20693
7751bd56d0be added actions and shortcuts for switching editor tabs
Torsten <ttl@justmail.de>
parents: 20686
diff changeset
300
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
301
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
302 // Documentation browser
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
303 init (tr ("Go to Homepage"), sc_doc_go_home);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
304 init (tr ("Go Back one Page"), sc_doc_go_back);
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
305 init (tr ("Go Forward one Page"), sc_doc_go_next);
29330
b92614cfdfed add bookmark functionality to the documentation browser (bug #54938)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29206
diff changeset
306 init (tr ("Bookmark this Page"), sc_doc_bookmark);
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
307 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
308
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
309 // write one or all actual shortcut set(s) into a settings file
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
310 void shortcut_manager::write_shortcuts (gui_settings& settings,
27935
f1844e33f621 maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents: 27923
diff changeset
311 bool closing)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
312 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
313 bool sc_ctrld = false;
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
314
27935
f1844e33f621 maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents: 27923
diff changeset
315 QString sc_main = sc_main_file.mid (0, sc_main_file.indexOf ('_') + 1);
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
316
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
317 for (int i = 0; i < m_sc.count (); i++) // loop over all shortcuts
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
318 {
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
319 settings.setValue (sc_group + "/" + m_sc.at (i).m_settings_key,
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
320 m_sc.at (i).m_actual_sc.toString ());
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
321 // special: check main-window for Ctrl-D (Terminal)
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
322 if (m_sc.at (i).m_settings_key.startsWith (sc_main)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
323 && m_sc.at (i).m_actual_sc == QKeySequence (Qt::ControlModifier+Qt::Key_D))
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
324 sc_ctrld = true;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
325 }
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
326
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
327 settings.setValue (sc_main_ctrld.key, sc_ctrld);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
328
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
329 if (closing)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
330 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
331 delete m_dialog; // the dialog for key sequences can be removed now
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
332 m_dialog = nullptr; // make sure it is zero again
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
333 }
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
334
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
335 settings.sync (); // sync the settings file
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
336 }
20987
f99cbd86a0f9 Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
337
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
338 void shortcut_manager::set_shortcut (QAction *action, const sc_pref& scpref,
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
339 bool enable)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
340 {
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
341 if (! enable)
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
342 {
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
343 // Disable => remove existing shortcut from the action
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
344 action->setShortcut (QKeySequence ());
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
345 return;
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
346 }
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
347
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
348 // Enable: Is the given key known? If yes, get the value from the
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
349 // settings file and set it to the action
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
350 int index;
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
351
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
352 index = m_action_hash[scpref.key] - 1;
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
353
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
354 if (index > -1 && index < m_sc.count ())
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
355 {
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
356 gui_settings settings;
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
357
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
358 action->setShortcut (QKeySequence (settings.sc_value (scpref)));
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
359 }
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
360 else
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
361 qDebug () << "Key: " << scpref.key << " not found in m_action_hash";
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
362 }
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
363
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
364 void shortcut_manager::shortcut (QShortcut *sc, const sc_pref& scpref)
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
365 {
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
366 int index;
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
367
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
368 index = m_action_hash[scpref.key] - 1;
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
369
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
370 if (index > -1 && index < m_sc.count ())
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
371 {
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
372 gui_settings settings;
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
373
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
374 sc->setKey (QKeySequence (settings.sc_value (scpref)));
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
375 }
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
376 else
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
377 qDebug () << "Key: " << scpref.key << " not found in m_action_hash";
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
378 }
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
379
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
380 void shortcut_manager::fill_treewidget (QTreeWidget *tree_view)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
381 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
382 m_dialog = nullptr;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
383 m_level_hash.clear ();
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
384
24827
1e0718c1867c eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents: 24724
diff changeset
385 tree_view->header ()->setSectionResizeMode (QHeaderView::ResizeToContents);
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
386
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
387 QTreeWidgetItem *main = new QTreeWidgetItem (tree_view);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
388 main->setText (0, tr ("Global"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
389 main->setExpanded (true);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
390 QTreeWidgetItem *main_file = new QTreeWidgetItem (main);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
391 main_file->setText (0, tr ("File Menu"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
392 QTreeWidgetItem *main_edit = new QTreeWidgetItem (main);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
393 main_edit->setText (0, tr ("Edit Menu"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
394 QTreeWidgetItem *main_debug = new QTreeWidgetItem (main);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
395 main_debug->setText (0, tr ("Debug Menu"));
29068
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28499
diff changeset
396 QTreeWidgetItem *main_tools = new QTreeWidgetItem (main);
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28499
diff changeset
397 main_tools->setText (0, tr ("Tools Menu"));
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
398 QTreeWidgetItem *main_window = new QTreeWidgetItem (main);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
399 main_window->setText (0, tr ("Window Menu"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
400 QTreeWidgetItem *main_help = new QTreeWidgetItem (main);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
401 main_help->setText (0, tr ("Help Menu"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
402 QTreeWidgetItem *main_news = new QTreeWidgetItem (main);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
403 main_news->setText (0, tr ("News Menu"));
27937
8dc5b36f1245 include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27935
diff changeset
404 QTreeWidgetItem *main_dock_widgets = new QTreeWidgetItem (main);
8dc5b36f1245 include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27935
diff changeset
405 main_dock_widgets->setText (0, tr ("Handling of Dock Widgets"));
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
406 QTreeWidgetItem *main_tabs = new QTreeWidgetItem (main);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
407 main_tabs->setText (0, tr ("Tab Handling in Dock Widgets"));
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
408 QTreeWidgetItem *main_find = new QTreeWidgetItem (main);
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
409 main_find->setText (0, tr ("Find & Replace in Dock Widgets"));
25976
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
410 QTreeWidgetItem *main_zoom = new QTreeWidgetItem (main);
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
411 main_zoom->setText (0, tr ("Zooming in Editor and Documentation"));
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
412
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
413 m_level_hash[sc_main_file] = main_file;
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
414 m_level_hash[sc_main_edit] = main_edit;
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
415 m_level_hash[sc_main_debug] = main_debug;
29068
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28499
diff changeset
416 m_level_hash[sc_main_tools] = main_tools;
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
417 m_level_hash[sc_main_window] = main_window;
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
418 m_level_hash[sc_main_help] = main_help;
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
419 m_level_hash[sc_main_news] = main_news;
27937
8dc5b36f1245 include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27935
diff changeset
420 m_level_hash[sc_dock_widget] = main_dock_widgets;
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
421 m_level_hash[sc_edit_tabs] = main_tabs;
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
422 m_level_hash[sc_edit_find] = main_find;
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
423 m_level_hash[sc_edit_zoom] = main_zoom;
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
424
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
425 QTreeWidgetItem *editor = new QTreeWidgetItem (tree_view);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
426 editor->setText (0, tr ("Editor"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
427 editor->setExpanded (true);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
428 QTreeWidgetItem *editor_file = new QTreeWidgetItem (editor);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
429 editor_file->setText (0, tr ("File Menu"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
430 QTreeWidgetItem *editor_edit = new QTreeWidgetItem (editor);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
431 editor_edit->setText (0, tr ("Edit Menu"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
432 QTreeWidgetItem *editor_view = new QTreeWidgetItem (editor);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
433 editor_view->setText (0, tr ("View Menu"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
434 QTreeWidgetItem *editor_debug = new QTreeWidgetItem (editor);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
435 editor_debug->setText (0, tr ("Debug Menu"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
436 QTreeWidgetItem *editor_run = new QTreeWidgetItem (editor);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
437 editor_run->setText (0, tr ("Run Menu"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
438 QTreeWidgetItem *editor_help = new QTreeWidgetItem (editor);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
439 editor_help->setText (0, tr ("Help Menu"));
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
440
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
441 m_level_hash[sc_edit_file] = editor_file;
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
442 m_level_hash[sc_edit_edit] = editor_edit;
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
443 m_level_hash[sc_edit_view] = editor_view;
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
444 m_level_hash[sc_edit_debug] = editor_debug;
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
445 m_level_hash[sc_edit_run] = editor_run;
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
446 m_level_hash[sc_edit_help] = editor_help;
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
447
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
448 QTreeWidgetItem *doc = new QTreeWidgetItem (tree_view);
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
449 doc->setText (0, tr ("Documentation Viewer"));
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
450 doc->setExpanded (true);
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
451
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
452 QTreeWidgetItem *doc_browser = new QTreeWidgetItem (doc);
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
453 doc_browser->setText (0, tr ("Browser"));
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
454
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
455 m_level_hash[sc_doc] = doc_browser;
26017
390d59717711 adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents: 25976
diff changeset
456
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
457 connect (tree_view, &QTreeWidget::itemDoubleClicked,
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
458 this, &shortcut_manager::handle_double_clicked);
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
459
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
460 for (int i = 0; i < m_sc.count (); i++)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
461 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
462 shortcut_t sc = m_sc.at (i);
24712
95815fc93a3a move shortcuts for tab closing into a separate global settings-section
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
463
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29542
diff changeset
464 QTreeWidgetItem *section = m_level_hash[sc.m_settings_key.section (':', 0, 0)];
24712
95815fc93a3a move shortcuts for tab closing into a separate global settings-section
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
465
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
466 // handle sections which have changed and do not correspond to the
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
467 // previously defined keyname
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
468 if (section == editor_file)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
469 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
470 // Closing tabs now in global tab handling section
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
471 if (sc.m_settings_key.contains (sc_edit_file_cl))
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
472 section = main_tabs;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
473 }
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
474 if (section == editor_edit)
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
475 {
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
476 // Find & replace now in global file & replace handling section
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
477 if (sc.m_settings_key.contains (sc_edit_edit_find))
25371
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
478 section = main_find;
41bbdf17f51a make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents: 25189
diff changeset
479 }
25976
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
480 if (section == editor_view)
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
481 {
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
482 // Zooming now in global zoom handling section
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
483 if (sc.m_settings_key.contains (sc_edit_view_zoom))
25976
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
484 section = main_zoom;
a7cc5b7a3d22 provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
485 }
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
486
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
487 QTreeWidgetItem *tree_item = new QTreeWidgetItem (section);
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
488
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
489 // set a slightly transparent foreground for default columns
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
490 QColor fg = QColor (tree_item->foreground (1).color ());
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
491 fg.setAlpha (128);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
492 tree_item->setForeground (1, QBrush (fg));
18728
95249367d6fa provide a second set of shortcuts
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
493
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
494 // write the shortcuts
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
495 tree_item->setText (0, sc.m_description);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
496 tree_item->setText (1, sc.m_default_sc.toString ());
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
497 tree_item->setText (2, sc.m_actual_sc.toString ());
20987
f99cbd86a0f9 Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
498
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
499 m_item_index_hash[tree_item] = i + 1; // index+1 to avoid 0
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
500 m_index_item_hash[i] = tree_item;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
501 }
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
502 }
20702
b6b16d8c8b57 possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents: 20693
diff changeset
503
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
504 // import or export of shortcut sets,
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
505 // called from settings dialog when related buttons are clicked;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
506 // returns true on success, false otherwise
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
507 bool
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
508 shortcut_manager::import_export (int action)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
509 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
510 // ask to save the current shortcuts, maybe abort import
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
511 if (action == OSC_DEFAULT || action == OSC_IMPORT)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
512 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
513 if (! overwrite_all_shortcuts ())
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
514 return false;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
515 }
20702
b6b16d8c8b57 possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents: 20693
diff changeset
516
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
517 // get the filename to read or write the shortcuts,
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
518 // the default extension is .osc (octave shortcuts)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
519 if (action != OSC_DEFAULT)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
520 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
521 QString file;
20702
b6b16d8c8b57 possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents: 20693
diff changeset
522
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26017
diff changeset
523 // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved.
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26017
diff changeset
524 int opts = 0; // No options by default.
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
525
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
526 gui_settings settings;
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
527
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
528 if (! settings.value (global_use_native_dialogs).toBool ())
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26017
diff changeset
529 opts = QFileDialog::DontUseNativeDialog;
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26017
diff changeset
530
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
531 if (action == OSC_IMPORT)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
532 file = QFileDialog::getOpenFileName (this,
25189
d2558ba799d8 Change the GUI Import/Export Shortcuts strings to end with ellipsis.
Rik <rik@octave.org>
parents: 25163
diff changeset
533 tr ("Import shortcuts from file..."), QString (),
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
534 tr ("Octave Shortcut Files (*.osc);;All Files (*)"),
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26017
diff changeset
535 nullptr, QFileDialog::Option (opts));
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
536 else if (action == OSC_EXPORT)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
537 file = QFileDialog::getSaveFileName (this,
25189
d2558ba799d8 Change the GUI Import/Export Shortcuts strings to end with ellipsis.
Rik <rik@octave.org>
parents: 25163
diff changeset
538 tr ("Export shortcuts to file..."), QString (),
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
539 tr ("Octave Shortcut Files (*.osc);;All Files (*)"),
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26017
diff changeset
540 nullptr, QFileDialog::Option (opts));
20702
b6b16d8c8b57 possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents: 20693
diff changeset
541
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
542 if (file.isEmpty ())
20702
b6b16d8c8b57 possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents: 20693
diff changeset
543 return false;
18822
3f6280d0a36b allow export and import of shortcut sets
Torsten <ttl@justmail.de>
parents: 18728
diff changeset
544
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27412
diff changeset
545 gui_settings osc_settings (file, QSettings::IniFormat);
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
546
26635
931ace437d5d fix possible memleak by avoiding bare poointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
547 if (osc_settings.status () != QSettings::NoError)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
548 {
25163
3aed4f0ba3cd Update some GUI strings identified as unclear by translators.
Rik <rik@octave.org>
parents: 25128
diff changeset
549 qWarning () << tr ("Failed to open %1 as Octave shortcut file")
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
550 .arg (file);
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
551 return false;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
552 }
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
553 else
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
554 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
555 if (action == OSC_IMPORT)
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
556 import_shortcuts (osc_settings); // import (special action)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
557 else if (action == OSC_EXPORT)
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
558 write_shortcuts (osc_settings, false); // export, (save settings)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
559 }
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
560 }
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
561 else
31618
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
562 reset_default_shortcuts ();
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
563
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
564 return true;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
565 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
566
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
567 void shortcut_manager::handle_double_clicked (QTreeWidgetItem *item, int col)
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
568 {
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
569 if (col != 2)
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
570 return;
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
571
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
572 int i = m_item_index_hash[item];
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
573 if (i == 0)
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
574 return; // top-level-item clicked
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
575
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
576 shortcut_dialog (i-1); // correct to index starting at 0
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
577 }
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
578
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
579 void shortcut_manager::shortcut_dialog_finished (int result)
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
580 {
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
581 if (result == QDialog::Rejected)
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
582 return;
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
583
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
584 // check for duplicate
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
585 int double_index = m_shortcut_hash[m_edit_actual->text ()] - 1;
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
586
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
587 if (double_index >= 0 && double_index != m_handled_index)
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
588 {
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
589 int ret = QMessageBox::warning (this, tr ("Double Shortcut"),
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
590 tr ("The chosen shortcut\n \"%1\"\n"
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
591 "is already used for the action\n \"%2\".\n"
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
592 "Do you want to use the shortcut anyhow removing it "
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
593 "from the previous action?")
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
594 .arg (m_edit_actual->text ())
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
595 .arg (m_sc.at (double_index).m_description),
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
596 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
597
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
598 if (ret == QMessageBox::Yes)
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
599 {
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
600 shortcut_t double_shortcut = m_sc.at (double_index);
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
601 double_shortcut.m_actual_sc = QKeySequence ();
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
602 m_sc.replace (double_index, double_shortcut);
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
603 m_index_item_hash[double_index]->setText (2, QString ());
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
604 }
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
605 else
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
606 return;
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
607 }
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
608
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
609 shortcut_t shortcut = m_sc.at (m_handled_index);
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
610 if (! shortcut.m_actual_sc.isEmpty ())
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
611 m_shortcut_hash.remove (shortcut.m_actual_sc.toString ());
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
612 shortcut.m_actual_sc = m_edit_actual->text ();
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
613 m_sc.replace (m_handled_index, shortcut);
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
614
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
615 m_index_item_hash[m_handled_index]->setText (2, shortcut.m_actual_sc.toString ());
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
616
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
617 if (! shortcut.m_actual_sc.isEmpty ())
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
618 m_shortcut_hash[shortcut.m_actual_sc.toString ()] = m_handled_index + 1;
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
619 }
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
620
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
621 void shortcut_manager::shortcut_dialog_set_default (void)
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
622 {
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
623 m_edit_actual->setText (m_label_default->text ());
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
624 }
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
625
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
626 void shortcut_manager::init (const QString& description, const sc_pref& sc)
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
627 {
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
628 gui_settings settings;
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
629
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
630 QKeySequence actual = QKeySequence (settings.sc_value (sc));
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
631
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
632 // append the new shortcut to the list
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
633 shortcut_t shortcut_info;
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
634 shortcut_info.m_description = description;
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
635 shortcut_info.m_settings_key = sc.key;
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
636 shortcut_info.m_actual_sc = actual;
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
637 shortcut_info.m_default_sc = settings.sc_def_value (sc);
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
638 m_sc << shortcut_info;
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
639
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27860
diff changeset
640 // insert shortcut in order to check for duplicates later
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
641 if (! actual.isEmpty ())
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
642 m_shortcut_hash[actual.toString ()] = m_sc.count ();
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
643 m_action_hash[sc.key] = m_sc.count ();
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
644
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
645 // check whether ctrl+d is used from main window, i.e. is a global shortcut
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
646 QString main_group_prefix
27935
f1844e33f621 maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents: 27923
diff changeset
647 = sc_main_file.mid (0, sc_main_file.indexOf ('_') + 1);
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
648 if (sc.key.startsWith (main_group_prefix)
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
649 && actual == QKeySequence (Qt::ControlModifier+Qt::Key_D))
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
650 settings.setValue (sc_main_ctrld.key, true);
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
651 }
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
652
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
653 void shortcut_manager::shortcut_dialog (int index)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
654 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
655 if (! m_dialog)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
656 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
657 m_dialog = new QDialog (this);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
658
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
659 m_dialog->setWindowTitle (tr ("Enter new Shortcut"));
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
660
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
661 QVBoxLayout *box = new QVBoxLayout (m_dialog);
26830
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
662 box->setSpacing (2);
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
663 box->setContentsMargins (12, 12, 12, 12);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
664
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
665 QLabel *help = new QLabel (tr ("Apply the desired shortcut or click "
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
666 "on the right button to reset the "
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
667 "shortcut to its default."));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
668 help->setWordWrap (true);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
669 box->addWidget (help);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
670
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 26885
diff changeset
671 QCheckBox *direct
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 26885
diff changeset
672 = new QCheckBox (tr ("Enter shortcut directly by performing it"));
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 26885
diff changeset
673
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 26885
diff changeset
674 QCheckBox *shift
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 26885
diff changeset
675 = new QCheckBox (tr ("Add Shift modifier\n"
31433
d17ee5e7b66c Fix typos and grammatical mistakes in text exposed to the user
Rafael Laboissiere <rafael@laboissiere.net>
parents: 30564
diff changeset
676 "(allows one to enter number keys)"));
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 26885
diff changeset
677
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 26885
diff changeset
678 shift->setStyleSheet
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 26885
diff changeset
679 ("QCheckBox::indicator { subcontrol-position: left top; }");
26830
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
680
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
681 connect (direct, &QCheckBox::clicked, shift, &QCheckBox::setEnabled);
26830
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
682
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
683 direct->setCheckState (Qt::Checked);
26830
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
684
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
685 box->addWidget (direct);
26830
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
686 box->addWidget (shift);
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
687
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
688 box->addSpacing (15);
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
689
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
690 QGridLayout *grid = new QGridLayout ();
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
691
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
692 QLabel *actual = new QLabel (tr ("Actual shortcut"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
693 m_edit_actual = new enter_shortcut (m_dialog);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
694 m_edit_actual->setAlignment (Qt::AlignHCenter);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
695 grid->addWidget (actual, 0, 0);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
696 grid->addWidget (m_edit_actual, 0, 1);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
697
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
698 QLabel *def = new QLabel (tr ("Default shortcut"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
699 m_label_default = new QLabel (m_dialog);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
700 m_label_default->setAlignment (Qt::AlignHCenter);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
701 grid->addWidget (def, 1, 0);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
702 grid->addWidget (m_label_default, 1, 1);
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
703
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
704 QPushButton *set_default = new QPushButton (tr ("Set to default"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
705 grid->addWidget (set_default, 0, 2);
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
706 connect (set_default, &QPushButton::clicked,
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
707 this, &shortcut_manager::shortcut_dialog_set_default);
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
708
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
709 box->addLayout (grid);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
710
26830
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
711 box->addSpacing (18);
e255897f353d gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents: 26638
diff changeset
712
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
713 QDialogButtonBox *button_box = new QDialogButtonBox (QDialogButtonBox::Ok
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
714 | QDialogButtonBox::Cancel);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
715 QList<QAbstractButton *> buttons = button_box->buttons ();
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
716 for (int i = 0; i < buttons.count (); i++)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
717 buttons.at (i)->setShortcut (QKeySequence ());
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
718 connect (button_box, &QDialogButtonBox::accepted,
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
719 m_dialog, &QDialog::accept);
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
720 connect (button_box, &QDialogButtonBox::rejected,
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
721 m_dialog, &QDialog::reject);
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
722 box->addWidget (button_box);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
723
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
724 m_dialog->setLayout (box);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
725
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
726 connect (direct, &QCheckBox::stateChanged,
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
727 m_edit_actual, &enter_shortcut::handle_direct_shortcut);
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
728 connect (shift, &QCheckBox::stateChanged,
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
729 m_edit_actual, &enter_shortcut::handle_shift_modifier);
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
730 connect (m_dialog, &QDialog::finished,
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
731 this, &shortcut_manager::shortcut_dialog_finished);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
732
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
733 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
734
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
735 m_edit_actual->setText (m_sc.at (index).m_actual_sc.toString ());
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
736 m_label_default->setText (m_sc.at (index).m_default_sc.toString ());
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
737 m_handled_index = index;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
738
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
739 m_edit_actual->setFocus ();
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
740 m_dialog->setFocusProxy (m_edit_actual);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
741 m_dialog->exec ();
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
742 }
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
743
31618
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
744 // import a shortcut set from a given settings file and refresh the
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
745 // tree view
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
746 void shortcut_manager::import_shortcuts (gui_settings& settings)
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
747 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
748 for (int i = 0; i < m_sc.count (); i++)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
749 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
750 // update the list of all shortcuts
31618
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
751
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
752 // make a copy
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
753 shortcut_t sc = m_sc.at (i);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
754
31618
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
755 // get new shortcut from settings and use the old one as default
31619
ad014fc78bd6 use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents: 31618
diff changeset
756 sc.m_actual_sc = QKeySequence (settings.value (sc_group + sc.m_settings_key, sc.m_actual_sc).toString ());
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
757
31618
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
758 // replace the old with the new one
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
759 m_sc.replace (i, sc);
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
760
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
761 // update the tree view
31618
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
762 // get related tree item
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
763 QTreeWidgetItem *tree_item = m_index_item_hash[i];
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
764
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
765 // display new shortcut
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
766 tree_item->setText (2, sc.m_actual_sc.toString ());
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
767 }
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
768 }
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
769
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
770 // reset to the defaults and refresh the tree view
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
771 void shortcut_manager::reset_default_shortcuts (void)
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
772 {
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
773 for (int i = 0; i < m_sc.count (); i++)
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
774 {
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
775 // update the list of all shortcuts
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
776
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
777 // make a copy
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
778 shortcut_t sc = m_sc.at (i);
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
779
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
780 // get default shortcut
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
781 sc.m_actual_sc = QKeySequence (sc.m_default_sc);
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
782
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
783 // replace the old with the new one
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
784 m_sc.replace (i, sc);
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
785
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
786 // update the tree view
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
787 // get related tree item
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
788 QTreeWidgetItem *tree_item = m_index_item_hash[i];
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
789
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
790 // display new shortcut
cd833a9baaa7 use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents: 31433
diff changeset
791 tree_item->setText (2, sc.m_actual_sc.toString ());
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
792 }
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
793 }
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
794
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
795 // ask the user whether to save the current shortcut set;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
796 // returns true to proceed with import action, false to abort it
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
797 bool shortcut_manager::overwrite_all_shortcuts (void)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
798 {
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
799 QMessageBox msg_box;
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
800 msg_box.setWindowTitle (tr ("Overwriting Shortcuts"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
801 msg_box.setIcon (QMessageBox::Warning);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
802 msg_box.setText (tr ("You are about to overwrite all shortcuts.\n"
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
803 "Would you like to save the current shortcut set or cancel the action?"));
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
804 msg_box.setStandardButtons (QMessageBox::Save | QMessageBox::Cancel);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
805 QPushButton *discard = msg_box.addButton (tr ("Don't save"),
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
806 QMessageBox::DestructiveRole);
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
807 msg_box.setDefaultButton (QMessageBox::Save);
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
808
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
809 int ret = msg_box.exec ();
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
810
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
811 if (msg_box.clickedButton () == discard)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
812 return true; // do not save and go ahead
24014
bffd7d826887 style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents: 23941
diff changeset
813
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
814 if (ret == QMessageBox::Save)
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
815 {
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
816 if (import_export (OSC_EXPORT))
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
817 return true; // go ahead
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
818 }
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
819
24718
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
820 return false; // abort the import
ea1c88bd4430 move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24712
diff changeset
821 }
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff changeset
822 }