Mercurial > octave
annotate libgui/src/shortcut-manager.cc @ 25371:41bbdf17f51a
make shortcuts for searching within the documentation configurable
* documentation.cc: include shortcut-manager.h,
(documentation): use class variables for the shortcuts;
(notice_settings): get the configured shortcuts via shortcut manager;
* documentation.h: include QShortcut, new class variables for the used
shortcuts
* shortcut-manager.cc (do_shortcut): new method for reading a shortcut
from the settings file;
(do_fill_treewidget): create a new section for shortcuts for searching
in dock widgets, put editor find shortcuts into this new section;
* shortcut-manager.h (shortcut): new static method, calling new method
do_shortcut
author | Torsten <mttl@mailbox.org> |
---|---|
date | Sun, 13 May 2018 10:07:54 +0200 |
parents | d2558ba799d8 |
children | cfdc768b661c |
rev | line source |
---|---|
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
1 /* |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
2 |
25054
6652d3823428
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
24827
diff
changeset
|
3 Copyright (C) 2014-2018 Torsten <ttl@justmail.de> |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
4 |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
5 This file is part of Octave. |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
6 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24484
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22587
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24484
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22587
diff
changeset
|
10 (at your option) any later version. |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22587
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22587
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22587
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22587
diff
changeset
|
15 GNU General Public License for more details. |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
16 |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24484
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
20 |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
21 */ |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
22 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21568
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
24 # include "config.h" |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
25 #endif |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
26 |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
27 #include <QtCore> |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
28 #include <QMessageBox> |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
29 #include <QDebug> |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
30 #include <QGridLayout> |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
31 #include <QVBoxLayout> |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
32 #include <QDialogButtonBox> |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
33 #include <QKeySequence> |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
34 #include <QPushButton> |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
35 #include <QLineEdit> |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
36 #include <QCheckBox> |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
37 #include <QHeaderView> |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
38 #include <QAction> |
18822
3f6280d0a36b
allow export and import of shortcut sets
Torsten <ttl@justmail.de>
parents:
18728
diff
changeset
|
39 #include <QFileDialog> |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
40 |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
41 #include "error.h" |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
42 #include "resource-manager.h" |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
43 #include "shortcut-manager.h" |
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
44 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
45 namespace octave |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
46 { |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
47 // enter_shortcut: |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
48 // 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
|
49 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
50 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
|
51 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
52 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
|
53 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
54 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
55 // new keyPressEvent |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
56 void enter_shortcut::keyPressEvent (QKeyEvent *e) |
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 if (! m_direct_shortcut) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
59 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
60 QLineEdit::keyPressEvent (e); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
61 return; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
62 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
63 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
64 if (e->type () == QEvent::KeyPress) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
65 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
66 int key = e->key (); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
67 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
68 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
|
69 return; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
70 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
71 Qt::KeyboardModifiers modifiers = e->modifiers (); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
72 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
73 if (modifiers & Qt::ShiftModifier) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
74 key += Qt::SHIFT; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
75 if (modifiers & Qt::ControlModifier) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
76 key += Qt::CTRL; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
77 if (modifiers & Qt::AltModifier) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
78 key += Qt::ALT; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
79 if (modifiers & Qt::MetaModifier) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
80 key += Qt::META; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
81 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
82 setText (QKeySequence (key).toString ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
83 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
84 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
85 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
86 // 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
|
87 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
|
88 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
89 if (state) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
90 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
|
91 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
92 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
|
93 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
94 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
95 shortcut_manager *shortcut_manager::instance = nullptr; |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
96 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
97 shortcut_manager::shortcut_manager (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
98 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
99 setObjectName ("Shortcut_Manager"); |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19251
diff
changeset
|
100 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
101 // 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
|
102 #if defined (Q_OS_MAC) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
103 QCoreApplication::setAttribute (Qt::AA_MacDontSwapCtrlAndMeta, true); |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
104 #endif |
18656
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18631
diff
changeset
|
105 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
106 m_settings = resource_manager::get_settings (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
107 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
108 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
109 void shortcut_manager::handle_double_clicked (QTreeWidgetItem *item, int col) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
110 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
111 if (col != 2) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
112 return; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
113 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
114 int i = m_item_index_hash[item]; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
115 if (i == 0) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
116 return; // top-level-item clicked |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
117 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
118 shortcut_dialog (i-1); // correct to index starting at 0 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
119 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
120 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
121 void shortcut_manager::shortcut_dialog_finished (int result) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
122 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
123 if (result == QDialog::Rejected) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
124 return; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
125 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
126 // check for duplicate |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
127 int double_index = m_shortcut_hash[m_edit_actual->text ()] - 1; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
128 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
129 if (double_index >= 0 && double_index != m_handled_index) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
130 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
131 int ret = QMessageBox::warning (this, tr ("Double Shortcut"), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
132 tr ("The chosen shortcut\n \"%1\"\n" |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
133 "is already used for the action\n \"%2\".\n" |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
134 "Do you want to use the shortcut anyhow removing it " |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
135 "from the previous action?") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
136 .arg (m_edit_actual->text ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
137 .arg (m_sc.at (double_index).m_description), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
138 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
139 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
140 if (ret == QMessageBox::Yes) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
141 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
142 shortcut_t double_shortcut = m_sc.at (double_index); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
143 double_shortcut.m_actual_sc = QKeySequence (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
144 m_sc.replace (double_index, double_shortcut); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
145 m_index_item_hash[double_index]->setText (2, QString ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
146 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
147 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
148 return; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
149 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
150 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
151 shortcut_t shortcut = m_sc.at (m_handled_index); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
152 if (! shortcut.m_actual_sc.isEmpty ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
153 m_shortcut_hash.remove (shortcut.m_actual_sc.toString ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
154 shortcut.m_actual_sc = m_edit_actual->text (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
155 m_sc.replace (m_handled_index, shortcut); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
156 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
157 m_index_item_hash[m_handled_index]->setText (2, shortcut.m_actual_sc.toString ()); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
158 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
159 if (! shortcut.m_actual_sc.isEmpty ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
160 m_shortcut_hash[shortcut.m_actual_sc.toString ()] = m_handled_index + 1; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
161 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
162 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
163 void shortcut_manager::shortcut_dialog_set_default (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
164 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
165 m_edit_actual->setText (m_label_default->text ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
166 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
167 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
168 bool shortcut_manager::instance_ok (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
169 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
170 bool retval = true; |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
171 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
172 if (! instance) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
173 instance = new shortcut_manager (); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
174 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
175 if (! instance) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
176 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
177 error ("unable to create shortcut_manager object!"); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
178 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
179 retval = false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
180 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
181 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
182 return retval; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
183 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
184 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
185 void shortcut_manager::init (const QString& description, const QString& key, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
186 const QKeySequence& def_sc) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
187 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
188 QKeySequence actual |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
189 = QKeySequence (m_settings->value ("shortcuts/" + key, def_sc).toString ()); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
190 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
191 // append the new shortcut to the list |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
192 shortcut_t shortcut_info; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
193 shortcut_info.m_description = description; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
194 shortcut_info.m_settings_key = key; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
195 shortcut_info.m_actual_sc = actual; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
196 shortcut_info.m_default_sc = def_sc; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
197 m_sc << shortcut_info; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
198 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
199 // insert shortcut in order check for duplicates later |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
200 if (! actual.isEmpty ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
201 m_shortcut_hash[actual.toString ()] = m_sc.count (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
202 m_action_hash[key] = m_sc.count (); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
203 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
204 // check whether ctrl+d is used from main window, i.e. is a global shortcut |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
205 if (key.startsWith ("main_") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
206 && actual == QKeySequence (Qt::ControlModifier+Qt::Key_D)) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
207 m_settings->setValue ("shortcuts/main_ctrld",true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
208 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
209 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
210 void shortcut_manager::do_init_data (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
211 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
212 Qt::KeyboardModifier ctrl; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
213 int prefix; |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
214 #if defined (Q_OS_MAC) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
215 // Use CMD key as an equivalent of Ctrl key on other platforms |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
216 ctrl = Qt::MetaModifier; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
217 // Some of octave default shortcuts on windows/linux are already defined |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
218 // as system wide shortcuts on Mac Os X (almost all Function keys). |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
219 // Prefix those with Option (Alt) modifier to avoid conflicts. |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
220 prefix = Qt::AltModifier; |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
221 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
222 ctrl = Qt::ControlModifier; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
223 prefix = Qt::NoModifier; |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
224 #endif |
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
225 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
226 Qt::KeyboardModifiers ctrl_shift = ctrl | Qt::ShiftModifier; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
227 Qt::KeyboardModifiers ctrl_alt = ctrl | Qt::AltModifier; |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19251
diff
changeset
|
228 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
229 // actions of the main window |
18665
777281eeb3d4
add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
230 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
231 m_settings->setValue ("shortcuts/main_ctrld",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
|
232 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
233 // file |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
234 init (tr ("New File"), "main_file:new_file", QKeySequence::New); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
235 init (tr ("New Function"), "main_file:new_function", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
236 QKeySequence (ctrl_shift + Qt::Key_N)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
237 init (tr ("New Figure"), "main_file:new_figure", QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
238 init (tr ("Open File"), "main_file:open_file", QKeySequence::Open); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
239 init (tr ("Load Workspace"), "main_file:load_workspace", QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
240 init (tr ("Save Workspace As"), "main_file:save_workspace", QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
241 init (tr ("Exit Octave"), "main_file:exit", QKeySequence::Quit); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
242 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
243 // edit |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
244 init (tr ("Copy"), "main_edit:copy", QKeySequence::Copy); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
245 init (tr ("Paste"), "main_edit:paste", QKeySequence::Paste); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
246 init (tr ("Undo"), "main_edit:undo", QKeySequence::Undo); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
247 init (tr ("Select All"), "main_edit:select_all", QKeySequence::SelectAll); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
248 init (tr ("Clear Clipboard"), "main_edit:clear_clipboard", QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
249 init (tr ("Find in Files"), "main_edit:find_in_files", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
250 QKeySequence (ctrl_shift + Qt::Key_F)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
251 init (tr ("Clear Command Window"), "main_edit:clear_command_window", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
252 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
253 init (tr ("Clear Command History"), "main_edit:clear_history", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
254 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
255 init (tr ("Clear Workspace"), "main_edit:clear_workspace", QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
256 init (tr ("Preferences"), "main_edit:preferences", QKeySequence ()); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
257 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
258 // debug |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
259 init (tr ("Step"), "main_debug:step_over", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
260 QKeySequence (prefix + Qt::Key_F10)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
261 init (tr ("Step Into"), "main_debug:step_into", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
262 QKeySequence (prefix + Qt::Key_F11)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
263 init (tr ("Step Out"), "main_debug:step_out", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
264 QKeySequence (prefix + Qt::ShiftModifier + Qt::Key_F11)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
265 init (tr ("Continue"), "main_debug:continue", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
266 QKeySequence (prefix + Qt::Key_F5)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
267 init (tr ("Quit Debug Mode"), "main_debug:quit", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
268 QKeySequence (prefix + Qt::ShiftModifier + Qt::Key_F5)); |
18697
908523bd79b4
use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents:
18685
diff
changeset
|
269 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
270 // window |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
271 init (tr ("Show Command Window"), "main_window:show_command", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
272 prefix + ctrl_shift + Qt::Key_0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
273 init (tr ("Show Command History"), "main_window:show_history", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
274 prefix + ctrl_shift + Qt::Key_1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
275 init (tr ("Show File Browser"), "main_window:show_file_browser", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
276 prefix + ctrl_shift + Qt::Key_2); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
277 init (tr ("Show Workspace"), "main_window:show_workspace", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
278 prefix + ctrl_shift + Qt::Key_3); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
279 init (tr ("Show Editor"), "main_window:show_editor", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
280 prefix + ctrl_shift + Qt::Key_4); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
281 init (tr ("Show Documentation"), "main_window:show_doc", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
282 prefix + ctrl_shift + Qt::Key_5); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
283 init (tr ("Show Variable Editor"), "main_window:show_variable_editor", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
284 prefix + ctrl_shift + Qt::Key_6); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
285 init (tr ("Command Window"), "main_window:command", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
286 prefix + ctrl + Qt::Key_0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
287 init (tr ("Command History"), "main_window:history", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
288 prefix + ctrl + Qt::Key_1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
289 init (tr ("File Browser"), "main_window:file_browser", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
290 prefix + ctrl + Qt::Key_2); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
291 init (tr ("Workspace"), "main_window:workspace", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
292 prefix + ctrl + Qt::Key_3); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
293 init (tr ("Editor"), "main_window:editor", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
294 prefix + ctrl + Qt::Key_4); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
295 init (tr ("Documentation"), "main_window:doc", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
296 prefix + ctrl + Qt::Key_5); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
297 init (tr ("Variable Editor"), "main_window:variable_editor", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
298 prefix + ctrl + Qt::Key_6); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
299 init (tr ("Reset Default Window Layout"), "main_window:reset", QKeySequence ()); |
18707
f31fde98c872
use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents:
18697
diff
changeset
|
300 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
301 // help |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
302 init (tr ("Show Ondisk Documentation"), "main_help:ondisk_doc", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
303 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
304 init (tr ("Show Online Documentation"), "main_help:online_doc", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
305 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
306 init (tr ("Report Bug"), "main_help:report_bug", QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
307 init (tr ("Octave Packages"), "main_help:packages", QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
308 init (tr ("Contribute to Octave"), "main_help:contribute", QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
309 init (tr ("Octave Developer Resources"), "main_help:developer", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
310 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
311 init (tr ("About Octave"), "main_help:about", QKeySequence ()); |
18710
584b20e9112c
use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents:
18707
diff
changeset
|
312 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
313 // news |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
314 init (tr ("Release Notes"), "main_news:release_notes", QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
315 init (tr ("Community News"), "main_news:community_news", QKeySequence ()); |
18711
9ef65c422f53
use shortcut manager for the main news menu
Torsten <ttl@justmail.de>
parents:
18710
diff
changeset
|
316 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
317 // Tab handling |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
318 // The following shortcuts are moved into a separate tab. The key names |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
319 // are not change for preserving compatibility with older versions |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
320 init (tr ("Close Tab"), "editor_file:close", QKeySequence::Close); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
321 init (tr ("Close All Tabs"), "editor_file:close_all", QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
322 init (tr ("Close Other Tabs"), "editor_file:close_other", QKeySequence ()); |
24724
fa60be0abc21
add tab move and switch shortcuts to the doc browser
Torsten <mttl@mailbox.org>
parents:
24718
diff
changeset
|
323 init (tr ("Switch to Left Tab"), "editor_tabs:switch_left_tab", |
fa60be0abc21
add tab move and switch shortcuts to the doc browser
Torsten <mttl@mailbox.org>
parents:
24718
diff
changeset
|
324 QKeySequence (ctrl + Qt::Key_PageUp)); |
fa60be0abc21
add tab move and switch shortcuts to the doc browser
Torsten <mttl@mailbox.org>
parents:
24718
diff
changeset
|
325 init (tr ("Switch to Right Tab"), "editor_tabs:switch_right_tab", |
fa60be0abc21
add tab move and switch shortcuts to the doc browser
Torsten <mttl@mailbox.org>
parents:
24718
diff
changeset
|
326 QKeySequence (ctrl + Qt::Key_PageDown)); |
fa60be0abc21
add tab move and switch shortcuts to the doc browser
Torsten <mttl@mailbox.org>
parents:
24718
diff
changeset
|
327 init (tr ("Move Tab Left"), "editor_tabs:move_tab_left", |
fa60be0abc21
add tab move and switch shortcuts to the doc browser
Torsten <mttl@mailbox.org>
parents:
24718
diff
changeset
|
328 QKeySequence (Qt::AltModifier + Qt::Key_PageUp)); |
fa60be0abc21
add tab move and switch shortcuts to the doc browser
Torsten <mttl@mailbox.org>
parents:
24718
diff
changeset
|
329 init (tr ("Move Tab Right"), "editor_tabs:move_tab_right", |
fa60be0abc21
add tab move and switch shortcuts to the doc browser
Torsten <mttl@mailbox.org>
parents:
24718
diff
changeset
|
330 QKeySequence (Qt::AltModifier + Qt::Key_PageDown)); |
24712
95815fc93a3a
move shortcuts for tab closing into a separate global settings-section
Torsten <mttl@mailbox.org>
parents:
24534
diff
changeset
|
331 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
332 // 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
|
333 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
334 // file |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
335 init (tr ("Edit Function"), "editor_file:edit_function", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
336 QKeySequence (ctrl + Qt::Key_E)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
337 init (tr ("Save File"), "editor_file:save", QKeySequence::Save); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
338 init (tr ("Save File As"), "editor_file:save_as", QKeySequence::SaveAs); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
339 init (tr ("Print"), "editor_file:print", QKeySequence::Print); |
18624
a827fc5fe59d
handle actions from the editors file and edit menu via the shortcut manager
Torsten <ttl@justmail.de>
parents:
18611
diff
changeset
|
340 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
341 // edit |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
342 init (tr ("Redo"), "editor_edit:redo", QKeySequence::Redo); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
343 init (tr ("Cut"), "editor_edit:cut", QKeySequence::Cut); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
344 init (tr ("Find and Replace"), "editor_edit:find_replace", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
345 QKeySequence::Find); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
346 init (tr ("Find Next"), "editor_edit:find_next", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
347 QKeySequence::FindNext); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
348 init (tr ("Find Previous"), "editor_edit:find_previous", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
349 QKeySequence::FindPrevious); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
350 init (tr ("Delete to Start of Word"), "editor_edit:delete_start_word", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
351 QKeySequence::DeleteStartOfWord); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
352 init (tr ("Delete to End of Word"), "editor_edit:delete_end_word", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
353 QKeySequence::DeleteEndOfWord); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
354 init (tr ("Delete to Start of Line"), "editor_edit:delete_start_line", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
355 QKeySequence (ctrl_shift + Qt::Key_Backspace)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
356 init (tr ("Delete to End of Line"), "editor_edit:delete_end_line", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
357 QKeySequence (ctrl_shift + Qt::Key_Delete)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
358 init (tr ("Delete Line"), "editor_edit:delete_line", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
359 QKeySequence (ctrl_shift + Qt::Key_L)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
360 init (tr ("Copy Line"), "editor_edit:copy_line", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
361 QKeySequence (ctrl_shift + Qt::Key_C)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
362 init (tr ("Cut Line"), "editor_edit:cut_line", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
363 QKeySequence (ctrl_shift + Qt::Key_X)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
364 init (tr ("Duplicate Selection/Line"), "editor_edit:duplicate_selection", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
365 QKeySequence (ctrl + Qt::Key_D)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
366 init (tr ("Transpose Line"), "editor_edit:transpose_line", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
367 QKeySequence (ctrl + Qt::Key_T)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
368 init (tr ("Show Completion List"), "editor_edit:completion_list", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
369 QKeySequence (ctrl + Qt::Key_Space)); |
18656
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18631
diff
changeset
|
370 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
371 init (tr ("Comment Selection"), "editor_edit:comment_selection", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
372 QKeySequence (ctrl + Qt::Key_R)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
373 init (tr ("Uncomment Selection"), "editor_edit:uncomment_selection", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
374 QKeySequence (ctrl_shift + Qt::Key_R)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
375 init (tr ("Comment Selection (Choosing String)"), "editor_edit:comment_var_selection", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
376 QKeySequence (ctrl_alt + Qt::Key_R)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
377 init (tr ("Uppercase Selection"), "editor_edit:upper_case", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
378 QKeySequence (ctrl + Qt::Key_U)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
379 init (tr ("Lowercase Selection"), "editor_edit:lower_case", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
380 QKeySequence (ctrl_alt + Qt::Key_U)); |
18656
1b289f45187f
add some qscintilla actions to the menu and to the shortcut manager
Torsten <ttl@justmail.de>
parents:
18631
diff
changeset
|
381 |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
382 #if defined (Q_OS_MAC) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
383 init (tr ("Indent Selection Rigidly"), "editor_edit:indent_selection", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
384 QKeySequence (prefix + Qt::Key_Tab)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
385 init (tr ("Unindent Selection Rigidly"), "editor_edit:unindent_selection", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
386 QKeySequence (prefix + Qt::ShiftModifier + Qt::Key_Tab)); |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
387 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
388 init (tr ("Indent Selection Rigidly"), "editor_edit:indent_selection", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
389 QKeySequence (ctrl + Qt::Key_Tab)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
390 init (tr ("Unindent Selection Rigidly"), "editor_edit:unindent_selection", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
391 QKeySequence (ctrl_shift + Qt::Key_Tab)); |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
392 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
393 init (tr ("Indent Code"), "editor_edit:smart_indent_line_or_selection", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
394 QKeySequence ()); |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
395 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
396 init (tr ("Convert Line Endings to Windows"), "editor_edit:conv_eol_winows", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
397 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
398 init (tr ("Convert Line Endings to Unix"), "editor_edit:conv_eol_unix", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
399 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
400 init (tr ("Convert Line Endings to Mac"), "editor_edit:conv_eol_mac", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
401 QKeySequence ()); |
19247
9582fad68730
add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents:
19246
diff
changeset
|
402 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
403 init (tr ("Goto Line"), "editor_edit:goto_line", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
404 QKeySequence (ctrl + Qt::Key_L)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
405 init (tr ("Move to Matching Brace"), "editor_edit:move_to_brace", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
406 QKeySequence (ctrl + Qt::Key_M)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
407 init (tr ("Select to Matching Brace"), "editor_edit:select_to_brace", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
408 QKeySequence (ctrl_shift + Qt::Key_M)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
409 init (tr ("Toggle Bookmark"), "editor_edit:toggle_bookmark", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
410 QKeySequence (prefix + Qt::Key_F7)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
411 init (tr ("Next Bookmark"), "editor_edit:next_bookmark", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
412 QKeySequence (prefix + Qt::Key_F2)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
413 init (tr ("Previous Bookmark"), "editor_edit:previous_bookmark", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
414 QKeySequence (prefix + Qt::SHIFT + Qt::Key_F2)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
415 init (tr ("Remove All Bookmark"), "editor_edit:remove_bookmark", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
416 QKeySequence ()); |
18665
777281eeb3d4
add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
417 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
418 init (tr ("Preferences"), "editor_edit:preferences", QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
419 init (tr ("Styles Preferences"), "editor_edit:styles_preferences", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
420 QKeySequence ()); |
18665
777281eeb3d4
add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
421 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
422 // view |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
423 init (tr ("Show Line Numbers"), "editor_view:show_line_numbers", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
424 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
425 init (tr ("Show Whitespace Characters"), "editor_view:show_white_spaces", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
426 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
427 init (tr ("Show Line Endings"), "editor_view:show_eol_chars", QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
428 init (tr ("Show Indentation Guides"), "editor_view:show_ind_guides", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
429 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
430 init (tr ("Show Long Line Marker"), "editor_view:show_long_line", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
431 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
432 init (tr ("Show Toolbar"), "editor_view:show_toolbar", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
433 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
434 init (tr ("Show Statusbar"), "editor_view:show_statusbar", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
435 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
436 init (tr ("Show Horizontal Scrollbar"), "editor_view:show_hscrollbar", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
437 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
438 init (tr ("Zoom In"), "editor_view:zoom_in", QKeySequence::ZoomIn); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
439 init (tr ("Zoom Out"), "editor_view:zoom_out", QKeySequence::ZoomOut); |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
440 #if defined (Q_OS_MAC) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
441 init (tr ("Zoom Normal"), "editor_view:zoom_normal", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
442 QKeySequence (ctrl + Qt::Key_Underscore)); |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
443 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
444 init (tr ("Zoom Normal"), "editor_view:zoom_normal", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
445 QKeySequence (ctrl + Qt::Key_Period)); |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
446 #endif |
18665
777281eeb3d4
add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
447 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
448 // debug |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
449 init (tr ("Toggle Breakpoint"), "editor_debug:toggle_breakpoint", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
450 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
451 init (tr ("Next Breakpoint"), "editor_debug:next_breakpoint", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
452 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
453 init (tr ("Previous Breakpoint"), "editor_debug:previous_breakpoint", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
454 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
455 init (tr ("Remove All Breakpoints"), "editor_debug:remove_breakpoints", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
456 QKeySequence ()); |
18665
777281eeb3d4
add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
457 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
458 // run |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
459 init (tr ("Run File"), "editor_run:run_file", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
460 QKeySequence (prefix + Qt::Key_F5)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
461 init (tr ("Run Selection"), "editor_run:run_selection", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
462 QKeySequence (prefix + Qt::Key_F9)); |
18665
777281eeb3d4
add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
463 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
464 // help |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
465 init (tr ("Help on Keyword"), "editor_help:help_keyword", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
466 QKeySequence::HelpContents); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
467 init (tr ("Document on Keyword"), "editor_help:doc_keyword", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
468 QKeySequence (Qt::SHIFT + Qt::Key_F1)); |
20693
7751bd56d0be
added actions and shortcuts for switching editor tabs
Torsten <ttl@justmail.de>
parents:
20686
diff
changeset
|
469 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
470 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
471 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
472 // write one or all actual shortcut set(s) into a settings file |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
473 void shortcut_manager::do_write_shortcuts (QSettings *settings, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
474 bool closing) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
475 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
476 bool sc_ctrld = false; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
477 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
478 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
|
479 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
480 settings->setValue ("shortcuts/" + m_sc.at (i).m_settings_key, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
481 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
|
482 // special: check main-window for Ctrl-D (Terminal) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
483 if (m_sc.at (i).m_settings_key.startsWith ("main_") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
484 && 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
|
485 sc_ctrld = true; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
486 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
487 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
488 settings->setValue ("shortcuts/main_ctrld",sc_ctrld); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
489 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
490 if (closing) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
491 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
492 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
|
493 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
|
494 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
495 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
496 settings->sync (); // sync the settings file |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
497 } |
20987
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20986
diff
changeset
|
498 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
499 void shortcut_manager::do_set_shortcut (QAction *action, const QString& key) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
500 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
501 int index; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
502 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
503 index = m_action_hash[key] - 1; |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
504 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
505 if (index > -1 && index < m_sc.count ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
506 action->setShortcut (QKeySequence ( |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
507 m_settings->value ("shortcuts/" + key, 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
|
508 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
509 qDebug () << "Key: " << key << " not found in m_action_hash"; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
510 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
511 |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
512 void shortcut_manager::do_shortcut (QShortcut *sc, const QString& key) |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
513 { |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
514 int index; |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
515 |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
516 index = m_action_hash[key] - 1; |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
517 |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
518 if (index > -1 && index < m_sc.count ()) |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
519 sc->setKey (QKeySequence (m_settings->value ("shortcuts/" + key, |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
520 m_sc.at (index).m_default_sc).toString ())); |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
521 else |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
522 qDebug () << "Key: " << key << " not found in m_action_hash"; |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
523 } |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
524 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
525 void shortcut_manager::do_fill_treewidget (QTreeWidget *tree_view) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
526 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
527 m_dialog = nullptr; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
528 m_level_hash.clear (); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
529 |
24827
1e0718c1867c
eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents:
24724
diff
changeset
|
530 #if defined (HAVE_QHEADERVIEW_SETSECTIONRESIZEMODE) |
1e0718c1867c
eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents:
24724
diff
changeset
|
531 tree_view->header ()->setSectionResizeMode (QHeaderView::ResizeToContents); |
1e0718c1867c
eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents:
24724
diff
changeset
|
532 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
533 tree_view->header ()->setResizeMode (QHeaderView::ResizeToContents); |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
534 #endif |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
535 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
536 QTreeWidgetItem *main = new QTreeWidgetItem (tree_view); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
537 main->setText (0, tr ("Global")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
538 main->setExpanded (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
539 QTreeWidgetItem *main_file = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
540 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
|
541 QTreeWidgetItem *main_edit = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
542 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
|
543 QTreeWidgetItem *main_debug = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
544 main_debug->setText (0, tr ("Debug Menu")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
545 QTreeWidgetItem *main_window = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
546 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
|
547 QTreeWidgetItem *main_help = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
548 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
|
549 QTreeWidgetItem *main_news = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
550 main_news->setText (0, tr ("News Menu")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
551 QTreeWidgetItem *main_tabs = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
552 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
|
553 QTreeWidgetItem *main_find = new QTreeWidgetItem (main); |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
554 main_find->setText (0, tr ("Find & Replace in Dock Widgets")); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
555 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
556 m_level_hash["main_file"] = main_file; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
557 m_level_hash["main_edit"] = main_edit; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
558 m_level_hash["main_debug"] = main_debug; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
559 m_level_hash["main_window"] = main_window; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
560 m_level_hash["main_help"] = main_help; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
561 m_level_hash["main_news"] = main_news; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
562 m_level_hash["main_tabs"] = main_tabs; |
24724
fa60be0abc21
add tab move and switch shortcuts to the doc browser
Torsten <mttl@mailbox.org>
parents:
24718
diff
changeset
|
563 m_level_hash["editor_tabs"] = main_tabs; |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
564 m_level_hash["editor_find"] = main_find; |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
565 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
566 QTreeWidgetItem *editor = new QTreeWidgetItem (tree_view); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
567 editor->setText (0, tr ("Editor")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
568 editor->setExpanded (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
569 QTreeWidgetItem *editor_file = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
570 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
|
571 QTreeWidgetItem *editor_edit = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
572 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
|
573 QTreeWidgetItem *editor_view = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
574 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
|
575 QTreeWidgetItem *editor_debug = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
576 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
|
577 QTreeWidgetItem *editor_run = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
578 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
|
579 QTreeWidgetItem *editor_help = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
580 editor_help->setText (0, tr ("Help Menu")); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
581 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
582 m_level_hash["editor_file"] = editor_file; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
583 m_level_hash["editor_edit"] = editor_edit; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
584 m_level_hash["editor_view"] = editor_view; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
585 m_level_hash["editor_debug"] = editor_debug; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
586 m_level_hash["editor_run"] = editor_run; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
587 m_level_hash["editor_help"] = editor_help; |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
588 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
589 connect (tree_view, SIGNAL (itemDoubleClicked (QTreeWidgetItem*, int)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
590 this, SLOT (handle_double_clicked (QTreeWidgetItem*, int))); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
591 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
592 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
|
593 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
594 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
|
595 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
596 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
|
597 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
598 // 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
|
599 // previously defined keyname |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
600 if (section == editor_file) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
601 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
602 // Closing tabs now in global tab handling section |
25128
8cffe74b7541
fix missing entries in shortcut preferences for other languages
Torsten <mttl@mailbox.org>
parents:
25103
diff
changeset
|
603 if (sc.m_settings_key.contains ("editor_file:close")) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
604 section = main_tabs; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
605 } |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
606 if (section == editor_edit) |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
607 { |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
608 // Find & replace now in global file & replace handling section |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
609 if (sc.m_settings_key.contains ("editor_edit:find")) |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
610 section = main_find; |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
611 } |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
612 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
613 QTreeWidgetItem *tree_item = new QTreeWidgetItem (section); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
614 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
615 // 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
|
616 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
|
617 fg.setAlpha (128); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
618 tree_item->setForeground (1, QBrush (fg)); |
18728
95249367d6fa
provide a second set of shortcuts
Torsten <ttl@justmail.de>
parents:
18711
diff
changeset
|
619 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
620 // write the shortcuts |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
621 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
|
622 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
|
623 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
|
624 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
625 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
|
626 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
|
627 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
628 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
629 } |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
630 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
631 // import or export of shortcut sets, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
632 // 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
|
633 // returns true on success, false otherwise |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
634 bool |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
635 shortcut_manager::do_import_export (int action) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
636 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
637 // 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
|
638 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
|
639 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
640 if (! overwrite_all_shortcuts ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
641 return false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
642 } |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
643 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
644 // 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
|
645 // 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
|
646 if (action != OSC_DEFAULT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
647 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
648 QString file; |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
649 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
650 if (action == OSC_IMPORT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
651 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
|
652 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
|
653 tr ("Octave Shortcut Files (*.osc);;All Files (*)"), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
654 nullptr, QFileDialog::DontUseNativeDialog); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
655 else if (action == OSC_EXPORT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
656 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
|
657 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
|
658 tr ("Octave Shortcut Files (*.osc);;All Files (*)"), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
659 nullptr, QFileDialog::DontUseNativeDialog); |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
660 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
661 if (file.isEmpty ()) |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
662 return false; |
18822
3f6280d0a36b
allow export and import of shortcut sets
Torsten <ttl@justmail.de>
parents:
18728
diff
changeset
|
663 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
664 QSettings *osc_settings = new QSettings (file, QSettings::IniFormat); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
665 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
666 if (! osc_settings) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
667 { |
25163
3aed4f0ba3cd
Update some GUI strings identified as unclear by translators.
Rik <rik@octave.org>
parents:
25128
diff
changeset
|
668 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
|
669 .arg (file); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
670 return false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
671 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
672 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
673 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
674 if (action == OSC_IMPORT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
675 import_shortcuts (osc_settings); // import (special action) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
676 else if (action == OSC_EXPORT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
677 do_write_shortcuts (osc_settings, false); // export, (save settings) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
678 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
679 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
680 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
681 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
682 import_shortcuts (nullptr); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
683 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
684 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
685 return true; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
686 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
687 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
688 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
|
689 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
690 if (! m_dialog) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
691 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
692 m_dialog = new QDialog (this); |
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 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
|
695 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
696 QVBoxLayout *box = new QVBoxLayout (m_dialog); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
697 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
698 QLabel *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
|
699 "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
|
700 "shortcut to its default.")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
701 help->setWordWrap (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
702 box->addWidget (help); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
703 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
704 QCheckBox *direct = new QCheckBox ( |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
705 tr ("Enter shortcut directly by performing it")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
706 direct->setCheckState (Qt::Checked); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
707 box->addWidget (direct); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
708 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
709 QGridLayout *grid = new QGridLayout (); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
710 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
711 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
|
712 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
|
713 m_edit_actual->setAlignment (Qt::AlignHCenter); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
714 grid->addWidget (actual, 0, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
715 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
|
716 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
717 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
|
718 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
|
719 m_label_default->setAlignment (Qt::AlignHCenter); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
720 grid->addWidget (def, 1, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
721 grid->addWidget (m_label_default, 1, 1); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
722 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
723 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
|
724 grid->addWidget (set_default, 0, 2); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
725 connect (set_default, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
726 this, SLOT (shortcut_dialog_set_default ())); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
727 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
728 box->addLayout (grid); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
729 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
730 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
|
731 | QDialogButtonBox::Cancel); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
732 QList<QAbstractButton *> buttons = button_box->buttons (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
733 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
|
734 buttons.at (i)->setShortcut (QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
735 connect (button_box, SIGNAL (accepted ()), m_dialog, SLOT (accept ())); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
736 connect (button_box, SIGNAL (rejected ()), m_dialog, SLOT (reject ())); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
737 box->addWidget (button_box); |
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_dialog->setLayout (box); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
740 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
741 connect (direct, SIGNAL (stateChanged (int)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
742 m_edit_actual, SLOT (handle_direct_shortcut (int))); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
743 connect (m_dialog, SIGNAL (finished (int)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
744 this, SLOT (shortcut_dialog_finished (int))); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
745 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
746 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
747 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
748 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
|
749 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
|
750 m_handled_index = index; |
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 m_edit_actual->setFocus (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
753 m_dialog->setFocusProxy (m_edit_actual); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
754 m_dialog->exec (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
755 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
756 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
757 // 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
|
758 // the defaults (settings = 0) and refresh the tree view |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
759 void shortcut_manager::import_shortcuts (QSettings *settings) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
760 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
761 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
|
762 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
763 // update the list of all shortcuts |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
764 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
|
765 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
766 if (settings) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
767 sc.m_actual_sc = QKeySequence ( // get new shortcut from settings |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
768 settings->value ("shortcuts/" + sc.m_settings_key,sc.m_actual_sc). |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
769 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
|
770 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
771 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
|
772 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
773 m_sc.replace (i,sc); // replace the old with the new one |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
774 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
775 // update the tree view |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
776 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
|
777 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
|
778 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
779 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
780 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
781 // 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
|
782 // 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
|
783 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
|
784 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
785 QMessageBox msg_box; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
786 msg_box.setWindowTitle (tr ("Overwriting Shortcuts")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
787 msg_box.setIcon (QMessageBox::Warning); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
788 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
|
789 "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
|
790 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
|
791 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
|
792 QMessageBox::DestructiveRole); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
793 msg_box.setDefaultButton (QMessageBox::Save); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
794 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
795 int ret = msg_box.exec (); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
796 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
797 if (msg_box.clickedButton () == discard) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
798 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
|
799 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
800 if (ret == QMessageBox::Save) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
801 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
802 if (do_import_export (OSC_EXPORT)) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
803 return true; // go ahead |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
804 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
805 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
806 return false; // abort the import |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
807 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
808 } |