Mercurial > octave
annotate libgui/src/shortcut-manager.cc @ 26638:1945796ba8b5
maint: merge stable to default.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 27 Jan 2019 16:32:02 +0100 |
parents | fff643eb3514 931ace437d5d |
children | e255897f353d |
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 |
26376
00f796120a6d
maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents:
26096
diff
changeset
|
3 Copyright (C) 2014-2019 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 return retval; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
176 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
177 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
178 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
|
179 const QKeySequence& def_sc) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
180 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
181 QKeySequence actual |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
182 = 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
|
183 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
184 // 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
|
185 shortcut_t shortcut_info; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
186 shortcut_info.m_description = description; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
187 shortcut_info.m_settings_key = key; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
188 shortcut_info.m_actual_sc = actual; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
189 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
|
190 m_sc << shortcut_info; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
191 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
192 // 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
|
193 if (! actual.isEmpty ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
194 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
|
195 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
|
196 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
197 // 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
|
198 if (key.startsWith ("main_") |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
199 && 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
|
200 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
|
201 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
202 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
203 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
|
204 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
205 Qt::KeyboardModifier ctrl; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
206 int prefix; |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
207 #if defined (Q_OS_MAC) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
208 // 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
|
209 ctrl = Qt::MetaModifier; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
210 // 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
|
211 // 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
|
212 // 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
|
213 prefix = Qt::AltModifier; |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
214 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
215 ctrl = Qt::ControlModifier; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
216 prefix = Qt::NoModifier; |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
217 #endif |
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
218 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
219 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
|
220 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
|
221 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
222 // 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
|
223 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
224 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
|
225 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
226 // file |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
227 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
|
228 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
|
229 QKeySequence (ctrl_shift + Qt::Key_N)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
230 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
|
231 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
|
232 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
|
233 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
|
234 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
|
235 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
236 // edit |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 QKeySequence (ctrl_shift + Qt::Key_F)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
244 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
|
245 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
246 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
|
247 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
248 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
|
249 init (tr ("Preferences"), "main_edit:preferences", QKeySequence ()); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
250 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
251 // debug |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
252 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
|
253 QKeySequence (prefix + Qt::Key_F10)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
254 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
|
255 QKeySequence (prefix + Qt::Key_F11)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
256 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
|
257 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
|
258 init (tr ("Continue"), "main_debug:continue", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
259 QKeySequence (prefix + Qt::Key_F5)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
260 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
|
261 QKeySequence (prefix + Qt::ShiftModifier + Qt::Key_F5)); |
18697
908523bd79b4
use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents:
18685
diff
changeset
|
262 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
263 // window |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
264 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
|
265 prefix + ctrl_shift + Qt::Key_0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
266 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
|
267 prefix + ctrl_shift + Qt::Key_1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
268 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
|
269 prefix + ctrl_shift + Qt::Key_2); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
270 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
|
271 prefix + ctrl_shift + Qt::Key_3); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
272 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
|
273 prefix + ctrl_shift + Qt::Key_4); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
274 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
|
275 prefix + ctrl_shift + Qt::Key_5); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
276 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
|
277 prefix + ctrl_shift + Qt::Key_6); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
278 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
|
279 prefix + ctrl + Qt::Key_0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
280 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
|
281 prefix + ctrl + Qt::Key_1); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
282 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
|
283 prefix + ctrl + Qt::Key_2); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
284 init (tr ("Workspace"), "main_window:workspace", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
285 prefix + ctrl + Qt::Key_3); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
286 init (tr ("Editor"), "main_window:editor", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
287 prefix + ctrl + Qt::Key_4); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
288 init (tr ("Documentation"), "main_window:doc", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
289 prefix + ctrl + Qt::Key_5); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
290 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
|
291 prefix + ctrl + Qt::Key_6); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
292 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
|
293 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
294 // help |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
295 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
|
296 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
297 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
|
298 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
299 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
|
300 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
|
301 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
|
302 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
|
303 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
304 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
|
305 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
306 // news |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
307 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
|
308 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
|
309 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
310 // Tab handling |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
311 // 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
|
312 // 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
|
313 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
|
314 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
|
315 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
|
316 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
|
317 QKeySequence (ctrl + Qt::Key_PageUp)); |
fa60be0abc21
add tab move and switch shortcuts to the doc browser
Torsten <mttl@mailbox.org>
parents:
24718
diff
changeset
|
318 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
|
319 QKeySequence (ctrl + Qt::Key_PageDown)); |
fa60be0abc21
add tab move and switch shortcuts to the doc browser
Torsten <mttl@mailbox.org>
parents:
24718
diff
changeset
|
320 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
|
321 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
|
322 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
|
323 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
|
324 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
325 // Zooming |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
326 init (tr ("Zoom In"), "editor_view:zoom_in", QKeySequence::ZoomIn); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
327 init (tr ("Zoom Out"), "editor_view:zoom_out", QKeySequence::ZoomOut); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
328 #if defined (Q_OS_MAC) |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
329 init (tr ("Zoom Normal"), "editor_view:zoom_normal", |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
330 QKeySequence (ctrl + Qt::Key_Underscore)); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
331 #else |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
332 init (tr ("Zoom Normal"), "editor_view:zoom_normal", |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
333 QKeySequence (ctrl + Qt::Key_Period)); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
334 #endif |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
335 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
336 // 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
|
337 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
338 // file |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
339 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
|
340 QKeySequence (ctrl + Qt::Key_E)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
341 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
|
342 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
|
343 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
|
344 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
345 // edit |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
346 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
|
347 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
|
348 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
|
349 QKeySequence::Find); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
350 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
|
351 QKeySequence::FindNext); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
352 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
|
353 QKeySequence::FindPrevious); |
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 Word"), "editor_edit:delete_start_word", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
355 QKeySequence::DeleteStartOfWord); |
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 Word"), "editor_edit:delete_end_word", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
357 QKeySequence::DeleteEndOfWord); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
358 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
|
359 QKeySequence (ctrl_shift + Qt::Key_Backspace)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
360 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
|
361 QKeySequence (ctrl_shift + Qt::Key_Delete)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
362 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
|
363 QKeySequence (ctrl_shift + Qt::Key_L)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
364 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
|
365 QKeySequence (ctrl_shift + Qt::Key_C)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
366 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
|
367 QKeySequence (ctrl_shift + Qt::Key_X)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
368 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
|
369 QKeySequence (ctrl + Qt::Key_D)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
370 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
|
371 QKeySequence (ctrl + Qt::Key_T)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
372 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
|
373 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
|
374 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
375 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
|
376 QKeySequence (ctrl + Qt::Key_R)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
377 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
|
378 QKeySequence (ctrl_shift + Qt::Key_R)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
379 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
|
380 QKeySequence (ctrl_alt + Qt::Key_R)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
381 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
|
382 QKeySequence (ctrl + Qt::Key_U)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
383 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
|
384 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
|
385 |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
386 #if defined (Q_OS_MAC) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
387 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
|
388 QKeySequence (prefix + Qt::Key_Tab)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
389 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
|
390 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
|
391 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
392 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
|
393 QKeySequence (ctrl + Qt::Key_Tab)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
394 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
|
395 QKeySequence (ctrl_shift + Qt::Key_Tab)); |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
396 #endif |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
397 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
|
398 QKeySequence ()); |
18923
58f1178f49ef
Redefine mac specific default shortcuts (bug #41217)
pantxo <pantxo.diribarne@gmail.com>
parents:
18922
diff
changeset
|
399 |
24718
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 Windows"), "editor_edit:conv_eol_winows", |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
401 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
402 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
|
403 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
404 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
|
405 QKeySequence ()); |
19247
9582fad68730
add actions for converting the eol characters of the editor file
Torsten <ttl@justmail.de>
parents:
19246
diff
changeset
|
406 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
407 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
|
408 QKeySequence (ctrl + Qt::Key_L)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
409 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
|
410 QKeySequence (ctrl + Qt::Key_M)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
411 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
|
412 QKeySequence (ctrl_shift + Qt::Key_M)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
413 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
|
414 QKeySequence (prefix + Qt::Key_F7)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
415 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
|
416 QKeySequence (prefix + Qt::Key_F2)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
417 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
|
418 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
|
419 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
|
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 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
|
423 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
|
424 QKeySequence ()); |
18665
777281eeb3d4
add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
425 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
426 // view |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
427 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
|
428 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
429 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
|
430 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
431 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
|
432 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
|
433 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
434 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
|
435 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
436 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
|
437 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
438 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
|
439 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
440 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
|
441 QKeySequence ()); |
18665
777281eeb3d4
add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
442 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
443 // debug |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
444 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
|
445 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
446 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
|
447 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
448 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
|
449 QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
450 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
|
451 QKeySequence ()); |
18665
777281eeb3d4
add all editor actions to the shortcut manager and fix their shortcut context
Torsten <ttl@justmail.de>
parents:
18656
diff
changeset
|
452 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
453 // run |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
454 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
|
455 QKeySequence (prefix + Qt::Key_F5)); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
456 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
|
457 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
|
458 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
459 // help |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
460 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
|
461 QKeySequence::HelpContents); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
462 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
|
463 QKeySequence (Qt::SHIFT + Qt::Key_F1)); |
20693
7751bd56d0be
added actions and shortcuts for switching editor tabs
Torsten <ttl@justmail.de>
parents:
20686
diff
changeset
|
464 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
465 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
466 // Documentation browser |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
467 init (tr ("Go to Homepage"), "doc_browser:go_home", |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
468 QKeySequence (Qt::AltModifier + Qt::Key_Home)); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
469 init (tr ("Go Back one Page"), "doc_browser:go_back", QKeySequence::Back); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
470 init (tr ("Go Forward one Page"), "doc_browser:go_next", QKeySequence::Forward); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
471 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
472 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
473 // 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
|
474 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
|
475 bool closing) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
476 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
477 bool sc_ctrld = false; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
478 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
479 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
|
480 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
481 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
|
482 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
|
483 // 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
|
484 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
|
485 && 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
|
486 sc_ctrld = true; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
487 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
488 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
489 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
|
490 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
491 if (closing) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
492 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
493 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
|
494 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
|
495 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
496 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
497 settings->sync (); // sync the settings file |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
498 } |
20987
f99cbd86a0f9
Prevent closing GUI by Ctrl+D in terminal (bug #46661)
Torsten <ttl@justmail.de>
parents:
20986
diff
changeset
|
499 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
500 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
|
501 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
502 int index; |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
503 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
504 index = m_action_hash[key] - 1; |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
505 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
506 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
|
507 action->setShortcut (QKeySequence ( |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
508 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
|
509 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
510 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
|
511 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
512 |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
513 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
|
514 { |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
515 int index; |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
516 |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
517 index = m_action_hash[key] - 1; |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
518 |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
519 if (index > -1 && index < m_sc.count ()) |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
520 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
|
521 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
|
522 else |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
523 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
|
524 } |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
525 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
526 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
|
527 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
528 m_dialog = nullptr; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
529 m_level_hash.clear (); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
530 |
24827
1e0718c1867c
eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents:
24724
diff
changeset
|
531 #if defined (HAVE_QHEADERVIEW_SETSECTIONRESIZEMODE) |
1e0718c1867c
eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents:
24724
diff
changeset
|
532 tree_view->header ()->setSectionResizeMode (QHeaderView::ResizeToContents); |
1e0718c1867c
eliminate most Qt version checks
John W. Eaton <jwe@octave.org>
parents:
24724
diff
changeset
|
533 #else |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
534 tree_view->header ()->setResizeMode (QHeaderView::ResizeToContents); |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22177
diff
changeset
|
535 #endif |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
536 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
537 QTreeWidgetItem *main = new QTreeWidgetItem (tree_view); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
538 main->setText (0, tr ("Global")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
539 main->setExpanded (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
540 QTreeWidgetItem *main_file = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
541 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
|
542 QTreeWidgetItem *main_edit = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
543 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
|
544 QTreeWidgetItem *main_debug = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
545 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
|
546 QTreeWidgetItem *main_window = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
547 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
|
548 QTreeWidgetItem *main_help = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
549 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
|
550 QTreeWidgetItem *main_news = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
551 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
|
552 QTreeWidgetItem *main_tabs = new QTreeWidgetItem (main); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
553 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
|
554 QTreeWidgetItem *main_find = new QTreeWidgetItem (main); |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
555 main_find->setText (0, tr ("Find & Replace in Dock Widgets")); |
25976
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
556 QTreeWidgetItem *main_zoom = new QTreeWidgetItem (main); |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
557 main_zoom->setText (0, tr ("Zooming in Editor and Documentation")); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
558 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
559 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
|
560 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
|
561 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
|
562 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
|
563 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
|
564 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
|
565 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
|
566 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
|
567 m_level_hash["editor_find"] = main_find; |
25976
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
568 m_level_hash["editor_zoom"] = main_zoom; |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
569 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
570 QTreeWidgetItem *editor = new QTreeWidgetItem (tree_view); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
571 editor->setText (0, tr ("Editor")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
572 editor->setExpanded (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
573 QTreeWidgetItem *editor_file = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
574 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
|
575 QTreeWidgetItem *editor_edit = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
576 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
|
577 QTreeWidgetItem *editor_view = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
578 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
|
579 QTreeWidgetItem *editor_debug = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
580 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
|
581 QTreeWidgetItem *editor_run = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
582 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
|
583 QTreeWidgetItem *editor_help = new QTreeWidgetItem (editor); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
584 editor_help->setText (0, tr ("Help Menu")); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
585 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
586 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
|
587 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
|
588 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
|
589 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
|
590 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
|
591 m_level_hash["editor_help"] = editor_help; |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
592 |
26017
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
593 QTreeWidgetItem *doc = new QTreeWidgetItem (tree_view); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
594 doc->setText (0, tr ("Documentation Viewer")); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
595 doc->setExpanded (true); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
596 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
597 QTreeWidgetItem *doc_browser = new QTreeWidgetItem (doc); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
598 doc_browser->setText (0, tr ("Browser")); |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
599 |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
600 m_level_hash["doc_browser"] = doc_browser; |
390d59717711
adding a toolbar with common browse tools to the doc browser (bug 54938)
Torsten <mttl@mailbox.org>
parents:
25976
diff
changeset
|
601 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
602 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
|
603 this, SLOT (handle_double_clicked (QTreeWidgetItem*, int))); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
604 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
605 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
|
606 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
607 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
|
608 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
609 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
|
610 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
611 // 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
|
612 // previously defined keyname |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
613 if (section == editor_file) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
614 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
615 // 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
|
616 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
|
617 section = main_tabs; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
618 } |
25371
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
619 if (section == editor_edit) |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
620 { |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
621 // 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
|
622 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
|
623 section = main_find; |
41bbdf17f51a
make shortcuts for searching within the documentation configurable
Torsten <mttl@mailbox.org>
parents:
25189
diff
changeset
|
624 } |
25976
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
625 if (section == editor_view) |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
626 { |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
627 // Zooming now in global zoom handling section |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
628 if (sc.m_settings_key.contains ("editor_view:zoom")) |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
629 section = main_zoom; |
a7cc5b7a3d22
provide shortcuts for zooming into the doc browser (bug #54877)
Torsten <mttl@mailbox.org>
parents:
25883
diff
changeset
|
630 } |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
631 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
632 QTreeWidgetItem *tree_item = new QTreeWidgetItem (section); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
633 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
634 // 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
|
635 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
|
636 fg.setAlpha (128); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
637 tree_item->setForeground (1, QBrush (fg)); |
18728
95249367d6fa
provide a second set of shortcuts
Torsten <ttl@justmail.de>
parents:
18711
diff
changeset
|
638 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
639 // write the shortcuts |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
640 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
|
641 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
|
642 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
|
643 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
644 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
|
645 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
|
646 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
647 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
648 } |
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 // import or export of shortcut sets, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
651 // 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
|
652 // returns true on success, false otherwise |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
653 bool |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
654 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
|
655 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
656 // 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
|
657 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
|
658 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
659 if (! overwrite_all_shortcuts ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
660 return false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
661 } |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
662 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
663 // 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
|
664 // 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
|
665 if (action != OSC_DEFAULT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
666 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
667 QString file; |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
668 |
26096
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26017
diff
changeset
|
669 // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved. |
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26017
diff
changeset
|
670 int opts = 0; // No options by default. |
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26017
diff
changeset
|
671 if (! resource_manager::get_settings ()->value ("use_native_file_dialogs", |
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26017
diff
changeset
|
672 true).toBool ()) |
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26017
diff
changeset
|
673 opts = QFileDialog::DontUseNativeDialog; |
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26017
diff
changeset
|
674 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
675 if (action == OSC_IMPORT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
676 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
|
677 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
|
678 tr ("Octave Shortcut Files (*.osc);;All Files (*)"), |
26096
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26017
diff
changeset
|
679 nullptr, QFileDialog::Option (opts)); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
680 else if (action == OSC_EXPORT) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
681 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
|
682 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
|
683 tr ("Octave Shortcut Files (*.osc);;All Files (*)"), |
26096
1002b49ce7b3
Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26017
diff
changeset
|
684 nullptr, QFileDialog::Option (opts)); |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
685 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
686 if (file.isEmpty ()) |
20702
b6b16d8c8b57
possibility to set all shortcuts to default values and check overwriting
Torsten <ttl@justmail.de>
parents:
20693
diff
changeset
|
687 return false; |
18822
3f6280d0a36b
allow export and import of shortcut sets
Torsten <ttl@justmail.de>
parents:
18728
diff
changeset
|
688 |
26635
931ace437d5d
fix possible memleak by avoiding bare poointer (bug #55440)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
689 QSettings osc_settings (file, QSettings::IniFormat); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
690 |
26635
931ace437d5d
fix possible memleak by avoiding bare poointer (bug #55440)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
691 if (osc_settings.status () != QSettings::NoError) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
692 { |
25163
3aed4f0ba3cd
Update some GUI strings identified as unclear by translators.
Rik <rik@octave.org>
parents:
25128
diff
changeset
|
693 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
|
694 .arg (file); |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
695 return false; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
696 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
697 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
698 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
699 if (action == OSC_IMPORT) |
26635
931ace437d5d
fix possible memleak by avoiding bare poointer (bug #55440)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
700 import_shortcuts (&osc_settings); // import (special action) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
701 else if (action == OSC_EXPORT) |
26635
931ace437d5d
fix possible memleak by avoiding bare poointer (bug #55440)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
702 do_write_shortcuts (&osc_settings, false); // export, (save settings) |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
703 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
704 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
705 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
706 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
707 import_shortcuts (nullptr); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
708 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
709 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
710 return true; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
711 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
712 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
713 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
|
714 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
715 if (! m_dialog) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
716 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
717 m_dialog = new QDialog (this); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
718 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
719 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
|
720 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
721 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
|
722 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
723 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
|
724 "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
|
725 "shortcut to its default.")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
726 help->setWordWrap (true); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
727 box->addWidget (help); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
728 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
729 QCheckBox *direct = new QCheckBox ( |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
730 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
|
731 direct->setCheckState (Qt::Checked); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
732 box->addWidget (direct); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
733 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
734 QGridLayout *grid = new QGridLayout (); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
735 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
736 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
|
737 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
|
738 m_edit_actual->setAlignment (Qt::AlignHCenter); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
739 grid->addWidget (actual, 0, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
740 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
|
741 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
742 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
|
743 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
|
744 m_label_default->setAlignment (Qt::AlignHCenter); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
745 grid->addWidget (def, 1, 0); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
746 grid->addWidget (m_label_default, 1, 1); |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
747 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
748 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
|
749 grid->addWidget (set_default, 0, 2); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
750 connect (set_default, SIGNAL (clicked ()), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
751 this, SLOT (shortcut_dialog_set_default ())); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
752 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
753 box->addLayout (grid); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
754 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
755 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
|
756 | QDialogButtonBox::Cancel); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
757 QList<QAbstractButton *> buttons = button_box->buttons (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
758 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
|
759 buttons.at (i)->setShortcut (QKeySequence ()); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
760 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
|
761 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
|
762 box->addWidget (button_box); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
763 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
764 m_dialog->setLayout (box); |
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 connect (direct, SIGNAL (stateChanged (int)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
767 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
|
768 connect (m_dialog, SIGNAL (finished (int)), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
769 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
|
770 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
771 } |
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_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
|
774 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
|
775 m_handled_index = index; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
776 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
777 m_edit_actual->setFocus (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
778 m_dialog->setFocusProxy (m_edit_actual); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
779 m_dialog->exec (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
780 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
781 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
782 // 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
|
783 // 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
|
784 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
|
785 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
786 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
|
787 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
788 // update the list of all shortcuts |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
789 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
|
790 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
791 if (settings) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
792 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
|
793 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
|
794 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
|
795 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
796 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
|
797 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
798 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
|
799 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
800 // update the tree view |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
801 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
|
802 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
|
803 } |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
804 } |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
805 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
806 // 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
|
807 // 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
|
808 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
|
809 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
810 QMessageBox msg_box; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
811 msg_box.setWindowTitle (tr ("Overwriting Shortcuts")); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
812 msg_box.setIcon (QMessageBox::Warning); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
813 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
|
814 "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
|
815 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
|
816 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
|
817 QMessageBox::DestructiveRole); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
818 msg_box.setDefaultButton (QMessageBox::Save); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
819 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
820 int ret = msg_box.exec (); |
24014
bffd7d826887
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23941
diff
changeset
|
821 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
822 if (msg_box.clickedButton () == discard) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
823 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
|
824 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
825 if (ret == QMessageBox::Save) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
826 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
827 if (do_import_export (OSC_EXPORT)) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
828 return true; // go ahead |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
829 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
830 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
831 return false; // abort the import |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24712
diff
changeset
|
832 } |
18611
086093fbdc1a
first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents:
diff
changeset
|
833 } |