Mercurial > octave
annotate libgui/src/dw-main-window.cc @ 25398:a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
* dw-main-window.cc/h (dw_main_window): new class derived from QMainWindow
with action and shortcuts for closing dock widgets;
(createPopupMenu): add new actions to the popup menu of QMainWindow;
(add_action): convenience function for adding an action;
(notice_settings): update the shortcuts from the settings file;
(request_close): slot for closing active widget;
(request_close_other): slot for closing other widgets;
(request_close_all_files): slot for closing all widgets;
* module.mk: add new files dw-main-window.cc/h
* variable-editor.cc (variable_editor): use new class dw_main_window;
(notice_settings): update settings of dw_main_window
* variable-editor.h: use dw_main_window instead of QMainWindow
author | Torsten <mttl@mailbox.org> |
---|---|
date | Tue, 22 May 2018 22:41:12 +0200 |
parents | |
children | ad3d018e595f |
rev | line source |
---|---|
25398
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
1 /* |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
2 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
3 Copyright (C) 2013-2018 Torsten <mttl@mailbox.org> |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
4 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
5 This file is part of Octave. |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
6 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
10 (at your option) any later version. |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
11 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
15 GNU General Public License for more details. |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
16 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
20 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
21 */ |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
22 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
23 /* This is the main window derived from QMainWindow for being used |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
24 as the main window in dock widgets like the variable editor or |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
25 the file editor |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
26 */ |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
27 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
28 #if defined (HAVE_CONFIG_H) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
29 # include "config.h" |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
30 #endif |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
31 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
32 #include <QMenu> |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
33 #include <QDockWidget> |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
34 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
35 #include "resource-manager.h" |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
36 #include "shortcut-manager.h" |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
37 #include "dw-main-window.h" |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
38 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
39 namespace octave |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
40 { |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
41 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
42 dw_main_window::dw_main_window (QWidget *p) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
43 : QMainWindow (p) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
44 { |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
45 // Adding the actions for closing the dock widgets |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
46 m_close_action |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
47 = add_action (nullptr, |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
48 resource_manager::icon ("window-close",false), |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
49 tr ("&Close"), |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
50 SLOT (request_close_file ()), this); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
51 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
52 m_close_all_action |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
53 = add_action (nullptr, |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
54 resource_manager::icon ("window-close",false), |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
55 tr ("Close &All"), |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
56 SLOT (request_close_all_files ()), this); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
57 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
58 m_close_others_action |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
59 = add_action (nullptr, |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
60 resource_manager::icon ("window-close",false), |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
61 tr ("Close &Other"), |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
62 SLOT (request_close_other_files ()), this); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
63 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
64 notice_settings (resource_manager::get_settings ()); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
65 } |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
66 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
67 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
68 // Re-implementing the popup menu of the main window |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
69 QMenu *dw_main_window::createPopupMenu () |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
70 { |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
71 QList<QAction *> new_actions = QList<QAction *> (); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
72 new_actions.append (m_close_action); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
73 new_actions.append (m_close_others_action); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
74 new_actions.append (m_close_all_action); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
75 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
76 QMenu *menu = QMainWindow::createPopupMenu (); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
77 QList<QAction *> actions = menu->actions(); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
78 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
79 if (actions.length () > 0) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
80 { |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
81 QAction *sep = menu->insertSeparator (actions.at (0)); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
82 menu->insertActions (sep, new_actions); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
83 } |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
84 else |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
85 menu->addActions (new_actions); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
86 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
87 return menu; |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
88 } |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
89 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
90 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
91 // Adding an action to the main window |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
92 QAction * dw_main_window::add_action (QMenu *menu, const QIcon& icon, |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
93 const QString& text, const char *member, |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
94 QWidget *receiver) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
95 { |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
96 QAction *a; |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
97 QWidget *r = this; |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
98 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
99 if (receiver != nullptr) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
100 r = receiver; |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
101 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
102 if (menu) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
103 a = menu->addAction (icon, text, r, member); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
104 else |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
105 { |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
106 a = new QAction (icon, text, this); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
107 a->setEnabled (true); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
108 connect (a, SIGNAL (triggered ()), r, member); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
109 } |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
110 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
111 addAction (a); // important for shortcut context |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
112 a->setShortcutContext (Qt::WidgetWithChildrenShortcut); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
113 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
114 return a; |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
115 } |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
116 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
117 // Update the settings |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
118 void dw_main_window::notice_settings (const QSettings*) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
119 { |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
120 shortcut_manager::set_shortcut (m_close_action, "editor_file:close"); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
121 shortcut_manager::set_shortcut (m_close_all_action, "editor_file:close_all"); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
122 shortcut_manager::set_shortcut (m_close_others_action, "editor_file:close_other"); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
123 } |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
124 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
125 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
126 // Slots for handling actions |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
127 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
128 // Close current widget |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
129 void dw_main_window::request_close_file () |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
130 { |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
131 QList<QDockWidget *> list = findChildren<QDockWidget *>(); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
132 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
133 for (int i = 0; i < list.length (); i++) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
134 { |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
135 if (list.at (i)->hasFocus ()) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
136 { |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
137 list.at (i)->close (); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
138 if (i > 0) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
139 list.at (i-1)->setFocus (); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
140 break; |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
141 } |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
142 } |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
143 } |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
144 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
145 // Close other widgets |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
146 void dw_main_window::request_close_other_files () |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
147 { |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
148 QList<QDockWidget *> list = findChildren<QDockWidget *>(); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
149 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
150 for (int i = list.length () - 1; i >= 0; i--) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
151 { |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
152 if (! list.at (i)->hasFocus ()) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
153 list.at (i)->close (); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
154 } |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
155 } |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
156 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
157 // Close all widgets |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
158 void dw_main_window::request_close_all_files () |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
159 { |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
160 QList<QDockWidget *> list = findChildren<QDockWidget *>(); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
161 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
162 for (int i = list.length () - 1; i >= 0; i--) |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
163 list.at (i)->close (); |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
164 } |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
165 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
166 } |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
167 |
a78e5b8d5ee7
provide shortcuts for closing widgets of the variable editor (bug #53002)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
168 |