annotate libgui/src/main-window.cc @ 27583:315c35e6037c

use symbolic constants for command widget preferences * QTerminal.cc: include new header file for shortcut preferences; (default_colors, color_names): removed obsolete methods; (notice_settings): replace preferences literals by symbolic constants; * QTerminal.h: remove obsolete methods, reorder enum CursorType matching the order in settings dialog * gui-preferences-all.h: add command window related preferences keys and default values as symbolic constants * gui-preferences-cs.h: add command window related preferences keys and default values as symbolic constants * gui-preferences-global.h: add global cursor blinking preferences constants * gui-preferences-sc.h: new header with shortcut related preferences * history-dock-widget.cc (notice_settings): replace font size literals by symbolic constants * file-editor-tab.cc (notice_settings): use cursor blinking pref. constants * main-window.cc (notice_settings): use cursor blinking pref. constants * module.mk: add new header gui-preferences-sc.h with shortcut preferences * resource-manager.cc (terminal_color_names, terminal_default_colors): remove obsolete methods * resource-manager.h: remove obsolete methods * settings-dialog.cc (settings_dialog, write_changed_settings): replace preferences key and default literals by new symbolic constants (read_terminal_colors, write_terminal_colors): use new arrays of symbolic constants and color names instead of literals * terminal-dock-widget.cc (terminal_dock_widget): use symbolic constants for font size preference key and default value * variable-editor.cc (variable_editor::notice_settings): use symbolic constants for font size preference key and default value
author Torsten Lilge <ttl-octave@mailbox.org>
date Tue, 29 Oct 2019 17:23:08 +0100
parents d7876110e854
children f0e3f3e28a8e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
1 /*
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
2
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 26323
diff changeset
3 Copyright (C) 2013-2019 John W. Eaton
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 26323
diff changeset
4 Copyright (C) 2011-2019 Jacob Dawid
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
5
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
6 This file is part of Octave.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
7
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24520
diff changeset
8 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
9 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: 24520
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
11 (at your option) any later version.
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
12
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
13 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
14 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
16 GNU General Public License for more details.
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
17
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
18 You should have received a copy of the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
19 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: 24520
diff changeset
20 <https://www.gnu.org/licenses/>.
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
21
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
22 */
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
23
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
24 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
25 # include "config.h"
15286
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15274
diff changeset
26 #endif
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15274
diff changeset
27
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
28 #include <utility>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
29
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
30 #include <QAction>
15257
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15204
diff changeset
31 #include <QApplication>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
32 #include <QDateTime>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
33 #include <QDebug>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
34 #include <QDesktopServices>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
35 #include <QDesktopWidget>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
36 #include <QFileDialog>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
37 #include <QIcon>
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
38 #include <QInputDialog>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
39 #include <QKeySequence>
15257
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15204
diff changeset
40 #include <QLabel>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
41 #include <QMenu>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
42 #include <QMenuBar>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
43 #include <QMessageBox>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
44 #include <QSettings>
14670
7fbea449737d Restructured menus, added toolbar and current directory line edit.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14669
diff changeset
45 #include <QStyle>
25956
2201f82db233 Add missing QStyleFactory header (Bug #54881)
John Donoghue
parents: 25944
diff changeset
46 #include <QStyleFactory>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
47 #include <QStyleFactory>
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
48 #include <QTextBrowser>
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
49 #include <QTextCodec>
17764
811b5a562680 Format release notes as preformatted text in the GUI (bug #40367)
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
50 #include <QTextStream>
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
51 #include <QThread>
21439
912b8828193b * main-window.cc: include QTimer header file
Mike Miller <mtmiller@octave.org>
parents: 21428
diff changeset
52 #include <QTimer>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
53 #include <QToolBar>
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
54
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
55 #if defined (HAVE_QSCINTILLA)
21203
710e700cdd7f maint: Clean up naming and indentation of #ifdef blocks in libgui
Rik <rik@octave.org>
parents: 21158
diff changeset
56 # include "file-editor.h"
16290
d07aeecb2d22 build: Add more #ifdefs to build GUI when Qscintilla is not present.
Rik <rik@octave.org>
parents: 16176
diff changeset
57 #endif
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27556
diff changeset
58 #include "gui-preferences-ed.h"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27556
diff changeset
59 #include "gui-preferences-global.h"
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
60 #include "gui-preferences-mw.h"
27196
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents: 27194
diff changeset
61 #include "interpreter-qobject.h"
14707
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
62 #include "main-window.h"
27193
01e73e1664ff move news reader widget to separate file
John W. Eaton <jwe@octave.org>
parents: 27118
diff changeset
63 #include "news-reader.h"
27197
b8c0d5ad024f refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents: 27196
diff changeset
64 #include "octave-qobject.h"
14707
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
65 #include "settings-dialog.h"
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
66 #include "shortcut-manager.h"
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
67 #include "welcome-wizard.h"
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
68
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
69 #include "Array.h"
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
70 #include "cmd-edit.h"
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
71 #include "oct-env.h"
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
72 #include "url-transfer.h"
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
73
19893
67cb2f421255 restore include statement removed in changeset c7c50030e76c
John W. Eaton <jwe@octave.org>
parents: 19882
diff changeset
74 #include "builtin-defun-decls.h"
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
75 #include "defaults.h"
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
76 #include "defun.h"
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23497
diff changeset
77 #include "interpreter-private.h"
23773
5ff24576b783 defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents: 23721
diff changeset
78 #include "interpreter.h"
27396
930c0fbc003b move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents: 27393
diff changeset
79 #include "load-path.h"
23479
06bf3a0b08bf maint: Use "" instead of <> for our own include files.
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
80 #include "oct-map.h"
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
81 #include "octave.h"
25408
ce725103ebf1 Fallback to open.m for opening files in the gui file browser (bug #50543)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25407
diff changeset
82 #include "parse.h"
26117
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 26115
diff changeset
83 #include "syminfo.h"
24362
3fc24b792a24 avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24361
diff changeset
84 #include "symscope.h"
23479
06bf3a0b08bf maint: Use "" instead of <> for our own include files.
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
85 #include "utils.h"
15404
f52a62a6db3a eliminate copy and paste copyright info in GUI about info box
John W. Eaton <jwe@octave.org>
parents: 15402
diff changeset
86 #include "version.h"
23380
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
87
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
88 namespace octave
23119
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
89 {
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
90 static file_editor_interface *
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
91 create_default_editor (QWidget *p)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
92 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
93 #if defined (HAVE_QSCINTILLA)
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27101
diff changeset
94 return new file_editor (p);
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
95 #else
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
96 octave_unused_parameter (p);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
97
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
98 return 0;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
99 #endif
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
100 }
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
101
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
102 main_window::main_window (base_qobject& qobj)
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
103 : QMainWindow (), m_octave_qobj (qobj), m_workspace_model (nullptr),
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
104 m_status_bar (nullptr), m_command_window (nullptr),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
105 m_history_window (nullptr), m_file_browser_window (nullptr),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
106 m_doc_browser_window (nullptr), m_editor_window (nullptr),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
107 m_workspace_window (nullptr), m_variable_editor_window (nullptr),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
108 m_external_editor (new external_editor_interface (this)),
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
109 m_active_editor (m_external_editor), m_settings_dlg (nullptr),
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
110 m_find_files_dlg (nullptr), m_set_path_dlg (nullptr),
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
111 m_release_notes_window (nullptr), m_community_news_window (nullptr),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
112 m_clipboard (QApplication::clipboard ()),
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
113 m_prevent_readline_conflicts (true), m_suppress_dbg_location (true),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
114 m_closing (false), m_file_encoding (QString ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
115 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
116 if (resource_manager::is_first_run ())
25938
6fec0e305268 Backed out changeset 2ab0a9b66388
John W. Eaton <jwe@octave.org>
parents: 25937
diff changeset
117 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
118 // Before wizard.
27197
b8c0d5ad024f refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents: 27196
diff changeset
119 qobj.config_translators ();
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
120
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
121 welcome_wizard welcomeWizard;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
122
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
123 if (welcomeWizard.exec () == QDialog::Rejected)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
124 exit (1);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
125
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
126 // Install settings file.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
127 resource_manager::reload_settings ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
128 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
129 else
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
130 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
131 // Get settings file.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
132 resource_manager::reload_settings ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
133
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
134 // After settings.
27197
b8c0d5ad024f refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents: 27196
diff changeset
135 qobj.config_translators ();
25938
6fec0e305268 Backed out changeset 2ab0a9b66388
John W. Eaton <jwe@octave.org>
parents: 25937
diff changeset
136 }
6fec0e305268 Backed out changeset 2ab0a9b66388
John W. Eaton <jwe@octave.org>
parents: 25937
diff changeset
137
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
138 resource_manager::update_network_settings ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
139
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
140 // We provide specific terminal capabilities, so ensure that
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
141 // TERM is always set appropriately.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
142
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
143 #if defined (OCTAVE_USE_WINDOWS_API)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
144 sys::env::putenv ("TERM", "cygwin");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
145 #else
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
146 sys::env::putenv ("TERM", "xterm");
25046
a4c687fec320 gui: set Qt Application and Desktop metadata for desktop integration (bug #53102)
Mike Miller <mtmiller@octave.org>
parents: 25042
diff changeset
147 #endif
a4c687fec320 gui: set Qt Application and Desktop metadata for desktop integration (bug #53102)
Mike Miller <mtmiller@octave.org>
parents: 25042
diff changeset
148
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
149 shortcut_manager::init_data ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
150
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
151 construct_central_widget ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
152
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
153 m_workspace_model = new workspace_model ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
154 m_status_bar = new QStatusBar ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
155 m_command_window = new terminal_dock_widget (this);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
156 m_history_window = new history_dock_widget (this);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
157 m_file_browser_window = new files_dock_widget (this);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
158 m_doc_browser_window = new documentation_dock_widget (this);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
159 m_editor_window = create_default_editor (this);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
160 m_variable_editor_window = new variable_editor (this);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
161 m_workspace_window = new workspace_view (this);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
162
27267
d75c7b4f7645 fix using external editor when built without qscintilla (regression from ceb508ea92ee)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27263
diff changeset
163 // Set active editor depending on editor window. If the latter is
d75c7b4f7645 fix using external editor when built without qscintilla (regression from ceb508ea92ee)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27263
diff changeset
164 // not initialized (qscintilla not present), use the external editor.
d75c7b4f7645 fix using external editor when built without qscintilla (regression from ceb508ea92ee)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27263
diff changeset
165 if (m_editor_window)
d75c7b4f7645 fix using external editor when built without qscintilla (regression from ceb508ea92ee)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27263
diff changeset
166 m_active_editor = m_editor_window;
d75c7b4f7645 fix using external editor when built without qscintilla (regression from ceb508ea92ee)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27263
diff changeset
167 else
d75c7b4f7645 fix using external editor when built without qscintilla (regression from ceb508ea92ee)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27263
diff changeset
168 m_active_editor = m_external_editor;
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
169
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
170 #if defined (HAVE_QGUIAPPLICATION_SETDESKTOPFILENAME)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
171 QGuiApplication::setDesktopFileName ("org.octave.Octave.desktop");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
172 #endif
25938
6fec0e305268 Backed out changeset 2ab0a9b66388
John W. Eaton <jwe@octave.org>
parents: 25937
diff changeset
173
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
174 QApplication *qapp = m_octave_qobj.qapplication ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
175
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
176 m_default_style = qapp->style ()->objectName ();
26227
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
177
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
178 QSettings *settings = resource_manager::get_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
179
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
180 bool connect_to_web = true;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
181 QDateTime last_checked;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
182 int serial = 0;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
183 m_active_dock = nullptr;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
184
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
185 if (settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
186 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
187 connect_to_web
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
188 = settings->value ("news/allow_web_connection", false).toBool ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
189
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
190 last_checked
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
191 = settings->value ("news/last_time_checked", QDateTime ()).toDateTime ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
192
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
193 serial = settings->value ("news/last_news_item", 0).toInt ();
25702
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
194 m_default_encoding = settings->value (ed_default_enc.key,
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
195 ed_default_enc.def).toString ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
196 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
197
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
198 QDateTime current = QDateTime::currentDateTime ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
199 QDateTime one_day_ago = current.addDays (-1);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
200
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
201 if (connect_to_web
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
202 && (! last_checked.isValid () || one_day_ago > last_checked))
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
203 load_and_display_community_news (serial);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
204
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
205 construct_octave_qt_link ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
206
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
207 // We have to set up all our windows, before we finally launch
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
208 // octave.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
209
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
210 construct ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
211
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
212 read_settings ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
213
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
214 init_terminal_size ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
215
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
216 // Connect signals for changes in visibility not before window is
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
217 // shown.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
218
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
219 connect_visibility_changed ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
220
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
221 focus_command_window ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
222 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
223
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
224 main_window::~main_window (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
225 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
226 // Destroy the terminal first so that STDERR stream is redirected back
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
227 // to its original pipe to capture error messages at exit.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
228
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
229 delete m_editor_window; // first one for dialogs of modified editor-tabs
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
230 delete m_external_editor;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
231 delete m_command_window;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
232 delete m_workspace_window;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
233 delete m_doc_browser_window;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
234 delete m_file_browser_window;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
235 delete m_history_window;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
236 delete m_status_bar;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
237 delete m_workspace_model;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
238 delete m_variable_editor_window;
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
239
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
240 delete m_find_files_dlg;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
241 delete m_release_notes_window;
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
242 delete m_community_news_window;
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
243 delete m_community_news_window;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
244 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
245
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
246 bool main_window::command_window_has_focus (void) const
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
247 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
248 return m_command_window->has_focus ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
249 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
250
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
251 void main_window::focus_command_window (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
252 {
27281
0915fec3d3a9 prevent gui from catching focus when its desktop workspace becomes active
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27277
diff changeset
253 m_command_window->activate ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
254 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
255
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
256 // catch focus changes and determine the active dock widget
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
257 void main_window::focus_changed (QWidget *, QWidget *new_widget)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
258 {
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
259 // If there is no new widget (e.g., when pressing <alt> and the global
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
260 // menu gets active, we can return immediately
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
261 if (! new_widget)
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
262 return;
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
263
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
264 octave_dock_widget *dock = nullptr;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
265 QWidget *w_new = new_widget; // get a copy of new focus widget
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
266 QWidget *start = w_new; // Save it as start of our search
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
267 int count = 0; // fallback to prevent endless loop
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
268
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
269 QList<octave_dock_widget *> w_list = dock_widget_list ();
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
270
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
271 while (w_new && w_new != m_main_tool_bar && count < 100)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
272 {
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
273 // Go through all dock widgets and check whether the current widget
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
274 // widget with focus is a child of one of it
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
275 foreach (octave_dock_widget *w, w_list)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
276 {
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
277 if (w->isAncestorOf (w_new))
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
278 dock = w;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
279 }
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
280
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
281 if (dock)
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
282 break;
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
283
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
284 // If not yet found (in case w_new is not a childs of its dock widget),
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
285 // test next widget in the focus chain
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
286 w_new = qobject_cast<QWidget *> (w_new->previousInFocusChain ());
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
287
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
288 // Measures preventing an endless loop
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
289 if (w_new == start)
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
290 break; // We have arrived where we began ==> exit loop
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
291 count++; // Limited number of trials
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
292 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
293
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
294 // editor needs extra handling
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
295 octave_dock_widget *edit_dock_widget
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
296 = static_cast<octave_dock_widget *> (m_editor_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
297 // if new dock has focus, emit signal and store active focus
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
298 // except editor changes to a dialog (dock=0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
299 if ((dock || m_active_dock != edit_dock_widget) && (dock != m_active_dock))
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
300 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
301 // signal to all dock widgets for updating the style
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
302 emit active_dock_changed (m_active_dock, dock);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
303
26555
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
304 if (dock)
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
305 {
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
306 QList<QDockWidget *> tabbed = tabifiedDockWidgets (dock);
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
307 if (tabbed.contains (m_active_dock))
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
308 dock->set_predecessor_widget (m_active_dock);
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
309 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
310
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
311 if (edit_dock_widget == dock)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
312 emit editor_focus_changed (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
313 else if (edit_dock_widget == m_active_dock)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
314 emit editor_focus_changed (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
315
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
316 m_active_dock = dock;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
317 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
318 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
319
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
320 void main_window::request_reload_settings (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
321 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
322 QSettings *settings = resource_manager::get_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
323
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
324 if (settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
325 emit settings_changed (settings);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
326 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
327
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
328 void main_window::report_status_message (const QString& statusMessage)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
329 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
330 m_status_bar->showMessage (statusMessage, 1000);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
331 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
332
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
333 void main_window::handle_save_workspace_request (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
334 {
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
335 // 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: 26067
diff changeset
336 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: 26067
diff changeset
337 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: 26067
diff changeset
338 true).toBool ())
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
339 opts = QFileDialog::DontUseNativeDialog;
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
340
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
341 QString file
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
342 = QFileDialog::getSaveFileName (this, tr ("Save Workspace As"), ".",
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
343 nullptr, nullptr, QFileDialog::Option (opts));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
344
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
345 if (! file.isEmpty ())
25723
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
346 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
347 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
348 ([file] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
349 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
350 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
351
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
352 Fsave (interp, ovl (file.toStdString ()));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
353 });
25723
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
354 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
355 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
356
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
357 void main_window::handle_load_workspace_request (const QString& file_arg)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
358 {
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
359 // 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: 26067
diff changeset
360 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: 26067
diff changeset
361 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: 26067
diff changeset
362 true).toBool ())
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
363 opts = QFileDialog::DontUseNativeDialog;
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
364
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
365 QString file = file_arg;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
366
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
367 if (file.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
368 file = QFileDialog::getOpenFileName (this, tr ("Load Workspace"), ".",
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
369 nullptr, nullptr, QFileDialog::Option (opts));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
370
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
371 if (! file.isEmpty ())
25723
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
372 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
373 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
374 ([file] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
375 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
376 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
377
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
378 Fload (interp, ovl (file.toStdString ()));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
379
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
380 tree_evaluator& tw = interp.get_evaluator ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
381
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
382 event_manager& xevmgr = interp.get_event_manager ();
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
383
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
384 xevmgr.set_workspace (true, tw.get_symbol_info ());
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
385 });
25723
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
386 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
387 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
388
25408
ce725103ebf1 Fallback to open.m for opening files in the gui file browser (bug #50543)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25407
diff changeset
389 void main_window::handle_open_any_request (const QString& file_arg)
ce725103ebf1 Fallback to open.m for opening files in the gui file browser (bug #50543)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25407
diff changeset
390 {
ce725103ebf1 Fallback to open.m for opening files in the gui file browser (bug #50543)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25407
diff changeset
391 if (! file_arg.isEmpty ())
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
392 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
393 std::string file = file_arg.toStdString ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
394
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
395 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
396 ([file] (interpreter& interp)
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
397 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
398 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
399
27405
646efbb5f407 avoid including builtin-defun-decls.h unless needed
John W. Eaton <jwe@octave.org>
parents: 27396
diff changeset
400 interp.feval ("open", ovl (file));
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
401
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
402 // Update the workspace since open.m may have loaded new
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
403 // variables.
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
404 tree_evaluator& tw = interp.get_evaluator ();
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
405
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
406 event_manager& xevmgr = interp.get_event_manager ();
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
407
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
408 xevmgr.set_workspace (true, tw.get_symbol_info ());
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
409 });
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
410 }
25408
ce725103ebf1 Fallback to open.m for opening files in the gui file browser (bug #50543)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25407
diff changeset
411 }
ce725103ebf1 Fallback to open.m for opening files in the gui file browser (bug #50543)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25407
diff changeset
412
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
413 void main_window::handle_clear_workspace_request (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
414 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
415 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
416 ([] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
417 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
418 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
419
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
420 Fclear (interp);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
421 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
422 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
423
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
424 void main_window::handle_clear_command_window_request (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
425 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
426 emit interpreter_event
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
427 ([] (void)
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
428 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
429 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
430
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
431 command_editor::kill_full_line ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
432 command_editor::clear_screen ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
433 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
434 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
435
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
436 void main_window::handle_clear_history_request (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
437 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
438 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
439 ([] (interpreter& interp)
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
440 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
441 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
442
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
443 history_system& history_sys = interp.get_history_system ();
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
444
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
445 history_sys.do_history (ovl ("-c"));
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
446 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
447 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
448
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
449 void main_window::handle_undo_request (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
450 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
451 if (command_window_has_focus ())
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
452 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
453 emit interpreter_event
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
454 ([] (void)
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
455 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
456 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
457
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
458 command_editor::undo ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
459 command_editor::redisplay ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
460 });
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
461 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
462 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
463 emit undo_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
464 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
465
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
466 void main_window::handle_rename_variable_request (const QString& old_name_arg,
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
467 const QString& new_name_arg)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
468
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
469 {
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
470 std::string old_name = old_name_arg.toStdString ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
471 std::string new_name = new_name_arg.toStdString ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
472
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
473 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
474 ([old_name, new_name] (interpreter& interp)
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
475 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
476 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
477
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
478 symbol_scope scope = interp.get_current_scope ();
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
479
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
480 if (scope)
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
481 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
482 scope.rename (old_name, new_name);
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
483
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
484 tree_evaluator& tw = interp.get_evaluator ();
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
485
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
486 event_manager& xevmgr = interp.get_event_manager ();
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
487
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
488 xevmgr.set_workspace (true, tw.get_symbol_info ());
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
489 }
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
490
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
491 // FIXME: if this action fails, do we need a way to display that info
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
492 // in the GUI?
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
493 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
494 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
495
27308
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
496 void main_window::modify_path (const octave_value_list& dir_list,
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
497 bool rm, bool subdirs)
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
498 {
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
499 emit interpreter_event
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
500 ([dir_list, rm, subdirs, this] (interpreter& interp)
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
501 {
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
502 // INTERPRETER THREAD
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
503
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
504 octave_value_list paths = ovl ();
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
505
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
506 if (subdirs)
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
507 {
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
508 // Loop over all directories in order to get all subdirs
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
509 for (octave_idx_type i = 0; i < dir_list.length (); i++)
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
510 paths.append (Fgenpath (dir_list(i)));
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
511 }
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
512 else
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
513 paths = dir_list;
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
514
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
515 if (rm)
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
516 Frmpath (interp, paths);
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
517 else
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
518 Faddpath (interp, paths);
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
519 });
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
520 }
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
521
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
522 void main_window::new_file (const QString& commands)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
523 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
524 emit new_file_signal (commands);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
525 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
526
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
527 void main_window::open_file (const QString& file_name, int line)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
528 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
529 if (line < 0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
530 emit open_file_signal (file_name);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
531 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
532 emit open_file_signal (file_name, QString (), line);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
533 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
534
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
535 void main_window::edit_mfile (const QString& name, int line)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
536 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
537 handle_edit_mfile_request (name, QString (), QString (), line);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
538 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
539
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
540 void main_window::file_remove_proxy (const QString& o, const QString& n)
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
541 {
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
542 interpreter_qobject *interp_qobj = m_octave_qobj.interpreter_qobj ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
543
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
544 qt_interpreter_events *qt_link = interp_qobj->qt_link ();
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
545
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
546 // Wait for worker to suspend
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
547 qt_link->lock ();
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
548
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
549 // Close the file if opened
27039
32d9f57d7245 fix missing unlock of mutex when gui editor is not present (bug #56097)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
550 #if defined (HAVE_QSCINTILLA)
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
551 m_editor_window->handle_file_remove (o, n);
27041
6caf75200854 build: Silence unused parameter warning created in cset 43f6f02dd91c (bug #56097).
Rik <rik@octave.org>
parents: 27039
diff changeset
552 #else
6caf75200854 build: Silence unused parameter warning created in cset 43f6f02dd91c (bug #56097).
Rik <rik@octave.org>
parents: 27039
diff changeset
553 octave_unused_parameter (o);
6caf75200854 build: Silence unused parameter warning created in cset 43f6f02dd91c (bug #56097).
Rik <rik@octave.org>
parents: 27039
diff changeset
554 octave_unused_parameter (n);
27039
32d9f57d7245 fix missing unlock of mutex when gui editor is not present (bug #56097)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
555 #endif
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
556
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
557 // We are done: Unlock and wake the worker thread
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
558 qt_link->unlock ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
559 qt_link->wake_all ();
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
560 }
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
561
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
562 void main_window::open_online_documentation_page (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
563 {
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
564 QDesktopServices::openUrl
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
565 (QUrl ("https://octave.org/doc/interpreter/index.html"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
566 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
567
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
568 void main_window::display_release_notes (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
569 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
570 if (! m_release_notes_window)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
571 {
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
572 std::string news_file = config::oct_etc_dir () + "/NEWS";
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
573
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
574 QString news;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
575
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
576 QFile *file = new QFile (QString::fromStdString (news_file));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
577 if (file->open (QFile::ReadOnly))
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
578 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
579 QTextStream *stream = new QTextStream (file);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
580 news = stream->readAll ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
581 if (! news.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
582 {
25251
0bc58956aa40 Escape '<', '>' in NEWS file before it is displayed as HTML in Release Notes window (bug #53642).
Rik <rik@octave.org>
parents: 25103
diff changeset
583 // Convert '<', '>' which would be interpreted as HTML
0bc58956aa40 Escape '<', '>' in NEWS file before it is displayed as HTML in Release Notes window (bug #53642).
Rik <rik@octave.org>
parents: 25103
diff changeset
584 news.replace ("<", "&lt;");
0bc58956aa40 Escape '<', '>' in NEWS file before it is displayed as HTML in Release Notes window (bug #53642).
Rik <rik@octave.org>
parents: 25103
diff changeset
585 news.replace (">", "&gt;");
0bc58956aa40 Escape '<', '>' in NEWS file before it is displayed as HTML in Release Notes window (bug #53642).
Rik <rik@octave.org>
parents: 25103
diff changeset
586 // Add HTML tags for pre-formatted text
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
587 news.prepend ("<pre>");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
588 news.append ("</pre>");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
589 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
590 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
591 news = (tr ("The release notes file '%1' is empty.")
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
592 . arg (QString::fromStdString (news_file)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
593 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
594 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
595 news = (tr ("The release notes file '%1' cannot be read.")
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
596 . arg (QString::fromStdString (news_file)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
597
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
598 m_release_notes_window = new QWidget;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
599
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
600 QTextBrowser *browser = new QTextBrowser (m_release_notes_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
601 browser->setText (news);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
602
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
603 QVBoxLayout *vlayout = new QVBoxLayout;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
604 vlayout->addWidget (browser);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
605
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
606 m_release_notes_window->setLayout (vlayout);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
607 m_release_notes_window->setWindowTitle (tr ("Octave Release Notes"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
608
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
609 browser->document ()->adjustSize ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
610
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
611 // center the window on the screen where octave is running
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
612 QDesktopWidget *m_desktop = QApplication::desktop ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
613 int screen = m_desktop->screenNumber (this); // screen of the main window
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
614 QRect screen_geo = m_desktop->availableGeometry (screen);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
615 int win_x = screen_geo.width (); // width of the screen
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
616 int win_y = screen_geo.height (); // height of the screen
26643
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
617 int reln_x = win_x*2/5; // desired width of release notes
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
618 int reln_y = win_y*2/3; // desired height of release notes
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
619 m_release_notes_window->resize (reln_x, reln_y); // set size
26643
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
620 m_release_notes_window->move (20, 20); // move to the top left corner
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
621 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
622
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
623 if (! m_release_notes_window->isVisible ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
624 m_release_notes_window->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
625 else if (m_release_notes_window->isMinimized ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
626 m_release_notes_window->showNormal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
627
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
628 m_release_notes_window->setWindowIcon (QIcon (m_release_notes_icon));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
629
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
630 m_release_notes_window->raise ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
631 m_release_notes_window->activateWindow ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
632 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
633
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
634 void main_window::load_and_display_community_news (int serial)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
635 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
636 QSettings *settings = resource_manager::get_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
637
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
638 bool connect_to_web
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
639 = (settings
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
640 ? settings->value ("news/allow_web_connection", false).toBool ()
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
641 : true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
642
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
643 QString base_url = "https://octave.org";
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
644 QString page = "community-news.html";
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
645
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
646 QThread *worker_thread = new QThread;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
647
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
648 news_reader *reader = new news_reader (base_url, page, serial,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
649 connect_to_web);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
650
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
651 reader->moveToThread (worker_thread);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
652
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
653 connect (reader, SIGNAL (display_news_signal (const QString&)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
654 this, SLOT (display_community_news (const QString&)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
655
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
656 connect (worker_thread, SIGNAL (started (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
657 reader, SLOT (process (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
658
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
659 connect (reader, SIGNAL (finished (void)), worker_thread, SLOT (quit (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
660
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
661 connect (reader, SIGNAL (finished (void)), reader, SLOT (deleteLater (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
662
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
663 connect (worker_thread, SIGNAL (finished (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
664 worker_thread, SLOT (deleteLater (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
665
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
666 worker_thread->start ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
667 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
668
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
669 void main_window::display_community_news (const QString& news)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
670 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
671 if (! m_community_news_window)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
672 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
673 m_community_news_window = new QWidget;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
674
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
675 QTextBrowser *browser = new QTextBrowser (m_community_news_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
676
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
677 browser->setHtml (news);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
678 browser->setObjectName ("OctaveNews");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
679 browser->setOpenExternalLinks (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
680
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
681 QVBoxLayout *vlayout = new QVBoxLayout;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
682
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
683 vlayout->addWidget (browser);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
684
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
685 m_community_news_window->setLayout (vlayout);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
686 m_community_news_window->setWindowTitle (tr ("Octave Community News"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
687
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
688 // center the window on the screen where octave is running
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
689 QDesktopWidget *m_desktop = QApplication::desktop ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
690 int screen = m_desktop->screenNumber (this); // screen of the main window
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
691 QRect screen_geo = m_desktop->availableGeometry (screen);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
692 int win_x = screen_geo.width (); // width of the screen
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
693 int win_y = screen_geo.height (); // height of the screen
26643
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
694 int news_x = win_x/2; // desired width of news window
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
695 int news_y = win_y/2; // desired height of news window
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
696 m_community_news_window->resize (news_x, news_y); // set size and center
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
697 m_community_news_window->move ((win_x - m_community_news_window->width ())/2,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
698 (win_y - m_community_news_window->height ())/2);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
699 }
25805
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
700 else
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
701 {
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
702 // Window already exists, just update the browser contents
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
703 QTextBrowser *browser
25819
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
704
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
705 = m_community_news_window->findChild<QTextBrowser *>("OctaveNews"
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
706 #if defined (QOBJECT_FINDCHILDREN_ACCEPTS_FINDCHILDOPTIONS)
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
707 , Qt::FindDirectChildrenOnly
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
708 #endif
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
709 );
25805
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
710 if (browser)
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
711 browser->setHtml (news);
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
712 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
713
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
714 if (! m_community_news_window->isVisible ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
715 m_community_news_window->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
716 else if (m_community_news_window->isMinimized ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
717 m_community_news_window->showNormal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
718
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
719 // same icon as release notes
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
720 m_community_news_window->setWindowIcon (QIcon (m_release_notes_icon));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
721
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
722 m_community_news_window->raise ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
723 m_community_news_window->activateWindow ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
724 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
725
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
726 void main_window::open_bug_tracker_page (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
727 {
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
728 QDesktopServices::openUrl (QUrl ("https://octave.org/bugs.html"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
729 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
730
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
731 void main_window::open_octave_packages_page (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
732 {
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
733 QDesktopServices::openUrl (QUrl ("https://octave.org/packages.html"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
734 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
735
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
736 void main_window::open_contribute_page (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
737 {
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
738 QDesktopServices::openUrl (QUrl ("https://octave.org/contribute.html"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
739 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
740
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
741 void main_window::open_donate_page (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
742 {
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
743 QDesktopServices::openUrl (QUrl ("https://octave.org/donate.html"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
744 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
745
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
746 void main_window::process_settings_dialog_request (const QString& desired_tab)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
747 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
748 if (m_settings_dlg) // m_settings_dlg is a guarded pointer!
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
749 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
750 // here the dialog is still open and called once again
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
751 if (! desired_tab.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
752 m_settings_dlg->show_tab (desired_tab);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
753 return;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
754 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
755
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
756 m_settings_dlg = new settings_dialog (this, desired_tab);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
757
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
758 connect (m_settings_dlg, SIGNAL (apply_new_settings (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
759 this, SLOT (request_reload_settings (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
760
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
761 m_settings_dlg->setModal (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
762 m_settings_dlg->setAttribute (Qt::WA_DeleteOnClose);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
763 m_settings_dlg->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
764 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
765
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
766 void main_window::show_about_octave (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
767 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
768 std::string message
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
769 = octave_name_version_copyright_copying_warranty_and_bugs (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
770
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
771 QMessageBox::about (this, tr ("About Octave"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
772 QString::fromStdString (message));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
773 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
774
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
775 void main_window::notice_settings (const QSettings *settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
776 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
777 // QSettings pointer is checked before emitting.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
778
26227
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
779 // Get desired style from preferences or take the default one if
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
780 // the desired one is not found
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
781 QString preferred_style
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
782 = settings->value (global_style.key, global_style.def).toString ();
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
783
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
784 if (preferred_style == global_style.def.toString ())
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
785 preferred_style = m_default_style;
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
786
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
787 QStyle *new_style = QStyleFactory::create (preferred_style);
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
788 if (new_style)
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
789 {
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
790 QApplication *qapp = m_octave_qobj.qapplication ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
791
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
792 qapp->setStyle (new_style);
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
793 }
26227
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
794
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
795 // the widget's icons (when floating)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
796 QString icon_set
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
797 = settings->value ("DockWidgets/widget_icon_set", "NONE").toString ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
798
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
799 static struct
19422
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
800 {
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
801 QString name;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
802 QString path;
17883
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
803 }
17599
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
804
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
805 widget_icon_data[] =
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
806 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
807 // array of possible icon sets (name, path (complete for NONE))
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
808 // the first entry here is the default!
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
809 {"NONE", ":/actions/icons/logo.png"},
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
810 {"GRAPHIC", ":/actions/icons/graphic_logo_"},
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
811 {"LETTER", ":/actions/icons/letter_logo_"},
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
812 {"", ""} // end marker has empty name
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
813 };
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
814
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
815 int count = 0;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
816 int icon_set_found = 0; // default
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
817
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
818 while (! widget_icon_data[count].name.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
819 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
820 // while not end of data
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
821 if (widget_icon_data[count].name == icon_set)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
822 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
823 // data of desired icon set found
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
824 icon_set_found = count;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
825 break;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
826 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
827 count++;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
828 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
829
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
830 QString icon;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
831 foreach (octave_dock_widget *widget, dock_widget_list ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
832 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
833 QString name = widget->objectName ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
834 if (! name.isEmpty ())
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
835 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
836 // if children has a name
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
837 icon = widget_icon_data[icon_set_found].path; // prefix | octave-logo
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
838 if (widget_icon_data[icon_set_found].name != "NONE")
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
839 icon += name + ".png"; // add widget name and ext.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
840 widget->setWindowIcon (QIcon (icon));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
841 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
842 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
843 if (widget_icon_data[icon_set_found].name != "NONE")
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
844 m_release_notes_icon = widget_icon_data[icon_set_found].path
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
845 + "ReleaseWidget.png";
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
846 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
847 m_release_notes_icon = ":/actions/icons/logo.png";
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
848
26058
ecd86b8b8979 use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents: 25994
diff changeset
849 int size_idx = settings->value (global_icon_size.key,
ecd86b8b8979 use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents: 25994
diff changeset
850 global_icon_size.def).toInt ();
ecd86b8b8979 use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents: 25994
diff changeset
851 size_idx = (size_idx > 0) - (size_idx < 0) + 1; // Make valid index from 0 to 2
ecd86b8b8979 use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents: 25994
diff changeset
852
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
853 QStyle *st = style ();
26058
ecd86b8b8979 use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents: 25994
diff changeset
854 int icon_size = st->pixelMetric (global_icon_sizes[size_idx]);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
855 m_main_tool_bar->setIconSize (QSize (icon_size,icon_size));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
856
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
857 if (settings->value ("show_status_bar",true).toBool ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
858 m_status_bar->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
859 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
860 m_status_bar->hide ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
861
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
862 m_prevent_readline_conflicts
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
863 = settings->value ("shortcuts/prevent_readline_conflicts", true).toBool ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
864
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
865 m_suppress_dbg_location
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
866 = ! settings->value ("terminal/print_debug_location", false).toBool ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
867
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
868 resource_manager::update_network_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
869
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
870 emit active_dock_changed (nullptr, m_active_dock); // update dock widget styles
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
871
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
872 configure_shortcuts ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
873 set_global_shortcuts (m_active_dock == m_command_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
874 disable_menu_shortcuts (m_active_dock == m_editor_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
875
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
876 // Check whether some octave internal preferences have to be updated
25702
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
877 QString new_default_encoding
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
878 = settings->value (ed_default_enc.key, ed_default_enc.def).toString ();
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
879 if (new_default_encoding != m_default_encoding)
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
880 update_default_encoding (new_default_encoding);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
881
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
882 // Set cursor blinking depending on the settings
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
883 // Cursor blinking: consider old terminal related setting if not yet set
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
884 // TODO: This pref. can be deprecated / removed if Qt adds support for
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
885 // getting the cursor blink preferences from all OS environments
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
886 bool cursor_blinking;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
887
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
888 if (settings->contains (global_cursor_blinking.key))
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
889 cursor_blinking = settings->value (global_cursor_blinking.key,
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
890 global_cursor_blinking.def).toBool ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
891 else
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
892 cursor_blinking = settings->value (cs_cursor_blinking.key,
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
893 cs_cursor_blinking.def).toBool ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
894
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
895 if (cursor_blinking)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
896 QApplication::setCursorFlashTime (1000); // 1000 ms flash time
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
897 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
898 QApplication::setCursorFlashTime (0); // no flashing
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
899
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
900 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
901
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
902 bool main_window::confirm_shutdown_octave (void)
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
903 {
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
904 bool closenow = true;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
905
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
906 QSettings *settings = resource_manager::get_settings ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
907
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
908 if (settings->value ("prompt_to_exit", false).toBool ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
909 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
910 int ans = QMessageBox::question (this, tr ("Octave"),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
911 tr ("Are you sure you want to exit Octave?"),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
912 (QMessageBox::Ok
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
913 | QMessageBox::Cancel),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
914 QMessageBox::Ok);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
915
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
916 if (ans != QMessageBox::Ok)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
917 closenow = false;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
918 }
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
919
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
920 #if defined (HAVE_QSCINTILLA)
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
921 if (closenow)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
922 closenow = m_editor_window->check_closing ();
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
923 #endif
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
924
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
925 return closenow;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
926 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
927
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
928 void main_window::prepare_to_exit (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
929 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
930 // Find files dialog is constructed dynamically, not at time of main_window
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
931 // construction. Connecting it to qApp aboutToQuit signal would have
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
932 // caused it to run after QSettings deleted.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
933 if (m_find_files_dlg)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
934 m_find_files_dlg->save_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
935
27312
b9a436b0400e save and restore last geometry of load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27311
diff changeset
936 if (m_set_path_dlg)
b9a436b0400e save and restore last geometry of load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27311
diff changeset
937 m_set_path_dlg->save_settings ();
b9a436b0400e save and restore last geometry of load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27311
diff changeset
938
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
939 write_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
940 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
941
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
942 void main_window::reset_windows (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
943 {
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
944 hide ();
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
945 set_window_layout (nullptr); // do not use the settings file
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
946 showNormal (); // make sure main window is not minimized
24792
3390adaee21d * main-window.cc (reset_windows): set focus to console after resetting window layout
Torsten <mttl@mailbox.org>
parents: 24772
diff changeset
947 focus_command_window ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
948 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
949
27409
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
950 void main_window::update_octave_directory (const QString& dir)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
951 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
952 // Remove existing entry, if any, then add new directory at top and
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
953 // mark it as the current directory. Finally, update the file list
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
954 // widget.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
955
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
956 int index = m_current_directory_combo_box->findText (dir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
957
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
958 if (index >= 0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
959 m_current_directory_combo_box->removeItem (index);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
960
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
961 m_current_directory_combo_box->insertItem (0, dir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
962 m_current_directory_combo_box->setCurrentIndex (0);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
963 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
964
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
965 void main_window::browse_for_directory (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
966 {
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
967 // 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: 26067
diff changeset
968 int opts = QFileDialog::ShowDirsOnly;
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
969 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: 26067
diff changeset
970 true).toBool ())
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
971 opts = QFileDialog::DontUseNativeDialog;
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
972
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
973 QString dir
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
974 = QFileDialog::getExistingDirectory (this, tr ("Browse directories"), nullptr,
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
975 QFileDialog::Option (opts));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
976
15626
1cc10ce368ea enable entering a new directory in the current directory combobox
Torsten <ttl@justmail.de>
parents: 15607
diff changeset
977 set_current_working_directory (dir);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
978
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
979 // FIXME: on Windows systems, the command window freezes after the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
980 // previous actions. Forcing the focus appears to unstick it.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
981
24019
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
982 focus_command_window ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
983 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
984
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
985 void main_window::set_current_working_directory (const QString& dir)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
986 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
987 // Change to dir if it is an existing directory.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
988
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
989 QString xdir = (dir.isEmpty () ? "." : dir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
990
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
991 QFileInfo fileInfo (xdir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
992
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
993 if (fileInfo.exists () && fileInfo.isDir ())
25703
7b4e99fbe9d4 include builtin functions without interpreter argument being into octave_cmd
Torsten <mttl@mailbox.org>
parents: 25702
diff changeset
994 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
995 emit interpreter_event
27408
9b19eec60931 move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents: 27405
diff changeset
996 ([xdir] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
997 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
998 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
999
27408
9b19eec60931 move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents: 27405
diff changeset
1000 interp.chdir (xdir.toStdString ());
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1001 });
25703
7b4e99fbe9d4 include builtin functions without interpreter argument being into octave_cmd
Torsten <mttl@mailbox.org>
parents: 25702
diff changeset
1002 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1003 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1004
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1005 void main_window::change_directory_up (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1006 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1007 set_current_working_directory ("..");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1008 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1009
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1010 // Slot that is called if return is pressed in the line edit of the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1011 // combobox to change to a new directory or a directory that is already
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1012 // in the drop down list.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1013
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1014 void main_window::accept_directory_line_edit (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1015 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1016 // Get new directory name, and change to it if it is new. Otherwise,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1017 // the combo box will triggers the "activated" signal to change to the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1018 // directory.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1019
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1020 QString dir = m_current_directory_combo_box->currentText ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1021
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1022 int index = m_current_directory_combo_box->findText (dir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1023
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1024 if (index < 0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1025 set_current_working_directory (dir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1026 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1027
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1028 void main_window::execute_command_in_terminal (const QString& command)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1029 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1030 emit interpreter_event
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1031 ([command] (void)
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1032 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1033 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1034
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1035 std::string pending_input = command_editor::get_current_line ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1036
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1037 command_editor::set_initial_input (pending_input);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1038 command_editor::replace_line (command.toStdString ());
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1039 command_editor::redisplay ();
27339
64289bf338da use separate variable for interrupting command editor event loop (bug #56738)
John W. Eaton <jwe@octave.org>
parents: 27335
diff changeset
1040 command_editor::interrupt_event_loop ();
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1041 command_editor::accept_line ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1042 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1043
27556
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27478
diff changeset
1044 focus_console_after_command ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1045 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1046
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1047 void main_window::run_file_in_terminal (const QFileInfo& info)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1048 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1049 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1050 ([info] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1051 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1052 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1053
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1054 QString function_name = info.fileName ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1055 function_name.chop (info.suffix ().length () + 1);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1056 std::string file_path = info.absoluteFilePath ().toStdString ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1057
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1058 std::string pending_input = command_editor::get_current_line ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1059
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1060 if (valid_identifier (function_name.toStdString ()))
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1061 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1062 // Valid identifier: call as function with possibility to
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1063 // debug.
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1064
27396
930c0fbc003b move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents: 27393
diff changeset
1065 load_path& lp = interp.get_load_path ();
930c0fbc003b move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents: 27393
diff changeset
1066
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1067 std::string path = info.absolutePath ().toStdString ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1068
27396
930c0fbc003b move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents: 27393
diff changeset
1069 if (lp.contains_file_in_dir (file_path, path))
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1070 command_editor::replace_line (function_name.toStdString ());
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1071 }
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1072 else
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1073 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1074 // No valid identifier: use equivalent of Fsource (), no
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1075 // debug possible.
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1076
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1077 interp.source_file (file_path);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1078
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1079 command_editor::replace_line ("");
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1080 }
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1081
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1082 command_editor::set_initial_input (pending_input);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1083 command_editor::redisplay ();
27339
64289bf338da use separate variable for interrupting command editor event loop (bug #56738)
John W. Eaton <jwe@octave.org>
parents: 27335
diff changeset
1084 command_editor::interrupt_event_loop ();
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1085 command_editor::accept_line ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1086 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1087
27556
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27478
diff changeset
1088 focus_console_after_command ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1089 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1090
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1091 void main_window::handle_new_figure_request (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1092 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1093 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1094 ([] (interpreter& interp)
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1095 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1096 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1097
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1098 Fbuiltin (interp, ovl ("figure"));
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27312
diff changeset
1099 Fdrawnow (interp);
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1100 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1101 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1102
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1103 void main_window::handle_enter_debugger (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1104 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1105 setWindowTitle ("Octave (Debugging)");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1106
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1107 m_debug_continue->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1108 m_debug_step_into->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1109 m_debug_step_over->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1110 m_debug_step_out->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1111 m_debug_quit->setEnabled (true);
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
1112
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1113 #if defined (HAVE_QSCINTILLA)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1114 m_editor_window->handle_enter_debug_mode ();
15873
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15848
diff changeset
1115 #endif
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1116 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1117
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1118 void main_window::handle_exit_debugger (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1119 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1120 setWindowTitle ("Octave");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1121
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1122 m_debug_continue->setEnabled (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1123 m_debug_step_into->setEnabled (false);
26873
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1124 m_debug_step_over->setEnabled (m_editor_has_tabs);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1125 m_debug_step_out->setEnabled (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1126 m_debug_quit->setEnabled (false);
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
1127
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1128 #if defined (HAVE_QSCINTILLA)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1129 m_editor_window->handle_exit_debug_mode ();
15873
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15848
diff changeset
1130 #endif
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1131 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1132
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1133 void main_window::debug_continue (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1134 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1135 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1136 ([this] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1137 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1138 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1139
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1140 F__db_next_breakpoint_quiet__ (interp, ovl (m_suppress_dbg_location));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1141 Fdbcont (interp);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1142
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1143 command_editor::interrupt (true);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1144 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1145 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1146
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1147 void main_window::debug_step_into (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1148 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1149 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1150 ([this] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1151 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1152 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1153
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1154 F__db_next_breakpoint_quiet__ (interp, ovl (m_suppress_dbg_location));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1155 Fdbstep (interp, ovl ("in"));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1156
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1157 command_editor::interrupt (true);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1158 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1159 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1160
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1161 void main_window::debug_step_over (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1162 {
26873
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1163 if (m_debug_quit->isEnabled ())
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1164 {
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1165 // We are in debug mode, just call dbstep.
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1166
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1167 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1168 ([this] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1169 {
27393
efe72866b483 mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents: 27391
diff changeset
1170 // INTERPRETER THREAD
efe72866b483 mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents: 27391
diff changeset
1171
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1172 F__db_next_breakpoint_quiet__ (interp,
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1173 ovl (m_suppress_dbg_location));
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1174 Fdbstep (interp);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1175
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1176 command_editor::interrupt (true);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1177 });
26873
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1178 }
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1179 else
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1180 {
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1181 // Not in debug mode: "step into" the current editor file
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1182 emit step_into_file_signal ();
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1183 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1184 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1185
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1186 void main_window::debug_step_out (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1187 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1188 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1189 ([this] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1190 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1191 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1192
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1193 F__db_next_breakpoint_quiet__ (interp, ovl (m_suppress_dbg_location));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1194 Fdbstep (interp, ovl ("out"));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1195
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1196 command_editor::interrupt (true);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1197 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1198 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1199
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1200 void main_window::debug_quit (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1201 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1202 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1203 ([] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1204 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1205 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1206
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1207 Fdbquit (interp);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1208
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1209 command_editor::interrupt (true);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1210 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1211 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1212
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1213 //
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1214 // Functions related to file editing
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1215 //
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1216 // These are moved from editor to here for also using them when octave
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1217 // is built without qscintilla
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1218 //
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1219 void main_window::request_open_file (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1220 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1221 // Open file isn't a file_editor_tab or editor function since the file
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1222 // might be opened in an external editor. Hence, functionality is here.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1223
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1224 QSettings *settings = resource_manager::get_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1225 bool is_internal = m_editor_window
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25091
diff changeset
1226 && ! settings->value ("useCustomFileEditor",false).toBool ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1227
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1228 // Create a NonModal message.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1229 QWidget *p = this;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1230 if (is_internal)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1231 p = m_editor_window;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1232 QFileDialog *fileDialog = new QFileDialog (p);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1233 fileDialog->setNameFilter (tr ("Octave Files (*.m);;All Files (*)"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1234
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1235 fileDialog->setAcceptMode (QFileDialog::AcceptOpen);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1236 fileDialog->setViewMode (QFileDialog::Detail);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1237 fileDialog->setFileMode (QFileDialog::ExistingFiles);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1238 fileDialog->setDirectory (m_current_directory_combo_box->itemText (0));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1239
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
1240 // 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: 26067
diff changeset
1241 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: 26067
diff changeset
1242 true).toBool ())
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
1243 fileDialog->setOption(QFileDialog::DontUseNativeDialog);
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
1244
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1245 connect (fileDialog, SIGNAL (filesSelected (const QStringList&)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1246 this, SLOT (request_open_files (const QStringList&)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1247
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1248 fileDialog->setWindowModality (Qt::NonModal);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1249 fileDialog->setAttribute (Qt::WA_DeleteOnClose);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1250 fileDialog->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1251 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1252
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1253 // Create a new script
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1254 void main_window::request_new_script (const QString& commands)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1255 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1256 emit new_file_signal (commands);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1257 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1258
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1259 // Create a new function and open it
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1260 void main_window::request_new_function (bool)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1261 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1262 bool ok;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1263 // Get the name of the new function: Parent of the input dialog is the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1264 // editor window or the main window. The latter is chosen, if a custom
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1265 // editor is used or qscintilla is not available
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1266 QWidget *p = m_editor_window;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1267 QSettings *settings = resource_manager::get_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1268 if (! p || settings->value ("useCustomFileEditor",false).toBool ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1269 p = this;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1270 QString new_name = QInputDialog::getText (p, tr ("New Function"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1271 tr ("New function name:\n"), QLineEdit::Normal, "", &ok);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1272
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1273 if (ok && new_name.length () > 0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1274 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1275 // append suffix if it not already exists
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1276 if (new_name.rightRef (2) != ".m")
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1277 new_name.append (".m");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1278 // check whether new files are created without prompt
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1279 if (! settings->value ("editor/create_new_file",false).toBool ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1280 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1281 // no, so enable this settings and wait for end of new file loading
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1282 settings->setValue ("editor/create_new_file",true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1283 connect (m_editor_window, SIGNAL (file_loaded_signal (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1284 this, SLOT (restore_create_file_setting (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1285 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1286 // start the edit command
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1287 execute_command_in_terminal ("edit " + new_name);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1288 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1289 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1290
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1291 void main_window::handle_edit_mfile_request (const QString& fname,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1292 const QString& ffile,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1293 const QString& curr_dir,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1294 int line)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1295 {
27377
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1296 emit interpreter_event
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1297 ([this, fname, ffile, curr_dir, line] (interpreter& interp)
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1298 {
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1299 // INTERPRETER THREAD
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1300
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1301 // Split possible subfuntions
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1302 QStringList fcn_list = fname.split ('>');
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1303 QString fcn_name = fcn_list.at (0) + ".m";
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1304
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1305 // FIXME: could use symbol_exist directly, but we may also want
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1306 // to fix that to be a member function in the interpreter
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1307 // class?
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1308
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1309 // Is it a regular function within the search path? (Call Fexist)
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1310 octave_value_list fct = Fexist (interp, ovl (fname.toStdString ()),0);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1311 int type = fct (0).int_value ();
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1312
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1313 QString message = QString ();
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1314 QString filename = QString ();
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1315
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1316 switch (type)
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1317 {
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1318 case 3:
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1319 case 5:
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1320 case 103:
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1321 message = tr ("%1 is a built-in, compiled or inline\n"
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1322 "function and can not be edited.");
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1323 break;
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1324
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1325 case 2:
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1326 // FIXME: could use a load_path function directly.
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1327 octave_value_list file_path
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1328 = Ffile_in_loadpath (interp, ovl (fcn_name.toStdString ()), 0);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1329 if (file_path.length () > 0)
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1330 filename = QString::fromStdString (file_path (0).string_value ());
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1331 break;
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1332 }
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1333
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1334 if (filename.isEmpty () && message.isEmpty ())
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1335 {
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1336 // No error so far, but function still not known
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1337 // -> try directory of edited file
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1338 // get directory
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1339 QDir dir;
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1340 if (ffile.isEmpty ())
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1341 {
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1342 if (curr_dir.isEmpty ())
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1343 dir = QDir (m_current_directory_combo_box->itemText (0));
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1344 else
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1345 dir = QDir (curr_dir);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1346 }
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1347 else
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1348 dir = QDir (QFileInfo (ffile).canonicalPath ());
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1349
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1350 QFileInfo file = QFileInfo (dir, fcn_name);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1351 if (file.exists ())
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1352 filename = file.canonicalFilePath (); // local file exists
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1353 else
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1354 {
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1355 // local file does not exist -> try private directory
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1356 file = QFileInfo (ffile);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1357 file = QFileInfo (QDir (file.canonicalPath () + "/private"),
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1358 fcn_name);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1359 if (file.exists ())
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1360 filename = file.canonicalFilePath (); // private function exists
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1361 else
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1362 message = tr ("Can not find function %1"); // no file found
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1363
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1364 }
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1365 }
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1366
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1367 if (! message.isEmpty ())
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1368 {
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1369 QMessageBox *msgBox
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1370 = new QMessageBox (QMessageBox::Critical,
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1371 tr ("Octave Editor"),
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1372 message.arg (fname),
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1373 QMessageBox::Ok, this);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1374
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1375 msgBox->setWindowModality (Qt::NonModal);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1376 msgBox->setAttribute (Qt::WA_DeleteOnClose);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1377 msgBox->show ();
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1378 return;
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1379 }
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1380
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1381 if (! filename.endsWith (".m"))
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1382 filename.append (".m");
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1383
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1384 // default encoding
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1385 emit open_file_signal (filename, QString (), line);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1386 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1387 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1388
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1389 void main_window::handle_insert_debugger_pointer_request (const QString& file,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1390 int line)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1391 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1392 bool cmd_focus = command_window_has_focus ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1393
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1394 emit insert_debugger_pointer_signal (file, line);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1395
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1396 if (cmd_focus)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1397 focus_command_window ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1398 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1399
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1400 void main_window::handle_delete_debugger_pointer_request (const QString& file,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1401 int line)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1402 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1403 bool cmd_focus = command_window_has_focus ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1404
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1405 emit delete_debugger_pointer_signal (file, line);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1406
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1407 if (cmd_focus)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1408 focus_command_window ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1409 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1410
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1411 void main_window::handle_update_breakpoint_marker_request (bool insert,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1412 const QString& file,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1413 int line,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1414 const QString& cond)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1415 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1416 bool cmd_focus = command_window_has_focus ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1417
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1418 emit update_breakpoint_marker_signal (insert, file, line, cond);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1419
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1420 if (cmd_focus)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1421 focus_command_window ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1422 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1423
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1424 void main_window::read_settings (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1425 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1426 QSettings *settings = resource_manager::get_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1427
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1428 if (! settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1429 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1430 qDebug ("Error: QSettings pointer from resource manager is NULL.");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1431 return;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1432 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1433
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1434 set_window_layout (settings);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1435
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1436 // restore the list of the last directories
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1437 QStringList curr_dirs
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1438 = settings->value ("MainWindow/current_directory_list").toStringList ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1439 for (int i=0; i < curr_dirs.size (); i++)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1440 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1441 m_current_directory_combo_box->addItem (curr_dirs.at (i));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1442 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1443 emit settings_changed (settings);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1444 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1445
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1446 void main_window::init_terminal_size (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1447 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1448 emit init_terminal_size_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1449 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1450
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1451 void main_window::set_window_layout (QSettings *settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1452 {
26299
c95884eed1cf make restoring gui more robust to changes of desktop size (bug #53207)
Torsten <mttl@mailbox.org>
parents: 26277
diff changeset
1453 // Restore main window state and geometry from settings file or, in case
c95884eed1cf make restoring gui more robust to changes of desktop size (bug #53207)
Torsten <mttl@mailbox.org>
parents: 26277
diff changeset
1454 // of an error from the default layout
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1455 if (settings)
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1456 {
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
1457 if (! restoreState (settings->value (mw_state.key, mw_state.def).toByteArray ()))
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1458 restoreState (mw_state.def.toByteArray ());
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1459
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
1460 if (! restoreGeometry (settings->value (mw_geometry.key, mw_geometry.def).toByteArray ()))
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1461 restoreGeometry (mw_geometry.def.toByteArray ());
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1462 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1463
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1464 // Restore the geometry of all dock-widgets
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1465 foreach (octave_dock_widget *widget, dock_widget_list ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1466 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1467 QString name = widget->objectName ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1468
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1469 if (! name.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1470 {
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1471 bool floating = false;
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1472 bool visible = true;
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1473 if (settings)
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1474 {
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1475 floating = settings->value
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1476 ("DockWidgets/" + name + "Floating", false).toBool ();
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1477 visible = settings->value
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1478 ("DockWidgets/" + name + "Visible", true).toBool ();
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1479 }
17899
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17890
diff changeset
1480
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1481 // If floating, make window from widget.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1482 if (floating)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1483 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1484 widget->make_window ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1485
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1486 if (visible)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1487 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
1488 if (settings && settings->value ("DockWidgets/" + name
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27276
diff changeset
1489 + "_minimized").toBool ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1490 widget->showMinimized ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1491 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1492 widget->setVisible (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1493 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1494 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1495 else // not floating
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1496 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1497 if (! widget->parent ()) // should not be floating but is
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1498 widget->make_widget (false); // no docking, just reparent
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1499
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1500 widget->make_widget ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1501 widget->setVisible (visible); // not floating -> show
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1502 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1503 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1504 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1505
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1506 if (! settings)
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1507 {
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1508 restoreGeometry (mw_geometry.def.toByteArray ());
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1509 restoreState (mw_state.def.toByteArray ());
26643
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
1510
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
1511 QDesktopWidget *m_desktop = QApplication::desktop ();
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
1512 int screen = m_desktop->screenNumber (this); // screen of the main window
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
1513 QRect screen_geo = m_desktop->availableGeometry (screen);
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
1514
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
1515 int win_x = screen_geo.width (); // width of the screen
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
1516 int win_y = screen_geo.height (); // height of the screen
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
1517
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
1518 resize (std::max (width (), 2*win_x/3), std::max (height (), 7*win_y/8));
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1519 }
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1520
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1521 show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1522 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1523
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1524 void main_window::write_settings (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1525 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1526 QSettings *settings = resource_manager::get_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1527 if (! settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1528 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1529 qDebug ("Error: QSettings pointer from resource manager is NULL.");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1530 return;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1531 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1532
27562
d7876110e854 use symbolic preference keys if available
John W. Eaton <jwe@octave.org>
parents: 27560
diff changeset
1533 settings->setValue (mw_geometry.key, saveGeometry ());
d7876110e854 use symbolic preference keys if available
John W. Eaton <jwe@octave.org>
parents: 27560
diff changeset
1534 settings->setValue (mw_state.key, saveState ());
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1535 // write the list of recent used directories
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1536 QStringList curr_dirs;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1537 for (int i=0; i<m_current_directory_combo_box->count (); i++)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1538 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1539 curr_dirs.append (m_current_directory_combo_box->itemText (i));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1540 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1541 settings->setValue ("MainWindow/current_directory_list", curr_dirs);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1542 settings->sync ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1543 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1544
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1545 // Connecting the signals emitted when the visibility of a widget changes.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1546 // This has to be done after the window is shown (see octave-gui.cc)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1547 void main_window::connect_visibility_changed (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1548 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1549 foreach (octave_dock_widget *widget, dock_widget_list ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1550 widget->connect_visibility_changed ();
18944
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
1551
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1552 #if defined (HAVE_QSCINTILLA)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1553 m_editor_window->enable_menu_shortcuts (false);
19589
4fe86a372f10 Fix compilation error when building without QScintilla
Mike Miller <mtmiller@ieee.org>
parents: 19585
diff changeset
1554 #endif
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1555 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1556
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1557 void main_window::copyClipboard (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1558 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1559 if (m_current_directory_combo_box->hasFocus ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1560 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1561 QLineEdit *edit = m_current_directory_combo_box->lineEdit ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1562 if (edit && edit->hasSelectedText ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1563 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1564 QClipboard *clipboard = QApplication::clipboard ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1565 clipboard->setText (edit->selectedText ());
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1566 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1567 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1568 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1569 emit copyClipboard_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1570 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1571
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1572 void main_window::pasteClipboard (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1573 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1574 if (m_current_directory_combo_box->hasFocus ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1575 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1576 QLineEdit *edit = m_current_directory_combo_box->lineEdit ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1577 QClipboard *clipboard = QApplication::clipboard ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1578 QString str = clipboard->text ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1579 if (edit && str.length () > 0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1580 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1581 edit->insert (str);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1582 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1583 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1584 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1585 emit pasteClipboard_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1586 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1587
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1588 void main_window::selectAll (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1589 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1590 if (m_current_directory_combo_box->hasFocus ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1591 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1592 QLineEdit *edit = m_current_directory_combo_box->lineEdit ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1593 if (edit)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1594 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1595 edit->selectAll ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1596 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1597 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1598 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1599 emit selectAll_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1600 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1601
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1602 void main_window::handle_show_doc (const QString& file)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1603 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1604 m_doc_browser_window->setVisible (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1605 emit show_doc_signal (file);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1606 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1607
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1608 void main_window::handle_register_doc (const QString& file)
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1609 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1610 emit register_doc_signal (file);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1611 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1612
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1613 void main_window::handle_unregister_doc (const QString& file)
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1614 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1615 emit unregister_doc_signal (file);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1616 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1617
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1618 void main_window::handle_octave_ready (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1619 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1620 // actions after the startup files are executed
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1621 QSettings *settings = resource_manager::get_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1622
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1623 QDir startup_dir = QDir (); // current octave dir after startup
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1624
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1625 if (settings)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1626 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1627 if (settings->value ("restore_octave_dir").toBool ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1628 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1629 // restore last dir from previous session
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1630 QStringList curr_dirs
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1631 = settings->value ("MainWindow/current_directory_list").toStringList ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1632 startup_dir
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1633 = QDir (curr_dirs.at (0)); // last dir in previous session
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1634 }
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1635 else if (! settings->value ("octave_startup_dir").toString ().isEmpty ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1636 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1637 // do not restore but there is a startup dir configured
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1638 startup_dir
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1639 = QDir (settings->value ("octave_startup_dir").toString ());
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1640 }
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
1641
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
1642 update_default_encoding
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
1643 (settings->value (ed_default_enc.key,
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
1644 ed_default_enc.def).toString ());
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1645 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1646
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1647 if (! startup_dir.exists ())
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1648 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1649 // the configured startup dir does not exist, take actual one
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1650 startup_dir = QDir ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1651 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1652
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1653 set_current_working_directory (startup_dir.absolutePath ());
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1654
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1655 if (m_editor_window)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1656 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1657 #if defined (HAVE_QSCINTILLA)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1658 // Octave ready, determine whether to create an empty script.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1659 // This can not be done when the editor is created because all functions
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1660 // must be known for the lexer's auto completion informations
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1661 m_editor_window->empty_script (true, false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1662 m_editor_window->restore_session (settings);
18833
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18823
diff changeset
1663 #endif
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1664 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1665
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1666 focus_command_window (); // make sure that the command window has focus
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1667 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1668
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1669 void main_window::handle_set_path_dialog_request (void)
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1670 {
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1671 if (m_set_path_dlg) // m_set_path_dlg is a guarded pointer!
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1672 return;
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1673
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1674 m_set_path_dlg = new set_path_dialog (this);
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1675
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1676 m_set_path_dlg->setModal (false);
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1677 m_set_path_dlg->setAttribute (Qt::WA_DeleteOnClose);
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1678 m_set_path_dlg->show ();
27306
82ace1225a9c update path dialog if path is changed from withtin the file browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27302
diff changeset
1679
27391
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1680 // Any interpreter_event signal from a set_path_dialog object is
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1681 // handled the same as for the main_window object.
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1682
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1683 connect (m_set_path_dlg, SIGNAL (interpreter_event (const fcn_callback&)),
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1684 this, SIGNAL (interpreter_event (const fcn_callback&)));
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1685
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1686 connect (m_set_path_dlg, SIGNAL (interpreter_event (const meth_callback&)),
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1687 this, SIGNAL (interpreter_event (const meth_callback&)));
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1688
27308
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
1689 connect (m_set_path_dlg,
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
1690 SIGNAL (modify_path_signal (const octave_value_list&, bool, bool)),
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
1691 this, SLOT (modify_path (const octave_value_list&, bool, bool)));
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
1692
27311
0040b7668518 update load path dialog when path is modified via console
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27308
diff changeset
1693 interpreter_qobject *interp_qobj = m_octave_qobj.interpreter_qobj ();
27391
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1694
27311
0040b7668518 update load path dialog when path is modified via console
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27308
diff changeset
1695 qt_interpreter_events *qt_link = interp_qobj->qt_link ();
27391
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1696
27311
0040b7668518 update load path dialog when path is modified via console
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27308
diff changeset
1697 connect (qt_link, SIGNAL (update_path_dialog_signal (void)),
27306
82ace1225a9c update path dialog if path is changed from withtin the file browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27302
diff changeset
1698 m_set_path_dlg, SLOT (update_model (void)));
27391
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1699
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1700 // Now that all the signal connections are in place for the dialog
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1701 // we can set the initial value of the path in the model.
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1702
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1703 m_set_path_dlg->update_model ();
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1704 }
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1705
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1706 void main_window::find_files (const QString& start_dir)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1707 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1708
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1709 if (! m_find_files_dlg)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1710 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1711 m_find_files_dlg = new find_files_dialog (this);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1712
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1713 connect (m_find_files_dlg, SIGNAL (finished (int)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1714 this, SLOT (find_files_finished (int)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1716 connect (m_find_files_dlg, SIGNAL (dir_selected (const QString &)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1717 m_file_browser_window,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1718 SLOT (set_current_directory (const QString&)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1719
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1720 connect (m_find_files_dlg, SIGNAL (file_selected (const QString &)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1721 this, SLOT (open_file (const QString &)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1722
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1723 m_find_files_dlg->setWindowModality (Qt::NonModal);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1724 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1725
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1726 if (! m_find_files_dlg->isVisible ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1727 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1728 m_find_files_dlg->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1729 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1730
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1731 m_find_files_dlg->set_search_dir (start_dir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1732
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1733 m_find_files_dlg->activateWindow ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1734
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1735 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1736
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1737 void main_window::set_global_shortcuts (bool set_shortcuts)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1738 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1739 // this slot is called when the terminal gets/loses focus
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1740
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1741 // return if the user don't want to use readline shortcuts
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1742 if (! m_prevent_readline_conflicts)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1743 return;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1744
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1745 if (set_shortcuts)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1746 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1747 // terminal loses focus: set the global shortcuts
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1748 configure_shortcuts ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1749 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1750 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1751 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1752 // terminal gets focus: disable some shortcuts
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1753 QKeySequence no_key = QKeySequence ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1754
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1755 // file menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1756 m_open_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1757 m_new_script_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1758 m_new_function_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1759 m_new_function_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1760 m_load_workspace_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1761 m_save_workspace_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1762 m_preferences_action->setShortcut (no_key);
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1763 m_set_path_action->setShortcut (no_key);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1764 m_exit_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1765
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1766 // edit menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1767 m_select_all_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1768 m_clear_clipboard_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1769 m_find_files_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1770 m_clear_command_history_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1771 m_clear_command_window_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1772 m_clear_workspace_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1773
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1774 // window menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1775 m_reset_windows_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1776
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1777 // help menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1778 m_ondisk_doc_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1779 m_online_doc_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1780 m_report_bug_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1781 m_octave_packages_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1782 m_contribute_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1783 m_developer_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1784 m_about_octave_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1785
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1786 // news menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1787 m_release_notes_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1788 m_current_news_action->setShortcut (no_key);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1789 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1790 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1791
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1792 void main_window::set_screen_size (int ht, int wd)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1793 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1794 emit interpreter_event
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1795 ([ht, wd] (void)
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1796 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1797 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1798
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1799 command_editor::set_screen_size (ht, wd);
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1800 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1801 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1802
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1803 void main_window::clipboard_has_changed (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1804 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1805 if (m_clipboard->text ().isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1806 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1807 m_paste_action->setEnabled (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1808 m_clear_clipboard_action->setEnabled (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1809 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1810 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1811 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1812 m_paste_action->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1813 m_clear_clipboard_action->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1814 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1815 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1816
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1817 void main_window::clear_clipboard (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1818 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1819 m_clipboard->clear (QClipboard::Clipboard);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1820 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1821
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1822 void main_window::disable_menu_shortcuts (bool disable)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1823 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1824 QHash<QMenu*, QStringList>::const_iterator i = m_hash_menu_text.constBegin ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1825
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1826 while (i != m_hash_menu_text.constEnd ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1827 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1828 i.key ()->setTitle (i.value ().at (disable));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1829 ++i;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1830 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1831 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1832
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1833 void main_window::restore_create_file_setting (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1834 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1835 // restore the new files creation setting
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1836 QSettings *settings = resource_manager::get_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1837 settings->setValue ("editor/create_new_file",false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1838 disconnect (m_editor_window, SIGNAL (file_loaded_signal (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1839 this, SLOT (restore_create_file_setting (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1840 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1841
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1842 void main_window::set_file_encoding (const QString& new_encoding)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1843 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1844 m_file_encoding = new_encoding;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1845 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1846
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1847 // The following slot is called after files have been selected in the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1848 // open file dialog., possibly with a new selected encoding stored in
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1849 // m_file_encoding
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1850 void main_window::request_open_files (const QStringList& open_file_names)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1851 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1852 for (int i = 0; i < open_file_names.count (); i++)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1853 emit open_file_signal (open_file_names.at (i), m_file_encoding, -1);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1854 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1855
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1856 void main_window::edit_variable (const QString &expr, const octave_value& val)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1857 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1858 m_variable_editor_window->edit_variable (expr, val);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1859
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1860 if (! m_variable_editor_window->isVisible ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1861 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1862 m_variable_editor_window->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1863 m_variable_editor_window->raise ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1864 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1865
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1866 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1867
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1868 void main_window::refresh_variable_editor (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1869 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1870 m_variable_editor_window->refresh ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1871 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1872
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1873 void main_window::handle_variable_editor_update (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1874 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1875 // Called when the variable editor emits the updated signal. The size
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1876 // of a variable may have changed, so we refresh the workspace in the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1877 // interpreter. That will eventually cause the workspace view in the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1878 // GUI to be updated.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1879
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1880 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1881 ([] (interpreter& interp)
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1882 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1883 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1884
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
1885 tree_evaluator& tw = interp.get_evaluator ();
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
1886
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
1887 event_manager& xevmgr = interp.get_event_manager ();
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
1888
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
1889 xevmgr.set_workspace (true, tw.get_symbol_info (), false);
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1890 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1891 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1892
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1893 void main_window::closeEvent (QCloseEvent *e)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1894 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1895 e->ignore ();
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1896
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1897 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1898 ([] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1899 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1900 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1901
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
1902 Fquit (interp);
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1903 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1904 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1905
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1906 void main_window::construct_central_widget (void)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1907 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1908 // Create and set the central widget. QMainWindow takes ownership of
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1909 // the widget (pointer) so there is no need to delete the object upon
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1910 // destroying this main_window.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1911
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1912 QWidget *dummyWidget = new QWidget ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1913 dummyWidget->setObjectName ("CentralDummyWidget");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1914 dummyWidget->resize (10, 10);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1915 dummyWidget->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1916 dummyWidget->hide ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1917 setCentralWidget (dummyWidget);
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1918 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1919
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1920 // Main subroutine of the constructor
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1921
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1922 void main_window::construct (void)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1923 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1924 setWindowIcon (QIcon (":/actions/icons/logo.png"));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1925
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1926 m_workspace_window->setModel (m_workspace_model);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1927
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1928 connect (m_workspace_model, SIGNAL (model_changed (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1929 m_workspace_window, SLOT (handle_model_changed (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1930
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
1931 interpreter_qobject *interp_qobj = m_octave_qobj.interpreter_qobj ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
1932
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
1933 qt_interpreter_events *qt_link = interp_qobj->qt_link ();
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
1934
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
1935 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1936 SIGNAL (edit_variable_signal (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1937 const octave_value&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1938 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1939 SLOT (edit_variable (const QString&, const octave_value&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1940
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
1941 connect (qt_link, SIGNAL (refresh_variable_editor_signal (void)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1942 this, SLOT (refresh_variable_editor (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1943
27220
9a4a9fcc186b connect workspace view rename variable signal to main window slot
John W. Eaton <jwe@octave.org>
parents: 27219
diff changeset
1944 connect (m_workspace_window,
9a4a9fcc186b connect workspace view rename variable signal to main window slot
John W. Eaton <jwe@octave.org>
parents: 27219
diff changeset
1945 SIGNAL (rename_variable_signal (const QString&, const QString&)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1946 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1947 SLOT (handle_rename_variable_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1948 const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1949
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1950 connect (m_variable_editor_window, SIGNAL (updated (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1951 this, SLOT (handle_variable_editor_update (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1952
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1953 construct_menu_bar ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1954
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1955 construct_tool_bar ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1956
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1957 // Order is important. Deleting QSettings must be last.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1958 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1959 m_command_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1960
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1961 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1962 m_history_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1963
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1964 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1965 m_file_browser_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1966
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1967 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1968 m_doc_browser_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1969
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1970 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1971 m_workspace_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1972
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1973 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1974 m_editor_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1975
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1976 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1977 m_variable_editor_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1978
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1979 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1980 this, SLOT (prepare_to_exit (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1981
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1982 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1983 shortcut_manager::instance, SLOT (cleanup_instance (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1984
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1985 // QSettings are saved upon deletion (i.e., cleanup_instance)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1986 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1987 resource_manager::instance, SLOT (cleanup_instance (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1988
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1989 connect (qApp, SIGNAL (focusChanged (QWidget*, QWidget*)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1990 this, SLOT (focus_changed (QWidget*, QWidget*)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1991
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1992 connect (this, SIGNAL (settings_changed (const QSettings *)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1993 this, SLOT (notice_settings (const QSettings *)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1994
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1995 connect (this, SIGNAL (editor_focus_changed (bool)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1996 this, SLOT (disable_menu_shortcuts (bool)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1997
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1998 connect (this, SIGNAL (editor_focus_changed (bool)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1999 m_editor_window, SLOT (enable_menu_shortcuts (bool)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2000
26873
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2001 connect (this, SIGNAL (step_into_file_signal (void)),
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2002 m_editor_window, SLOT (request_step_into_file (void)));
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2003
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2004 connect (m_editor_window, SIGNAL (editor_tabs_changed_signal (bool)),
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2005 this, SLOT (editor_tabs_changed (bool)));
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2006
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2007 connect (m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2008 SIGNAL (request_open_file_external (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2009 m_external_editor,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2010 SLOT (call_custom_editor (const QString&, int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2011
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2012 connect (m_external_editor,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2013 SIGNAL (request_settings_dialog (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2014 this, SLOT (process_settings_dialog_request (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2015
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2016 connect (m_file_browser_window, SIGNAL (load_file_signal (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2017 this, SLOT (handle_load_workspace_request (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2018
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2019 connect (m_file_browser_window, SIGNAL (open_any_signal (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2020 this, SLOT (handle_open_any_request (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2021
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2022 connect (m_file_browser_window, SIGNAL (find_files_signal (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2023 this, SLOT (find_files (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2024
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2025 setWindowTitle ("Octave");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2026
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2027 // See Octave bug #53409 and https://bugreports.qt.io/browse/QTBUG-55357
25091
2b8442c890d8 Fix locked GUI panels for Qt 5.6.1 through 5.7.0 series versions (bug #53409)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25060
diff changeset
2028 #if (QT_VERSION < 0x050601) || (QT_VERSION >= 0x050701)
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2029 setDockOptions (QMainWindow::AnimatedDocks
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2030 | QMainWindow::AllowNestedDocks
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2031 | QMainWindow::AllowTabbedDocks);
25091
2b8442c890d8 Fix locked GUI panels for Qt 5.6.1 through 5.7.0 series versions (bug #53409)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25060
diff changeset
2032 #else
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2033 setDockNestingEnabled (true);
25091
2b8442c890d8 Fix locked GUI panels for Qt 5.6.1 through 5.7.0 series versions (bug #53409)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 25060
diff changeset
2034 #endif
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2035
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2036 addDockWidget (Qt::RightDockWidgetArea, m_command_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2037 addDockWidget (Qt::RightDockWidgetArea, m_doc_browser_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2038 tabifyDockWidget (m_command_window, m_doc_browser_window);
24019
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
2039
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
2040 #if defined (HAVE_QSCINTILLA)
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2041 addDockWidget (Qt::RightDockWidgetArea, m_editor_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2042 tabifyDockWidget (m_command_window, m_editor_window);
24019
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
2043 #endif
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2044 addDockWidget (Qt::RightDockWidgetArea, m_variable_editor_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2045 tabifyDockWidget (m_command_window, m_variable_editor_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2046
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2047 addDockWidget (Qt::LeftDockWidgetArea, m_file_browser_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2048 addDockWidget (Qt::LeftDockWidgetArea, m_workspace_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2049 addDockWidget (Qt::LeftDockWidgetArea, m_history_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2050
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2051 int win_x = QApplication::desktop ()->width ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2052 int win_y = QApplication::desktop ()->height ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2053
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2054 if (win_x > 960)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2055 win_x = 960;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2056
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2057 if (win_y > 720)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2058 win_y = 720;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2059
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2060 setGeometry (0, 0, win_x, win_y);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2061
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2062 setStatusBar (m_status_bar);
24019
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
2063
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
2064 #if defined (HAVE_QSCINTILLA)
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2065 connect (this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2066 SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2067 m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2068 SLOT (handle_insert_debugger_pointer_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2069 int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2070
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2071 connect (this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2072 SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2073 m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2074 SLOT (handle_delete_debugger_pointer_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2075 int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2076
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2077 connect (this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2078 SIGNAL (update_breakpoint_marker_signal (bool, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2079 int, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2080 m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2081 SLOT (handle_update_breakpoint_marker_request (bool,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2082 const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2083 int,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2084 const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2085
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2086 // Signals for removing/renaming files/dirs in the file browser
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2087 connect (m_file_browser_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2088 SIGNAL (file_remove_signal (const QString&, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2089 m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2090 SLOT (handle_file_remove (const QString&, const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2091
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2092 connect (m_file_browser_window, SIGNAL (file_renamed_signal (bool)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2093 m_editor_window, SLOT (handle_file_renamed (bool)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2094
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2095 // Signals for removing/renaming files/dirs in the temrinal window
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2096 connect (qt_link, SIGNAL (file_renamed_signal (bool)),
27039
32d9f57d7245 fix missing unlock of mutex when gui editor is not present (bug #56097)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2097 m_editor_window, SLOT (handle_file_renamed (bool)));
32d9f57d7245 fix missing unlock of mutex when gui editor is not present (bug #56097)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2098 #endif
32d9f57d7245 fix missing unlock of mutex when gui editor is not present (bug #56097)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2099
32d9f57d7245 fix missing unlock of mutex when gui editor is not present (bug #56097)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2100 // Signals for removing/renaming files/dirs in the temrinal window
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2101 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2102 SIGNAL (file_remove_signal (const QString&, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2103 this, SLOT (file_remove_proxy (const QString&, const QString&)));
24019
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
2104
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2105 connect (this, SIGNAL (interpreter_event (const fcn_callback&)),
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2106 &m_octave_qobj, SLOT (interpreter_event (const fcn_callback&)));
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2107
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2108 connect (this, SIGNAL (interpreter_event (const meth_callback&)),
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2109 &m_octave_qobj, SLOT (interpreter_event (const meth_callback&)));
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2110
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2111 configure_shortcuts ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2112 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2113
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2114 void main_window::construct_octave_qt_link (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2115 {
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2116 interpreter_qobject *interp_qobj = m_octave_qobj.interpreter_qobj ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2117
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
2118 qt_interpreter_events *qt_link = interp_qobj->qt_link ();
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2119
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2120 connect (qt_link,
26117
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 26115
diff changeset
2121 SIGNAL (set_workspace_signal (bool, bool, const symbol_info_list&)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2122 m_workspace_model,
26117
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 26115
diff changeset
2123 SLOT (set_workspace (bool, bool, const symbol_info_list&)));
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2124
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2125 connect (qt_link, SIGNAL (clear_workspace_signal (void)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2126 m_workspace_model, SLOT (clear_workspace (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2127
27409
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
2128 connect (qt_link, SIGNAL (directory_changed_signal (QString)),
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
2129 this, SLOT (update_octave_directory (QString)));
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
2130
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
2131 connect (qt_link, SIGNAL (directory_changed_signal (QString)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2132 m_file_browser_window, SLOT (update_octave_directory (QString)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2133
27409
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
2134 connect (qt_link, SIGNAL (directory_changed_signal (QString)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2135 m_editor_window, SLOT (update_octave_directory (QString)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2136
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2137 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2138 SIGNAL (execute_command_in_terminal_signal (QString)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2139 this, SLOT (execute_command_in_terminal (QString)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2140
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2141 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2142 SIGNAL (set_history_signal (const QStringList&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2143 m_history_window, SLOT (set_history (const QStringList&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2144
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2145 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2146 SIGNAL (append_history_signal (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2147 m_history_window, SLOT (append_history (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2148
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2149 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2150 SIGNAL (clear_history_signal (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2151 m_history_window, SLOT (clear_history (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2152
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2153 connect (qt_link, SIGNAL (enter_debugger_signal (void)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2154 this, SLOT (handle_enter_debugger (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2155
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2156 connect (qt_link, SIGNAL (exit_debugger_signal (void)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2157 this, SLOT (handle_exit_debugger (void)));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2158
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2159 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2160 SIGNAL (show_preferences_signal (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2161 this, SLOT (process_settings_dialog_request (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2162
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2163 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2164 SIGNAL (gui_preference_signal (const QString&, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2165 QString*)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2166 this, SLOT (gui_preference (const QString&, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2167 QString*)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2168
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2169 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2170 SIGNAL (edit_file_signal (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2171 m_active_editor,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2172 SLOT (handle_edit_file_request (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2173
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2174 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2175 SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2176 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2177 SLOT (handle_insert_debugger_pointer_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2178 int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2179
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2180 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2181 SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2182 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2183 SLOT (handle_delete_debugger_pointer_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2184 int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2185
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2186 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2187 SIGNAL (update_breakpoint_marker_signal (bool, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2188 int, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2189 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2190 SLOT (handle_update_breakpoint_marker_request (bool, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2191 int, const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2192
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2193 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2194 SIGNAL (show_doc_signal (const QString &)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2195 this, SLOT (handle_show_doc (const QString &)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2196
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2197 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2198 SIGNAL (register_doc_signal (const QString &)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2199 this, SLOT (handle_register_doc (const QString &)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2200
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2201 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2202 SIGNAL (unregister_doc_signal (const QString &)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2203 this, SLOT (handle_unregister_doc (const QString &)));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2204 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2205
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2206 QAction* main_window::add_action (QMenu *menu, const QIcon& icon,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2207 const QString& text, const char *member,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2208 const QWidget *receiver)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2209 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2210 QAction *a;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2211
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2212 if (receiver)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2213 a = menu->addAction (icon, text, receiver, member);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2214 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2215 a = menu->addAction (icon, text, this, member);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2216
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2217 addAction (a); // important for shortcut context
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2218 a->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2219 return a;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2220 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2221
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2222 QMenu* main_window::m_add_menu (QMenuBar *p, QString name)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2223 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2224 QMenu *menu = p->addMenu (name);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2225
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2226 QString base_name = name; // get a copy
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2227 // replace intended '&' ("&&") by a temp. string
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2228 base_name.replace ("&&", "___octave_amp_replacement___");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2229 // remove single '&' (shortcut)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2230 base_name.remove ("&");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2231 // restore intended '&'
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2232 base_name.replace ("___octave_amp_replacement___", "&&");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2233
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2234 // remember names with and without shortcut
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2235 m_hash_menu_text[menu] = QStringList () << name << base_name;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2236
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2237 return menu;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2238 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2239
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2240 void main_window::construct_menu_bar (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2241 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2242 QMenuBar *menu_bar = menuBar ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2243
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2244 construct_file_menu (menu_bar);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2245
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2246 construct_edit_menu (menu_bar);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2247
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2248 construct_debug_menu (menu_bar);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2249
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2250 construct_window_menu (menu_bar);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2251
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2252 construct_help_menu (menu_bar);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2253
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2254 construct_news_menu (menu_bar);
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
2255
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2256 #if defined (HAVE_QSCINTILLA)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2257 // call the editor to add actions which should also be available in the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2258 // editor's menu and tool bar
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2259 QList<QAction*> shared_actions;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2260 shared_actions << m_new_script_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2261 << m_new_function_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2262 << m_open_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2263 << m_find_files_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2264 << m_undo_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2265 << m_copy_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2266 << m_paste_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2267 <<m_select_all_action;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2268 m_editor_window->insert_global_actions (shared_actions);
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
2269 #endif
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2270 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2271
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2272 void main_window::construct_file_menu (QMenuBar *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2273 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2274 QMenu *file_menu = m_add_menu (p, tr ("&File"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2275
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2276 construct_new_menu (file_menu);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2277
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2278 m_open_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2279 = file_menu->addAction (resource_manager::icon ("document-open"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2280 tr ("Open..."));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2281 m_open_action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2282 m_open_action->setToolTip (tr ("Open an existing file in editor"));
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2283
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2284 #if defined (HAVE_QSCINTILLA)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2285 file_menu->addMenu (m_editor_window->get_mru_menu ());
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2286 #endif
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2287
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2288 file_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2289
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2290 m_load_workspace_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2291 = file_menu->addAction (tr ("Load Workspace..."));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2292
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2293 m_save_workspace_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2294 = file_menu->addAction (tr ("Save Workspace As..."));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2295
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2296 file_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2297
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2298 m_exit_action = file_menu->addAction (tr ("Exit"));
27118
99adef2c6e10 Enable "Quit" menu item on Mac application menu (bug #56155)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27102
diff changeset
2299 m_exit_action->setMenuRole (QAction::QuitRole);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2300 m_exit_action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2301
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2302 connect (m_open_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2303 this, SLOT (request_open_file (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2304
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2305 connect (m_load_workspace_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2306 this, SLOT (handle_load_workspace_request (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2307
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2308 connect (m_save_workspace_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2309 this, SLOT (handle_save_workspace_request (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2310
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2311 connect (m_exit_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2312 this, SLOT (close (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2313 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2314
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2315 void main_window::construct_new_menu (QMenu *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2316 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2317 QMenu *new_menu = p->addMenu (tr ("New"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2318
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2319 m_new_script_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2320 = new_menu->addAction (resource_manager::icon ("document-new"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2321 tr ("New Script"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2322 m_new_script_action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2323
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2324 m_new_function_action = new_menu->addAction (tr ("New Function..."));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2325 m_new_function_action->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2326 m_new_function_action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2327
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2328 m_new_figure_action = new_menu->addAction (tr ("New Figure"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2329 m_new_figure_action->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2330
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2331 connect (m_new_script_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2332 this, SLOT (request_new_script (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2333
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2334 connect (m_new_function_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2335 this, SLOT (request_new_function (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2336
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2337 connect (this, SIGNAL (new_file_signal (const QString&)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2338 m_active_editor, SLOT (request_new_file (const QString&)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2339
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2340 connect (this, SIGNAL (open_file_signal (const QString&)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2341 m_active_editor, SLOT (request_open_file (const QString&)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2342
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2343 connect (this,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2344 SIGNAL (open_file_signal (const QString&, const QString&, int)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2345 m_active_editor,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2346 SLOT (request_open_file (const QString&, const QString&, int)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2347
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2348 connect (m_new_figure_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2349 this, SLOT (handle_new_figure_request (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2350 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2351
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2352 void main_window::construct_edit_menu (QMenuBar *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2353 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2354 QMenu *edit_menu = m_add_menu (p, tr ("&Edit"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2355
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2356 QKeySequence ctrl_shift = Qt::ControlModifier + Qt::ShiftModifier;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2357
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2358 m_undo_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2359 = edit_menu->addAction (resource_manager::icon ("edit-undo"), tr ("Undo"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2360 m_undo_action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2361
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2362 edit_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2363
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2364 m_copy_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2365 = edit_menu->addAction (resource_manager::icon ("edit-copy"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2366 tr ("Copy"), this, SLOT (copyClipboard (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2367 m_copy_action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2368
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2369 m_paste_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2370 = edit_menu->addAction (resource_manager::icon ("edit-paste"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2371 tr ("Paste"), this, SLOT (pasteClipboard (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2372 m_paste_action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2373
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2374 m_select_all_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2375 = edit_menu->addAction (tr ("Select All"), this, SLOT (selectAll (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2376 m_select_all_action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2377
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2378 m_clear_clipboard_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2379 = edit_menu->addAction (tr ("Clear Clipboard"), this,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2380 SLOT (clear_clipboard (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2381
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2382 edit_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2383
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2384 m_find_files_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2385 = edit_menu->addAction (resource_manager::icon ("edit-find"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2386 tr ("Find Files..."));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2387
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2388 edit_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2389
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2390 m_clear_command_window_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2391 = edit_menu->addAction (tr ("Clear Command Window"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2392
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2393 m_clear_command_history_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2394 = edit_menu->addAction (tr ("Clear Command History"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2395
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2396 m_clear_workspace_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2397 = edit_menu->addAction (tr ("Clear Workspace"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2398
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2399 edit_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2400
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2401 m_set_path_action
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2402 = edit_menu->addAction (tr ("Set Path"));
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2403
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2404 m_preferences_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2405 = edit_menu->addAction (resource_manager::icon ("preferences-system"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2406 tr ("Preferences..."));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2407
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2408 connect (m_find_files_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2409 this, SLOT (find_files (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2410
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2411 connect (m_clear_command_window_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2412 this, SLOT (handle_clear_command_window_request (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2413
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2414 connect (m_clear_command_history_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2415 this, SLOT (handle_clear_history_request (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2416
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2417 connect (m_clear_workspace_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2418 this, SLOT (handle_clear_workspace_request (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2419
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2420 connect (m_clipboard, SIGNAL (dataChanged (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2421 this, SLOT (clipboard_has_changed (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2422 clipboard_has_changed ();
24625
be37df6e1fb4 always enable paste action in windows (bug #52361)
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
2423 #if defined (Q_OS_WIN32)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2424 // Always enable paste action (unreliable clipboard signals in windows)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2425 // FIXME: This has to be removed, when the clipboards signals in windows
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2426 // are working again
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2427 m_paste_action->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2428 m_clear_clipboard_action->setEnabled (true);
24625
be37df6e1fb4 always enable paste action in windows (bug #52361)
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
2429 #endif
20039
3538c2824dd8 GUI: Move preferences to edit menu (Bug #44725)
John Donoghue
parents: 19985
diff changeset
2430
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2431 connect (m_preferences_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2432 this, SLOT (process_settings_dialog_request (void)));
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2433
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2434 connect (m_set_path_action, SIGNAL (triggered (void)),
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2435 this, SLOT (handle_set_path_dialog_request (void)));
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2436
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2437 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2438
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2439 QAction * main_window::construct_debug_menu_item (const char *icon,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2440 const QString& item,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2441 const char *member)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2442 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2443 QAction *action = add_action (m_debug_menu,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2444 resource_manager::icon (QString (icon)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2445 item, member);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2446
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2447 action->setEnabled (false);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2448
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2449 #if defined (HAVE_QSCINTILLA)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2450 m_editor_window->debug_menu ()->addAction (action);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2451 m_editor_window->toolbar ()->addAction (action);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2452 #endif
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2453
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2454 return action;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2455 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2456
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2457 void main_window::construct_debug_menu (QMenuBar *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2458 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2459 m_debug_menu = m_add_menu (p, tr ("De&bug"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2460
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2461 m_debug_step_over
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2462 = construct_debug_menu_item ("db-step", tr ("Step"),
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2463 SLOT (debug_step_over (void)));
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2464
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2465 m_debug_step_into
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2466 = construct_debug_menu_item ("db-step-in", tr ("Step In"),
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2467 SLOT (debug_step_into (void)));
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2468
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2469 m_debug_step_out
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2470 = construct_debug_menu_item ("db-step-out", tr ("Step Out"),
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2471 SLOT (debug_step_out (void)));
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2472
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2473 m_debug_continue
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2474 = construct_debug_menu_item ("db-cont", tr ("Continue"),
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2475 SLOT (debug_continue (void)));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2476
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2477 m_debug_menu->addSeparator ();
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2478 #if defined (HAVE_QSCINTILLA)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2479 m_editor_window->debug_menu ()->addSeparator ();
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2480 #endif
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2481
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2482 m_debug_quit
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2483 = construct_debug_menu_item ("db-stop", tr ("Quit Debug Mode"),
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2484 SLOT (debug_quit (void)));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2485 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2486
26873
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2487 void main_window::editor_tabs_changed (bool have_tabs)
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2488 {
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2489 // Set state of action which depend on the existance of editor tabs
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2490 m_editor_has_tabs = have_tabs;
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2491 m_debug_step_over->setEnabled (have_tabs);
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2492 }
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2493
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2494 QAction * main_window::construct_window_menu_item (QMenu *p,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2495 const QString& item,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2496 bool checkable,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2497 QWidget *widget)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2498 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2499 QAction *action = p->addAction (QIcon (), item);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2500
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2501 addAction (action); // important for shortcut context
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2502 action->setCheckable (checkable);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2503 action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2504
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2505 if (widget) // might be zero for m_editor_window
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2506 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2507 if (checkable)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2508 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2509 // action for visibilty of dock widget
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2510 connect (action, SIGNAL (toggled (bool)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2511 widget, SLOT (setVisible (bool)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2512
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2513 connect (widget, SIGNAL (active_changed (bool)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2514 action, SLOT (setChecked (bool)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2515 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2516 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2517 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2518 // action for focus of dock widget
27281
0915fec3d3a9 prevent gui from catching focus when its desktop workspace becomes active
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27277
diff changeset
2519 connect (action, SIGNAL (triggered (void)), widget, SLOT (activate (void)));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2520 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2521 }
27258
922c47ff5218 disable editor actions in window menu when editor is not available (bug #56114)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27255
diff changeset
2522 else
922c47ff5218 disable editor actions in window menu when editor is not available (bug #56114)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27255
diff changeset
2523 {
922c47ff5218 disable editor actions in window menu when editor is not available (bug #56114)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27255
diff changeset
2524 action->setEnabled (false);
922c47ff5218 disable editor actions in window menu when editor is not available (bug #56114)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27255
diff changeset
2525 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2526
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2527 return action;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2528 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2529
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2530 void main_window::construct_window_menu (QMenuBar *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2531 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2532 QMenu *window_menu = m_add_menu (p, tr ("&Window"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2533
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2534 m_show_command_window_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2535 (window_menu, tr ("Show Command Window"), true, m_command_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2536
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2537 m_show_history_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2538 (window_menu, tr ("Show Command History"), true, m_history_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2539
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2540 m_show_file_browser_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2541 (window_menu, tr ("Show File Browser"), true, m_file_browser_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2542
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2543 m_show_workspace_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2544 (window_menu, tr ("Show Workspace"), true, m_workspace_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2545
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2546 m_show_editor_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2547 (window_menu, tr ("Show Editor"), true, m_editor_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2548
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2549 m_show_documentation_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2550 (window_menu, tr ("Show Documentation"), true, m_doc_browser_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2551
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2552 m_show_variable_editor_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2553 (window_menu, tr ("Show Variable Editor"), true, m_variable_editor_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2554
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2555 window_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2556
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2557 m_command_window_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2558 (window_menu, tr ("Command Window"), false, m_command_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2559
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2560 m_history_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2561 (window_menu, tr ("Command History"), false, m_history_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2562
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2563 m_file_browser_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2564 (window_menu, tr ("File Browser"), false, m_file_browser_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2565
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2566 m_workspace_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2567 (window_menu, tr ("Workspace"), false, m_workspace_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2568
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2569 m_editor_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2570 (window_menu, tr ("Editor"), false, m_editor_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2571
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2572 m_documentation_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2573 (window_menu, tr ("Documentation"), false, m_doc_browser_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2574
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2575 m_variable_editor_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2576 (window_menu, tr ("Variable Editor"), false, m_variable_editor_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2577
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2578 window_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2579
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2580 m_reset_windows_action = add_action (window_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2581 tr ("Reset Default Window Layout"), SLOT (reset_windows (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2582 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2583
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2584 void main_window::construct_help_menu (QMenuBar *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2585 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2586 QMenu *help_menu = m_add_menu (p, tr ("&Help"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2587
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2588 construct_documentation_menu (help_menu);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2589
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2590 help_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2591
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2592 m_report_bug_action = add_action (help_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2593 tr ("Report Bug"), SLOT (open_bug_tracker_page ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2594
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2595 m_octave_packages_action = add_action (help_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2596 tr ("Octave Packages"), SLOT (open_octave_packages_page ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2597
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2598 m_contribute_action = add_action (help_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2599 tr ("Contribute"), SLOT (open_contribute_page ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2600
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2601 m_developer_action = add_action (help_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2602 tr ("Donate to Octave"), SLOT (open_donate_page ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2603
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2604 help_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2605
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2606 m_about_octave_action = add_action (help_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2607 tr ("About Octave"), SLOT (show_about_octave ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2608 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2609
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2610 void main_window::construct_documentation_menu (QMenu *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2611 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2612 QMenu *doc_menu = p->addMenu (tr ("Documentation"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2613
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2614 m_ondisk_doc_action = add_action (doc_menu, QIcon (),
27281
0915fec3d3a9 prevent gui from catching focus when its desktop workspace becomes active
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27277
diff changeset
2615 tr ("On Disk"), SLOT (activate ()), m_doc_browser_window);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2616
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2617 m_online_doc_action = add_action (doc_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2618 tr ("Online"), SLOT (open_online_documentation_page ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2619 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2620
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2621 void main_window::construct_news_menu (QMenuBar *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2622 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2623 QMenu *news_menu = m_add_menu (p, tr ("&News"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2624
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2625 m_release_notes_action = add_action (news_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2626 tr ("Release Notes"), SLOT (display_release_notes ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2627
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2628 m_current_news_action = add_action (news_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2629 tr ("Community News"), SLOT (load_and_display_community_news ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2630 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2631
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2632 void main_window::construct_tool_bar (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2633 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2634 m_main_tool_bar = addToolBar (tr ("Toolbar"));
27457
70d9746e9011 smaller toolbars in editor and main window (bug #53902)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27412
diff changeset
2635 m_main_tool_bar->setStyleSheet (m_main_tool_bar->styleSheet ()
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27556
diff changeset
2636 + global_toolbar_style);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2637
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2638 m_main_tool_bar->setObjectName ("MainToolBar");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2639 m_main_tool_bar->addAction (m_new_script_action);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2640 m_main_tool_bar->addAction (m_open_action);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2641
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2642 m_main_tool_bar->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2643
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2644 m_main_tool_bar->addAction (m_copy_action);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2645 m_main_tool_bar->addAction (m_paste_action);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2646 m_main_tool_bar->addAction (m_undo_action);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2647
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2648 m_main_tool_bar->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2649
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2650 m_current_directory_combo_box = new QComboBox (this);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2651 QFontMetrics fm = m_current_directory_combo_box->fontMetrics ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2652 m_current_directory_combo_box->setFixedWidth (48*fm.averageCharWidth ());
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2653 m_current_directory_combo_box->setEditable (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2654 m_current_directory_combo_box->setInsertPolicy (QComboBox::NoInsert);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2655 m_current_directory_combo_box->setToolTip (tr ("Enter directory name"));
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2656 m_current_directory_combo_box->setMaxVisibleItems (current_directory_max_visible);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2657 m_current_directory_combo_box->setMaxCount (current_directory_max_count);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2658 QSizePolicy sizePol (QSizePolicy::Preferred, QSizePolicy::Preferred);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2659 m_current_directory_combo_box->setSizePolicy (sizePol);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2660
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2661 // addWidget takes ownership of the objects so there is no
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2662 // need to delete these upon destroying this main_window.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2663 m_main_tool_bar->addWidget (new QLabel (tr ("Current Directory: ")));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2664 m_main_tool_bar->addWidget (m_current_directory_combo_box);
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2665 QAction *current_dir_up
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2666 = m_main_tool_bar->addAction (resource_manager::icon ("go-up"),
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2667 tr ("One directory up"));
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2668 QAction *current_dir_search
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2669 = m_main_tool_bar->addAction (resource_manager::icon ("folder"),
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2670 tr ("Browse directories"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2671
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2672 connect (m_current_directory_combo_box, SIGNAL (activated (QString)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2673 this, SLOT (set_current_working_directory (QString)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2674
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2675 connect (m_current_directory_combo_box->lineEdit (), SIGNAL (returnPressed (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2676 this, SLOT (accept_directory_line_edit (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2677
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2678 connect (current_dir_search, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2679 this, SLOT (browse_for_directory (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2680
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2681 connect (current_dir_up, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2682 this, SLOT (change_directory_up (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2683
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2684 connect (m_undo_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2685 this, SLOT (handle_undo_request (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2686 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2687
25700
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2688 QString main_window::gui_preference_adjust (const QString& key,
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2689 const QString& value)
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2690 {
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2691 QString adjusted_value = value;
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2692
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2693 // Immediately return if no new value is given
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2694 if (adjusted_value.isEmpty ())
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2695 return adjusted_value;
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2696
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2697 // Not all encodings are available. Encodings are uppercase and do not
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2698 // use CPxxx but IBMxxx or WINDOWS-xxx.
25702
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
2699 if (key == ed_default_enc.key)
25700
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2700 {
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2701 adjusted_value = adjusted_value.toUpper ();
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2702
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2703 QStringList codecs;
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2704 resource_manager::get_codecs (&codecs);
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2705
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2706 QRegExp re ("^CP(\\d+)$");
27271
a4416cd6bb4f Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27270
diff changeset
2707 if (adjusted_value == "SYSTEM")
a4416cd6bb4f Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27270
diff changeset
2708 adjusted_value =
a4416cd6bb4f Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27270
diff changeset
2709 QTextCodec::codecForLocale ()->name ().toUpper ().prepend ("SYSTEM (").append (")");
a4416cd6bb4f Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27270
diff changeset
2710 else if (re.indexIn (adjusted_value) > -1)
25700
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2711 {
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2712 if (codecs.contains ("IBM" + re.cap (1)))
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2713 adjusted_value = "IBM" + re.cap (1);
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2714 else if (codecs.contains ("WINDOWS-" + re.cap (1)))
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2715 adjusted_value = "WINDOWS-" + re.cap (1);
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2716 else
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2717 adjusted_value.clear ();
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2718 }
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2719 else if (! codecs.contains (adjusted_value))
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2720 adjusted_value.clear ();
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2721 }
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2722
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2723 return adjusted_value;
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2724 }
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2725
25639
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2726 void main_window::gui_preference (const QString& key, const QString& value,
25678
3418d3729a51 use exisitng mutex in octave_qt_link for changing gui preferences (bug #54369)
Torsten <mttl@mailbox.org>
parents: 25639
diff changeset
2727 QString* read_value)
25639
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2728 {
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2729 QSettings *settings = resource_manager::get_settings ();
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2730 *read_value = settings->value (key).toString ();
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2731
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2732 interpreter_qobject *interp_qobj = m_octave_qobj.interpreter_qobj ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2733
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
2734 qt_interpreter_events *qt_link = interp_qobj->qt_link ();
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2735
25678
3418d3729a51 use exisitng mutex in octave_qt_link for changing gui preferences (bug #54369)
Torsten <mttl@mailbox.org>
parents: 25639
diff changeset
2736 // Wait for worker to suspend
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2737 qt_link->lock ();
25678
3418d3729a51 use exisitng mutex in octave_qt_link for changing gui preferences (bug #54369)
Torsten <mttl@mailbox.org>
parents: 25639
diff changeset
2738
25700
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2739 // Some preferences need extra handling
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2740 QString adjusted_value = gui_preference_adjust (key, value);
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2741
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2742 if (! adjusted_value.isEmpty () && (*read_value != adjusted_value))
25639
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2743 {
25700
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2744 // Change settings only for new, non-empty values
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2745 settings->setValue (key, QVariant (adjusted_value));
25639
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2746 emit settings_changed (settings);
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2747 }
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2748
25678
3418d3729a51 use exisitng mutex in octave_qt_link for changing gui preferences (bug #54369)
Torsten <mttl@mailbox.org>
parents: 25639
diff changeset
2749 // We are done: Unlock and wake the worker thread
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2750 qt_link->unlock ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2751 qt_link->wake_all ();
25639
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2752 }
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2753
27556
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27478
diff changeset
2754 void main_window::focus_console_after_command (void)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2755 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2756 QSettings *settings = resource_manager::get_settings ();
27556
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27478
diff changeset
2757 if (settings->value ("terminal/focus_after_command",false).toBool ())
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27478
diff changeset
2758 focus_command_window ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2759 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2760
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2761 void main_window::configure_shortcuts (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2762 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2763 // file menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2764 shortcut_manager::set_shortcut (m_open_action, "main_file:open_file");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2765 shortcut_manager::set_shortcut (m_new_script_action, "main_file:new_file");
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
2766 shortcut_manager::set_shortcut (m_new_function_action,
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
2767 "main_file:new_function");
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2768 shortcut_manager::set_shortcut (m_new_function_action, "main_file:new_figure");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2769 shortcut_manager::set_shortcut (m_load_workspace_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2770 "main_file:load_workspace");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2771 shortcut_manager::set_shortcut (m_save_workspace_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2772 "main_file:save_workspace");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2773 shortcut_manager::set_shortcut (m_exit_action,"main_file:exit");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2774
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2775 // edit menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2776 shortcut_manager::set_shortcut (m_copy_action, "main_edit:copy");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2777 shortcut_manager::set_shortcut (m_paste_action, "main_edit:paste");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2778 shortcut_manager::set_shortcut (m_undo_action, "main_edit:undo");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2779 shortcut_manager::set_shortcut (m_select_all_action, "main_edit:select_all");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2780 shortcut_manager::set_shortcut (m_clear_clipboard_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2781 "main_edit:clear_clipboard");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2782 shortcut_manager::set_shortcut (m_find_files_action, "main_edit:find_in_files");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2783 shortcut_manager::set_shortcut (m_clear_command_history_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2784 "main_edit:clear_history");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2785 shortcut_manager::set_shortcut (m_clear_command_window_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2786 "main_edit:clear_command_window");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2787 shortcut_manager::set_shortcut (m_clear_workspace_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2788 "main_edit:clear_workspace");
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2789 shortcut_manager::set_shortcut (m_set_path_action, "main_edit:set_path");
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2790 shortcut_manager::set_shortcut (m_preferences_action, "main_edit:preferences");
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2791
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2792 // debug menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2793 shortcut_manager::set_shortcut (m_debug_step_over, "main_debug:step_over");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2794 shortcut_manager::set_shortcut (m_debug_step_into, "main_debug:step_into");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2795 shortcut_manager::set_shortcut (m_debug_step_out, "main_debug:step_out");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2796 shortcut_manager::set_shortcut (m_debug_continue, "main_debug:continue");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2797 shortcut_manager::set_shortcut (m_debug_quit, "main_debug:quit");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2798
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2799 // window menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2800 shortcut_manager::set_shortcut (m_show_command_window_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2801 "main_window:show_command");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2802 shortcut_manager::set_shortcut (m_show_history_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2803 "main_window:show_history");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2804 shortcut_manager::set_shortcut (m_show_workspace_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2805 "main_window:show_workspace");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2806 shortcut_manager::set_shortcut (m_show_file_browser_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2807 "main_window:show_file_browser");
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
2808 shortcut_manager::set_shortcut (m_show_editor_action,
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
2809 "main_window:show_editor");
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2810 shortcut_manager::set_shortcut (m_show_documentation_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2811 "main_window:show_doc");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2812 shortcut_manager::set_shortcut (m_show_variable_editor_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2813 "main_window:show_variable_editor");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2814 shortcut_manager::set_shortcut (m_command_window_action, "main_window:command");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2815 shortcut_manager::set_shortcut (m_history_action, "main_window:history");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2816 shortcut_manager::set_shortcut (m_workspace_action, "main_window:workspace");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2817 shortcut_manager::set_shortcut (m_file_browser_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2818 "main_window:file_browser");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2819 shortcut_manager::set_shortcut (m_editor_action, "main_window:editor");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2820 shortcut_manager::set_shortcut (m_documentation_action, "main_window:doc");
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
2821 shortcut_manager::set_shortcut (m_variable_editor_action,
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
2822 "main_window:variable_editor");
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2823 shortcut_manager::set_shortcut (m_reset_windows_action, "main_window:reset");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2824
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2825 // help menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2826 shortcut_manager::set_shortcut (m_ondisk_doc_action, "main_help:ondisk_doc");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2827 shortcut_manager::set_shortcut (m_online_doc_action, "main_help:online_doc");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2828 shortcut_manager::set_shortcut (m_report_bug_action, "main_help:report_bug");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2829 shortcut_manager::set_shortcut (m_octave_packages_action, "main_help:packages");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2830 shortcut_manager::set_shortcut (m_contribute_action, "main_help:contribute");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2831 shortcut_manager::set_shortcut (m_developer_action, "main_help:developer");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2832 shortcut_manager::set_shortcut (m_about_octave_action, "main_help:about");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2833
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2834 // news menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2835 shortcut_manager::set_shortcut (m_release_notes_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2836 "main_news:release_notes");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2837 shortcut_manager::set_shortcut (m_current_news_action,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2838 "main_news:community_news");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2839 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2840
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2841 QList<octave_dock_widget *> main_window::dock_widget_list (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2842 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2843 QList<octave_dock_widget *> list = QList<octave_dock_widget *> ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2844 list.append (static_cast<octave_dock_widget *> (m_command_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2845 list.append (static_cast<octave_dock_widget *> (m_history_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2846 list.append (static_cast<octave_dock_widget *> (m_file_browser_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2847 list.append (static_cast<octave_dock_widget *> (m_doc_browser_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2848 #if defined (HAVE_QSCINTILLA)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2849 list.append (static_cast<octave_dock_widget *> (m_editor_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2850 #endif
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2851 list.append (static_cast<octave_dock_widget *> (m_workspace_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2852 list.append (static_cast<octave_dock_widget *> (m_variable_editor_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2853 return list;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2854 }
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2855
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2856 void main_window::update_default_encoding (const QString& default_encoding)
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2857 {
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2858 m_default_encoding = default_encoding;
27271
a4416cd6bb4f Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27270
diff changeset
2859 std::string mfile_encoding = m_default_encoding.toStdString ();
a4416cd6bb4f Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27270
diff changeset
2860 if (m_default_encoding.startsWith ("SYSTEM", Qt::CaseInsensitive))
a4416cd6bb4f Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27270
diff changeset
2861 mfile_encoding = "SYSTEM";
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2862
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2863 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2864 ([mfile_encoding] (interpreter& interp)
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2865 {
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2866 // INTERPRETER THREAD
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2867
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2868 F__mfile_encoding__ (interp, ovl (mfile_encoding));
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2869 });
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2870 }
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
2871 }