Mercurial > octave
annotate libgui/src/shortcut-manager.cc @ 31647:431f80aba37a
maint: Merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 06 Dec 2022 15:37:43 -0500 |
parents | ca7d58406f82 c6d54dd31a7e |
children | deb553ac2c54 |
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 |
31646
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
51 OCTAVE_BEGIN_NAMESPACE(octave) |
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
31433
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 |
31639
ca7d58406f82
eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents:
31619
diff
changeset
|
111 shortcut_manager::shortcut_manager (void) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
112 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
113 setObjectName ("Shortcut_Manager"); |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19251
diff
changeset
|
114 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
115 // 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
|
116 #if defined (Q_OS_MAC) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
117 QCoreApplication::setAttribute (Qt::AA_MacDontSwapCtrlAndMeta, true); |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
118 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
119 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
120 |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
121 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
|
122 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
123 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
|
124 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
125 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
|
126 |
27937
8dc5b36f1245
include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
127 // 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
|
128 |
8dc5b36f1245
include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
129 // dock widgets |
8dc5b36f1245
include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
130 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
|
131 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
|
132 |
8dc5b36f1245
include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
133 // 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
|
134 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
135 // file |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
136 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
|
137 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
|
138 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
|
139 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
|
140 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
|
141 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
|
142 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
|
143 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
144 // edit |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
145 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
|
146 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
|
147 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
|
148 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
|
149 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
|
150 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
|
151 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
|
152 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
|
153 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
|
154 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
|
155 init (tr ("Preferences"), sc_main_edit_preferences); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
156 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
157 // debug |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
158 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
|
159 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
|
160 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
|
161 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
|
162 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
|
163 |
29068
d8089b13d4d7
add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
164 // tools |
d8089b13d4d7
add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
165 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
|
166 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
|
167 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
|
168 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
169 // window |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
170 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
|
171 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
|
172 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
|
173 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
|
174 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
|
175 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
|
176 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
|
177 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
|
178 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
187 // help |
30432
db045364dca9
Fixed typos before string freeze
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
188 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
|
189 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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 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
|
195 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
196 // news |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
197 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
|
198 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
|
199 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
200 // Tab handling |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27860
diff
changeset
|
201 // 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
|
202 // 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
211 // Zooming |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
212 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
|
213 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
|
214 #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
|
215 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
|
216 #else |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
217 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
|
218 #endif |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
219 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
220 // 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
|
221 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
222 // file |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
223 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
|
224 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
|
225 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
|
226 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
|
227 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
228 // edit |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
229 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
|
230 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
|
231 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
|
232 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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 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
|
244 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
245 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
|
246 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
|
247 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
|
248 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
|
249 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
|
250 |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
251 #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
|
252 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
|
253 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
|
254 #else |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
255 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
|
256 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
|
257 #endif |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
258 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
|
259 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
260 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
|
261 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
|
262 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
|
263 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
264 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
|
265 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
|
266 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
|
267 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
|
268 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
|
269 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
|
270 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
|
271 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
272 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
|
273 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
|
274 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
275 // view |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
276 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
|
277 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
|
278 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
|
279 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
|
280 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
|
281 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
|
282 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
|
283 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
|
284 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
|
285 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
286 // debug |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
287 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
|
288 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
|
289 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
|
290 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
|
291 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
292 // run |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
293 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
|
294 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
|
295 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
296 // help |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
297 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
|
298 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
|
299 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
300 // Documentation browser |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
301 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
|
302 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
|
303 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
|
304 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
|
305 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
306 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
307 // 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
|
308 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
|
309 bool closing) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
310 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
311 bool sc_ctrld = false; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
312 |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
313 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
|
314 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
315 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
|
316 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
317 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
|
318 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
|
319 // 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
|
320 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
|
321 && 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
|
322 sc_ctrld = true; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
323 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
324 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
325 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
|
326 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
327 if (closing) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
328 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
329 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
|
330 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
|
331 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
332 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
333 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
|
334 } |
20987
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20986
diff
changeset
|
335 |
29206
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
336 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
|
337 bool enable) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
338 { |
29206
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
339 if (! enable) |
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
340 { |
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
341 // 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
|
342 action->setShortcut (QKeySequence ()); |
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
343 return; |
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
344 } |
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
345 |
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
346 // 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
|
347 // 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
|
348 int index; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
349 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
350 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
|
351 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
352 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
|
353 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
354 gui_settings settings; |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
355 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
356 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
|
357 } |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
358 else |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
359 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
|
360 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
361 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
362 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
|
363 { |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
364 int index; |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
365 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
366 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
|
367 |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
368 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
|
369 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
370 gui_settings settings; |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
371 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
372 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
|
373 } |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
374 else |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
375 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
|
376 } |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
377 |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
378 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
|
379 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
380 m_dialog = nullptr; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
381 m_level_hash.clear (); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
382 |
24827
1e0718c1867c
eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents:
24724
diff
changeset
|
383 tree_view->header ()->setSectionResizeMode (QHeaderView::ResizeToContents); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
384 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
385 QTreeWidgetItem *main = new QTreeWidgetItem (tree_view); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
386 main->setText (0, tr ("Global")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
387 main->setExpanded (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
388 QTreeWidgetItem *main_file = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
389 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
|
390 QTreeWidgetItem *main_edit = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
391 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
|
392 QTreeWidgetItem *main_debug = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
393 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
|
394 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
|
395 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
|
396 QTreeWidgetItem *main_window = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
397 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
|
398 QTreeWidgetItem *main_help = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
399 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
|
400 QTreeWidgetItem *main_news = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
401 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
|
402 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
|
403 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
|
404 QTreeWidgetItem *main_tabs = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
405 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
|
406 QTreeWidgetItem *main_find = new QTreeWidgetItem (main); |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
407 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
|
408 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
|
409 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
|
410 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
411 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
|
412 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
|
413 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
|
414 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
|
415 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
|
416 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
|
417 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
|
418 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
|
419 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
|
420 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
|
421 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
|
422 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
423 QTreeWidgetItem *editor = new QTreeWidgetItem (tree_view); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
424 editor->setText (0, tr ("Editor")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
425 editor->setExpanded (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
426 QTreeWidgetItem *editor_file = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
427 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
|
428 QTreeWidgetItem *editor_edit = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
429 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
|
430 QTreeWidgetItem *editor_view = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
431 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
|
432 QTreeWidgetItem *editor_debug = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
433 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
|
434 QTreeWidgetItem *editor_run = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
435 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
|
436 QTreeWidgetItem *editor_help = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
437 editor_help->setText (0, tr ("Help Menu")); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
438 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
439 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
|
440 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
|
441 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
|
442 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
|
443 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
|
444 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
|
445 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
446 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
|
447 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
|
448 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
|
449 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
450 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
|
451 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
|
452 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
453 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
|
454 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
455 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
|
456 this, &shortcut_manager::handle_double_clicked); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
457 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
458 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
|
459 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
460 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
|
461 |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29542
diff
changeset
|
462 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
|
463 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
464 // 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
|
465 // previously defined keyname |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
466 if (section == editor_file) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
467 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
468 // 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
|
469 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
|
470 section = main_tabs; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
471 } |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
472 if (section == editor_edit) |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
473 { |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
474 // 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
|
475 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
|
476 section = main_find; |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
477 } |
25976
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
478 if (section == editor_view) |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
479 { |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
480 // 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
|
481 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
|
482 section = main_zoom; |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
483 } |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
484 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
485 QTreeWidgetItem *tree_item = new QTreeWidgetItem (section); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
486 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
487 // 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
|
488 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
|
489 fg.setAlpha (128); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
490 tree_item->setForeground (1, QBrush (fg)); |
18728
95249367d6fa
provide a second set of shortcuts
Torsten <ttl@justmail.de>
parents:
18711
diff
changeset
|
491 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
492 // write the shortcuts |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
493 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
|
494 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
|
495 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
|
496 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
497 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
|
498 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
|
499 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
500 } |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
501 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
502 // import or export of shortcut sets, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
503 // 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
|
504 // returns true on success, false otherwise |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
505 bool |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
506 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
|
507 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
508 // 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
|
509 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
|
510 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
511 if (! overwrite_all_shortcuts ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
512 return false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
513 } |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
514 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
515 // 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
|
516 // 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
|
517 if (action != OSC_DEFAULT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
518 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
519 QString file; |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
520 |
26096
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26017
diff
changeset
|
521 // 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
|
522 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
|
523 |
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
524 gui_settings settings; |
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 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
|
527 opts = QFileDialog::DontUseNativeDialog; |
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26017
diff
changeset
|
528 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
529 if (action == OSC_IMPORT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
530 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
|
531 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
|
532 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
|
533 nullptr, QFileDialog::Option (opts)); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
534 else if (action == OSC_EXPORT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
535 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
|
536 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
|
537 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
|
538 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
|
539 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
540 if (file.isEmpty ()) |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
541 return false; |
18822
3f6280d0a36b
allow export and import of shortcut sets
Torsten <ttl@justmail.de>
parents:
18728
diff
changeset
|
542 |
27611
0495b64288f7
use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
543 gui_settings osc_settings (file, QSettings::IniFormat); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
544 |
26635
931ace437d5d
fix possible memleak by avoiding bare poointer (bug #55440)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
545 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
|
546 { |
25163
3aed4f0ba3cd
Update some GUI strings identified as unclear by translators.
Rik <rik@octave.org>
parents:
25128
diff
changeset
|
547 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
|
548 .arg (file); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
549 return false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
550 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
551 else |
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 if (action == OSC_IMPORT) |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
554 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
|
555 else if (action == OSC_EXPORT) |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
556 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
|
557 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
558 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
559 else |
31618
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
560 reset_default_shortcuts (); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
561 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
562 return true; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
563 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
564 |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
565 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
|
566 { |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
567 if (col != 2) |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
568 return; |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
569 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
570 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
|
571 if (i == 0) |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
572 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
|
573 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
574 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
|
575 } |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
576 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
577 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
|
578 { |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
579 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
|
580 return; |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
581 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
582 // check for duplicate |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
583 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
|
584 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
585 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
|
586 { |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
587 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
|
588 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
|
589 "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
|
590 "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
|
591 "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
|
592 .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
|
593 .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
|
594 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
|
595 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
596 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
|
597 { |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
598 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
|
599 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
|
600 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
|
601 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
|
602 } |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
603 else |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
604 return; |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
605 } |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
606 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
607 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
|
608 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
|
609 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
|
610 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
|
611 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
|
612 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
613 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
|
614 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
615 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
|
616 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
|
617 } |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
618 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
619 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
|
620 { |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
621 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
|
622 } |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
623 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
624 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
|
625 { |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
626 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
|
627 |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
628 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
|
629 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
630 // 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
|
631 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
|
632 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
|
633 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
|
634 shortcut_info.m_actual_sc = actual; |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
635 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
|
636 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
|
637 |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27860
diff
changeset
|
638 // 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
|
639 if (! actual.isEmpty ()) |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
640 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
|
641 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
|
642 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
643 // 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
|
644 QString main_group_prefix |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
645 = 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
|
646 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
|
647 && 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
|
648 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
|
649 } |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
650 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
651 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
|
652 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
653 if (! m_dialog) |
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 m_dialog = new QDialog (this); |
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->setWindowTitle (tr ("Enter new Shortcut")); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
658 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
659 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
|
660 box->setSpacing (2); |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
661 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
|
662 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
663 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
|
664 "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
|
665 "shortcut to its default.")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
666 help->setWordWrap (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
667 box->addWidget (help); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
668 |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
669 QCheckBox *direct |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
670 = 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
|
671 |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
672 QCheckBox *shift |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
673 = 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
|
674 "(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
|
675 |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
676 shift->setStyleSheet |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
677 ("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
|
678 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
679 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
|
680 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
681 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
|
682 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
683 box->addWidget (direct); |
26830
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
684 box->addWidget (shift); |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
685 |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
686 box->addSpacing (15); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
687 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
688 QGridLayout *grid = new QGridLayout (); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
689 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
690 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
|
691 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
|
692 m_edit_actual->setAlignment (Qt::AlignHCenter); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
693 grid->addWidget (actual, 0, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
694 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
|
695 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
696 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
|
697 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
|
698 m_label_default->setAlignment (Qt::AlignHCenter); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
699 grid->addWidget (def, 1, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
700 grid->addWidget (m_label_default, 1, 1); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
701 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
702 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
|
703 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
|
704 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
|
705 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
|
706 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
707 box->addLayout (grid); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
708 |
26830
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
709 box->addSpacing (18); |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
710 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
711 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
|
712 | QDialogButtonBox::Cancel); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
713 QList<QAbstractButton *> buttons = button_box->buttons (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
714 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
|
715 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
|
716 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
|
717 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
|
718 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
|
719 m_dialog, &QDialog::reject); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
720 box->addWidget (button_box); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
721 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
722 m_dialog->setLayout (box); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
723 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
724 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
|
725 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
|
726 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
|
727 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
|
728 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
|
729 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
|
730 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
731 } |
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 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
|
734 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
|
735 m_handled_index = index; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
736 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
737 m_edit_actual->setFocus (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
738 m_dialog->setFocusProxy (m_edit_actual); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
739 m_dialog->exec (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
740 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
741 |
31618
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
742 // 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
|
743 // tree view |
31619
ad014fc78bd6
use individual local gui_settings objects
John W. Eaton <jwe@octave.org>
parents:
31618
diff
changeset
|
744 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
|
745 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
746 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
|
747 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
748 // 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
|
749 |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
750 // make a copy |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
751 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
|
752 |
31618
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
753 // 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
|
754 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
|
755 |
31618
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
756 // 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
|
757 m_sc.replace (i, sc); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
758 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
759 // 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
|
760 // get related tree item |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
761 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
|
762 |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
763 // display new shortcut |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
764 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
|
765 } |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
766 } |
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 // 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
|
769 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
|
770 { |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
771 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
|
772 { |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
773 // 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
|
774 |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
775 // make a copy |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
776 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
|
777 |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
778 // get default shortcut |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
779 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
|
780 |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
781 // 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
|
782 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
|
783 |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
784 // update the tree view |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
785 // get related tree item |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
786 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
|
787 |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
788 // display new shortcut |
cd833a9baaa7
use separate functions for importing and resetting default shortcuts
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
789 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
|
790 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
791 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
792 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
793 // 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
|
794 // 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
|
795 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
|
796 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
797 QMessageBox msg_box; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
798 msg_box.setWindowTitle (tr ("Overwriting Shortcuts")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
799 msg_box.setIcon (QMessageBox::Warning); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
800 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
|
801 "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
|
802 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
|
803 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
|
804 QMessageBox::DestructiveRole); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
805 msg_box.setDefaultButton (QMessageBox::Save); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
806 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
807 int ret = msg_box.exec (); |
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 if (msg_box.clickedButton () == discard) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
810 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
|
811 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
812 if (ret == QMessageBox::Save) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
813 { |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
814 if (import_export (OSC_EXPORT)) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
815 return true; // go ahead |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
816 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
817 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
818 return false; // abort the import |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
819 } |
31646
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
820 |
c6d54dd31a7e
maint: Use macros to begin/end C++ namespaces.
John W. Eaton <jwe@octave.org>
parents:
31433
diff
changeset
|
821 OCTAVE_END_NAMESPACE(octave) |