Mercurial > octave
annotate libgui/src/shortcut-manager.cc @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | db045364dca9 |
children | d17ee5e7b66c |
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 |
27629
8b6e928e0705
in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
45 #include "octave-qobject.h" |
27412
da1f59fe04b3
try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27330
diff
changeset
|
46 #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
|
47 #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
|
48 #include "gui-preferences-sc.h" |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
49 #include "error.h" |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
50 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
51 namespace octave |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
52 { |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
53 // enter_shortcut: |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
54 // class derived from QLineEdit for directly entering key sequences which |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
55 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
56 enter_shortcut::enter_shortcut (QWidget *p) : QLineEdit (p) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
57 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
58 m_direct_shortcut = true; // the shortcut is directly entered |
26830
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
59 m_shift_modifier = false; // the shift modifier is not added |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
60 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
61 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
62 // new keyPressEvent |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
63 void enter_shortcut::keyPressEvent (QKeyEvent *e) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
64 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
65 if (! m_direct_shortcut) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
66 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
67 QLineEdit::keyPressEvent (e); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
68 return; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
69 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
70 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
71 if (e->type () == QEvent::KeyPress) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
72 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
73 int key = e->key (); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
74 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
75 if (key == Qt::Key_unknown || key == 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
76 return; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
77 |
26830
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
78 Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers (); //e->modifiers (); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
79 |
26830
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
80 if (m_shift_modifier || (modifiers & Qt::ShiftModifier)) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
81 key += Qt::SHIFT; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
82 if (modifiers & Qt::ControlModifier) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
83 key += Qt::CTRL; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
84 if (modifiers & Qt::AltModifier) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
85 key += Qt::ALT; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
86 if (modifiers & Qt::MetaModifier) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
87 key += Qt::META; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
88 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
89 setText (QKeySequence (key).toString ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
90 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
91 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
92 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
93 // slot for checkbox whether the shortcut is directly entered or not |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
94 void enter_shortcut::handle_direct_shortcut (int state) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
95 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
96 if (state) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
97 m_direct_shortcut = true; // the shortcut is directly entered |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
98 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
99 m_direct_shortcut = false; // the shortcut has to be written as text |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
100 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
101 |
26830
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
102 // slot for checkbox whether the shift modifier should be added |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
103 void enter_shortcut::handle_shift_modifier (int state) |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
104 { |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
105 if (state) |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
106 m_shift_modifier = true; // the shortcut is directly entered |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
107 else |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
108 m_shift_modifier = false; // the shortcut has to be written as text |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
109 } |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
110 |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
111 |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
112 shortcut_manager::shortcut_manager (base_qobject& oct_qobj) |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
113 : m_octave_qobj (oct_qobj) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
114 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
115 setObjectName ("Shortcut_Manager"); |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19251
diff
changeset
|
116 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
117 // 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
|
118 #if defined (Q_OS_MAC) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
119 QCoreApplication::setAttribute (Qt::AA_MacDontSwapCtrlAndMeta, true); |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
120 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
121 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
122 |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
123 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
|
124 { |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
125 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
126 gui_settings *settings = rmgr.get_settings (); |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
127 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
128 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
|
129 |
27937
8dc5b36f1245
include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
130 // 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
|
131 |
8dc5b36f1245
include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
132 // dock widgets |
8dc5b36f1245
include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
133 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
|
134 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
|
135 |
8dc5b36f1245
include new undock/dock actions into the shortcut manager
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27935
diff
changeset
|
136 // 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
|
137 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
138 // file |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
139 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
|
140 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
|
141 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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
147 // edit |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
148 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
|
149 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
|
150 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
|
151 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
|
152 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
|
153 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
|
154 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
|
155 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
|
156 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
|
157 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
|
158 init (tr ("Preferences"), sc_main_edit_preferences); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
159 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
160 // debug |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
161 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
|
162 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
|
163 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
|
164 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
|
165 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
|
166 |
29068
d8089b13d4d7
add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
167 // tools |
d8089b13d4d7
add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents:
28499
diff
changeset
|
168 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
|
169 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
|
170 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
|
171 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
172 // window |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
173 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
|
174 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
|
175 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
|
176 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
|
177 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
|
178 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 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
|
188 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
|
189 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
190 // help |
30432
db045364dca9
Fixed typos before string freeze
Torsten Lilge <ttl-octave@mailbox.org>
parents:
30398
diff
changeset
|
191 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
|
192 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
|
193 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
|
194 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
|
195 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
|
196 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
|
197 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
|
198 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
199 // news |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
200 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
|
201 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
|
202 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
203 // Tab handling |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27860
diff
changeset
|
204 // 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
|
205 // 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
214 // Zooming |
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 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
|
216 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
|
217 #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
|
218 init (tr ("Zoom Normal"), sc_edit_view_zoom_normal); |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
219 #else |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
220 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
|
221 #endif |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
222 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
223 // 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
|
224 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
225 // file |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
226 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
|
227 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
|
228 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
|
229 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
|
230 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
231 // edit |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
232 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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 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
|
247 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
248 init (tr ("Comment Selection"), 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
|
249 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
|
250 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
|
251 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
|
252 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
|
253 |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
254 #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
|
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 #else |
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 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
|
259 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
|
260 #endif |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
261 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
|
262 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
263 init (tr ("Convert Line Endings to 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
|
264 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
|
265 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
|
266 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
267 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
|
268 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
|
269 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
|
270 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
|
271 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
|
272 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
|
273 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
|
274 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
275 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
|
276 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
|
277 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
278 // view |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
279 init (tr ("Show Line 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
|
280 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
|
281 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
|
282 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
|
283 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
|
284 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
|
285 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
|
286 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
|
287 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
|
288 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
289 // debug |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
290 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
|
291 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
|
292 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
|
293 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
|
294 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
295 // run |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
296 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
|
297 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
|
298 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
299 // help |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
300 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
|
301 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
|
302 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
303 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
304 // Documentation browser |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
305 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
|
306 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
|
307 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
|
308 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
|
309 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
310 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
311 // write one or all actual shortcut set(s) into a settings file |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
312 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
|
313 bool closing) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
314 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
315 bool sc_ctrld = false; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
316 |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
317 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
|
318 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
319 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
|
320 { |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
321 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
|
322 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
|
323 // 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
|
324 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
|
325 && 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
|
326 sc_ctrld = true; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
327 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
328 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
329 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
|
330 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
331 if (closing) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
332 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
333 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
|
334 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
|
335 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
336 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
337 settings->sync (); // sync the settings file |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
338 } |
20987
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20986
diff
changeset
|
339 |
29206
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
340 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
|
341 bool enable) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
342 { |
29206
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
343 if (! enable) |
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 // 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
|
346 action->setShortcut (QKeySequence ()); |
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
347 return; |
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
348 } |
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
349 |
a0a892829b6d
fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents:
29068
diff
changeset
|
350 // 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
|
351 // 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
|
352 int index; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
353 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
354 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
|
355 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
356 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
|
357 { |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
358 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
359 gui_settings *settings = rmgr.get_settings (); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
360 action->setShortcut (QKeySequence (settings->sc_value (scpref))); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
361 } |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
362 else |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
363 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
|
364 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
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 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
|
367 { |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
368 int index; |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
369 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
370 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
|
371 |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
372 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
|
373 { |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
374 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
375 gui_settings *settings = rmgr.get_settings (); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
376 sc->setKey (QKeySequence (settings->sc_value (scpref))); |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
377 } |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
378 else |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
379 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
|
380 } |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
381 |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
382 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
|
383 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
384 m_dialog = nullptr; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
385 m_level_hash.clear (); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
386 |
24827
1e0718c1867c
eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents:
24724
diff
changeset
|
387 tree_view->header ()->setSectionResizeMode (QHeaderView::ResizeToContents); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
388 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
389 QTreeWidgetItem *main = new QTreeWidgetItem (tree_view); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
390 main->setText (0, tr ("Global")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
391 main->setExpanded (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
392 QTreeWidgetItem *main_file = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
393 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
|
394 QTreeWidgetItem *main_edit = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
395 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
|
396 QTreeWidgetItem *main_debug = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
397 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
|
398 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
|
399 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
|
400 QTreeWidgetItem *main_window = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
401 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
|
402 QTreeWidgetItem *main_help = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
403 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
|
404 QTreeWidgetItem *main_news = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
405 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
|
406 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
|
407 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
|
408 QTreeWidgetItem *main_tabs = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
409 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
|
410 QTreeWidgetItem *main_find = new QTreeWidgetItem (main); |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
411 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
|
412 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
|
413 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
|
414 |
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_file] = main_file; |
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_edit] = main_edit; |
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_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
|
418 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
|
419 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
|
420 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
|
421 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
|
422 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
|
423 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
|
424 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
|
425 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
|
426 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
427 QTreeWidgetItem *editor = new QTreeWidgetItem (tree_view); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
428 editor->setText (0, tr ("Editor")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
429 editor->setExpanded (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
430 QTreeWidgetItem *editor_file = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
431 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
|
432 QTreeWidgetItem *editor_edit = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
433 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
|
434 QTreeWidgetItem *editor_view = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
435 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
|
436 QTreeWidgetItem *editor_debug = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
437 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
|
438 QTreeWidgetItem *editor_run = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
439 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
|
440 QTreeWidgetItem *editor_help = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
441 editor_help->setText (0, tr ("Help Menu")); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
442 |
27818
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_file] = editor_file; |
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_edit] = editor_edit; |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
445 m_level_hash[sc_edit_view] = editor_view; |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
446 m_level_hash[sc_edit_debug] = editor_debug; |
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
447 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
|
448 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
|
449 |
26017
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 = 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
|
451 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
|
452 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
|
453 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
454 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
|
455 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
|
456 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
457 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
|
458 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
459 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
|
460 this, &shortcut_manager::handle_double_clicked); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
461 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
462 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
|
463 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
464 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
|
465 |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29542
diff
changeset
|
466 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
|
467 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
468 // 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
|
469 // previously defined keyname |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
470 if (section == editor_file) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
471 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
472 // 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
|
473 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
|
474 section = main_tabs; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
475 } |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
476 if (section == editor_edit) |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
477 { |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
478 // 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
|
479 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
|
480 section = main_find; |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
481 } |
25976
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
482 if (section == editor_view) |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
483 { |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
484 // 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
|
485 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
|
486 section = main_zoom; |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
487 } |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
488 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
489 QTreeWidgetItem *tree_item = new QTreeWidgetItem (section); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
490 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
491 // 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
|
492 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
|
493 fg.setAlpha (128); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
494 tree_item->setForeground (1, QBrush (fg)); |
18728
95249367d6fa
provide a second set of shortcuts
Torsten <ttl@justmail.de>
parents:
18711
diff
changeset
|
495 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
496 // write the shortcuts |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
497 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
|
498 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
|
499 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
|
500 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
501 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
|
502 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
|
503 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
504 } |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
505 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
506 // import or export of shortcut sets, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
507 // 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
|
508 // returns true on success, false otherwise |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
509 bool |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
510 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
|
511 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
512 // 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
|
513 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
|
514 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
515 if (! overwrite_all_shortcuts ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
516 return false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
517 } |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
518 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
519 // 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
|
520 // 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
|
521 if (action != OSC_DEFAULT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
522 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
523 QString file; |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
524 |
26096
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26017
diff
changeset
|
525 // 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
|
526 int opts = 0; // No options by default. |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
527 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
528 gui_settings *settings = rmgr.get_settings (); |
28497
2813ac10ca1e
force non-native file dialogs on Mac ignoring current user pref (bug #52840)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27937
diff
changeset
|
529 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
|
530 opts = QFileDialog::DontUseNativeDialog; |
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26017
diff
changeset
|
531 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
532 if (action == OSC_IMPORT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
533 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
|
534 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
|
535 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
|
536 nullptr, QFileDialog::Option (opts)); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
537 else if (action == OSC_EXPORT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
538 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
|
539 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
|
540 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
|
541 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
|
542 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
543 if (file.isEmpty ()) |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
544 return false; |
18822
3f6280d0a36b
allow export and import of shortcut sets
Torsten <ttl@justmail.de>
parents:
18728
diff
changeset
|
545 |
27611
0495b64288f7
use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
546 gui_settings osc_settings (file, QSettings::IniFormat); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
547 |
26635
931ace437d5d
fix possible memleak by avoiding bare poointer (bug #55440)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
548 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
|
549 { |
25163
3aed4f0ba3cd
Update some GUI strings identified as unclear by translators.
Rik <rik@octave.org>
parents:
25128
diff
changeset
|
550 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
|
551 .arg (file); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
552 return false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
553 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
554 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
555 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
556 if (action == OSC_IMPORT) |
26635
931ace437d5d
fix possible memleak by avoiding bare poointer (bug #55440)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
557 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
|
558 else if (action == OSC_EXPORT) |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
559 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
|
560 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
561 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
562 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
563 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
564 import_shortcuts (nullptr); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
565 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
566 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
567 return true; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
568 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
569 |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
570 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
|
571 { |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
572 if (col != 2) |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
573 return; |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
574 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
575 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
|
576 if (i == 0) |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
577 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
|
578 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
579 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
|
580 } |
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 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
|
583 { |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
584 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
|
585 return; |
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 // check for duplicate |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
588 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
|
589 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
590 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
|
591 { |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
592 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
|
593 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
|
594 "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
|
595 "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
|
596 "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
|
597 .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
|
598 .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
|
599 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
|
600 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
601 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
|
602 { |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
603 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
|
604 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
|
605 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
|
606 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
|
607 } |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
608 else |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
609 return; |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
610 } |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
611 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
612 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
|
613 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
|
614 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
|
615 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
|
616 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
|
617 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
618 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
|
619 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
620 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
|
621 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
|
622 } |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
623 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
624 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
|
625 { |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
626 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
|
627 } |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
628 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
629 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
|
630 { |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
631 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
632 gui_settings *settings = rmgr.get_settings (); |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
633 |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
634 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
|
635 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
636 // 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
|
637 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
|
638 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
|
639 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
|
640 shortcut_info.m_actual_sc = actual; |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
641 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
|
642 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
|
643 |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27860
diff
changeset
|
644 // 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
|
645 if (! actual.isEmpty ()) |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
646 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
|
647 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
|
648 |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
649 // 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
|
650 QString main_group_prefix |
27935
f1844e33f621
maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
651 = 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
|
652 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
|
653 && actual == QKeySequence (Qt::ControlModifier+Qt::Key_D)) |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
654 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
|
655 } |
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
656 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
657 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
|
658 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
659 if (! m_dialog) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
660 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
661 m_dialog = new QDialog (this); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
662 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
663 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
|
664 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
665 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
|
666 box->setSpacing (2); |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
667 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
|
668 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
669 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
|
670 "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
|
671 "shortcut to its default.")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
672 help->setWordWrap (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
673 box->addWidget (help); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
674 |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
675 QCheckBox *direct |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
676 = 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
|
677 |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
678 QCheckBox *shift |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
679 = new QCheckBox (tr ("Add Shift modifier\n" |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
680 "(allows to enter number keys)")); |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
681 |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
682 shift->setStyleSheet |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26885
diff
changeset
|
683 ("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
|
684 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
685 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
|
686 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
687 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
|
688 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
689 box->addWidget (direct); |
26830
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
690 box->addWidget (shift); |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
691 |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
692 box->addSpacing (15); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
693 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
694 QGridLayout *grid = new QGridLayout (); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
695 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
696 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
|
697 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
|
698 m_edit_actual->setAlignment (Qt::AlignHCenter); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
699 grid->addWidget (actual, 0, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
700 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
|
701 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
702 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
|
703 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
|
704 m_label_default->setAlignment (Qt::AlignHCenter); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
705 grid->addWidget (def, 1, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
706 grid->addWidget (m_label_default, 1, 1); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
707 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
708 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
|
709 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
|
710 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
|
711 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
|
712 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
713 box->addLayout (grid); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
714 |
26830
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
715 box->addSpacing (18); |
e255897f353d
gui: allow entering shorcuts with shift modifier and numbers (bug #50555)
Torsten <mttl@mailbox.org>
parents:
26638
diff
changeset
|
716 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
717 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
|
718 | QDialogButtonBox::Cancel); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
719 QList<QAbstractButton *> buttons = button_box->buttons (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
720 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
|
721 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
|
722 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
|
723 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
|
724 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
|
725 m_dialog, &QDialog::reject); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
726 box->addWidget (button_box); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
727 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
728 m_dialog->setLayout (box); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
729 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
730 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
|
731 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
|
732 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
|
733 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
|
734 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
|
735 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
|
736 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
737 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
738 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
739 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
|
740 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
|
741 m_handled_index = index; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
742 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
743 m_edit_actual->setFocus (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
744 m_dialog->setFocusProxy (m_edit_actual); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
745 m_dialog->exec (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
746 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
747 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
748 // import a shortcut set from a given settings file or reset to |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
749 // the defaults (settings = 0) and refresh the tree view |
27611
0495b64288f7
use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
27412
diff
changeset
|
750 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
|
751 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
752 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
|
753 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
754 // update the list of all shortcuts |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
755 shortcut_t sc = m_sc.at (i); // make a copy |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
756 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
757 if (settings) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
758 sc.m_actual_sc = QKeySequence ( // get new shortcut from settings |
27818
fa0582694fda
replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27805
diff
changeset
|
759 settings->value (sc_group + sc.m_settings_key,sc.m_actual_sc). |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
760 toString ()); // and use the old one as default |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
761 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
762 sc.m_actual_sc = QKeySequence (sc.m_default_sc); // get default shortcut |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
763 |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29542
diff
changeset
|
764 m_sc.replace (i, sc); // replace the old with the new one |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
765 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
766 // update the tree view |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
767 QTreeWidgetItem *tree_item = m_index_item_hash[i]; // get related tree item |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
768 tree_item->setText (2, sc.m_actual_sc.toString ()); // display new shortcut |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
769 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
770 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
771 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
772 // 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
|
773 // 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
|
774 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
|
775 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
776 QMessageBox msg_box; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
777 msg_box.setWindowTitle (tr ("Overwriting Shortcuts")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
778 msg_box.setIcon (QMessageBox::Warning); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
779 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
|
780 "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
|
781 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
|
782 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
|
783 QMessageBox::DestructiveRole); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
784 msg_box.setDefaultButton (QMessageBox::Save); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
785 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
786 int ret = msg_box.exec (); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
787 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
788 if (msg_box.clickedButton () == discard) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
789 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
|
790 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
791 if (ret == QMessageBox::Save) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
792 { |
27630
262cdd0f7619
don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27629
diff
changeset
|
793 if (import_export (OSC_EXPORT)) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
794 return true; // go ahead |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
795 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
796 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
797 return false; // abort the import |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
798 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
799 } |