annotate libgui/src/main-window.cc @ 27041:6caf75200854 stable

build: Silence unused parameter warning created in cset 43f6f02dd91c (bug #56097). * main-window.cc (main:window::file_remove_proxy): Create #else branch of "#ifdef (HAVE_QSCINTILLA)" which uses octave_unused_parameter() to silence unused inputs to function.
author Rik <rik@octave.org>
date Thu, 11 Apr 2019 08:48:43 -0700
parents 32d9f57d7245
children 2faa56886789 2310164737b3
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
16648
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16642
diff changeset
28 #include <QKeySequence>
15257
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15204
diff changeset
29 #include <QApplication>
26227
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
30 #include <QStyleFactory>
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
31 #include <QInputDialog>
15257
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15204
diff changeset
32 #include <QLabel>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
33 #include <QMenuBar>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
34 #include <QMenu>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
35 #include <QAction>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
36 #include <QSettings>
14670
7fbea449737d Restructured menus, added toolbar and current directory line edit.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14669
diff changeset
37 #include <QStyle>
25956
2201f82db233 Add missing QStyleFactory header (Bug #54881)
John Donoghue
parents: 25944
diff changeset
38 #include <QStyleFactory>
14670
7fbea449737d Restructured menus, added toolbar and current directory line edit.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14669
diff changeset
39 #include <QToolBar>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
40 #include <QDesktopServices>
16391
a695ee2dc17e * main-window.cc: Include <QDesktopWidget>
John W. Eaton <jwe@octave.org>
parents: 16386
diff changeset
41 #include <QDesktopWidget>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
42 #include <QFileDialog>
13626
cc90c62ada21 Removed terminal, instead now using QPlainTextEdit, which looks much nicer and is not that error-prone...
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13620
diff changeset
43 #include <QMessageBox>
14670
7fbea449737d Restructured menus, added toolbar and current directory line edit.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14669
diff changeset
44 #include <QIcon>
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
45 #include <QTextBrowser>
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
46 #include <QTextCodec>
17764
811b5a562680 Format release notes as preformatted text in the GUI (bug #40367)
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
47 #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
48 #include <QThread>
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
49 #include <QDateTime>
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
50 #include <QDebug>
21439
912b8828193b * main-window.cc: include QTimer header file
Mike Miller <mtmiller@octave.org>
parents: 21428
diff changeset
51 #include <QTimer>
14670
7fbea449737d Restructured menus, added toolbar and current directory line edit.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14669
diff changeset
52
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
53 #include <utility>
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
14707
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
58 #include "main-window.h"
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
59 #include "settings-dialog.h"
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
60 #include "shortcut-manager.h"
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
61 #include "welcome-wizard.h"
26309
b26b31781b30 separate include file for main window gui preferences
Torsten <mttl@mailbox.org>
parents: 26307
diff changeset
62 #include "gui-preferences-mw.h"
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
63
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
64 #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
65 #include "cmd-edit.h"
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
66 #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
67 #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
68
19893
67cb2f421255 restore include statement removed in changeset c7c50030e76c
John W. Eaton <jwe@octave.org>
parents: 19882
diff changeset
69 #include "builtin-defun-decls.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
70 #include "call-stack.h"
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
71 #include "defaults.h"
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
72 #include "defun.h"
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23497
diff changeset
73 #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
74 #include "interpreter.h"
23479
06bf3a0b08bf maint: Use "" instead of <> for our own include files.
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
75 #include "oct-map.h"
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
76 #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
77 #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
78 #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
79 #include "symscope.h"
23479
06bf3a0b08bf maint: Use "" instead of <> for our own include files.
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
80 #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
81 #include "version.h"
23380
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
82
24716
2b3e0b570e77 move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24715
diff changeset
83 static octave::file_editor_interface *
23380
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
84 create_default_editor (QWidget *p)
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
85 {
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
86 #if defined (HAVE_QSCINTILLA)
24716
2b3e0b570e77 move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24715
diff changeset
87 return new octave::file_editor (p);
23380
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
88 #else
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
89 octave_unused_parameter (p);
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
90
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
91 return 0;
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
92 #endif
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
93 }
16457
10edb6f1ae98 improve encapsulation of file editor window object
John W. Eaton <jwe@octave.org>
parents: 16456
diff changeset
94
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
95 // Disable all Qt messages by default.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
96
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
97 static void
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
98 #if defined (QTMESSAGEHANDLER_ACCEPTS_QMESSAGELOGCONTEXT)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
99 message_handler (QtMsgType, const QMessageLogContext &, const QString &)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
100 #else
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
101 message_handler (QtMsgType, const char *)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
102 #endif
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
103 { }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
104
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
105 namespace octave
23119
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
106 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
107 octave_interpreter::octave_interpreter (gui_application& app_context)
25275
4adeabc1bbfe improve Ctrl-C interrupt handling in the GUI (bug #53635)
John W. Eaton <jwe@octave.org>
parents: 25251
diff changeset
108 : QObject (), m_app_context (app_context)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
109 { }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
110
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
111 void octave_interpreter::execute (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
112 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
113 // The application context owns the interpreter.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
114
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
115 interpreter& interp = m_app_context.create_interpreter ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
116
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
117 int exit_status = 0;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
118
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
119 try
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
120 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
121 // Final initialization.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
122
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
123 interp.initialize ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
124
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
125 if (m_app_context.start_gui_p ())
25407
ab10403a0b50 new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents: 25356
diff changeset
126 {
ab10403a0b50 new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents: 25356
diff changeset
127 input_system& input_sys = interp.get_input_system ();
ab10403a0b50 new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents: 25356
diff changeset
128
ab10403a0b50 new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents: 25356
diff changeset
129 input_sys.PS1 (">> ");
ab10403a0b50 new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents: 25356
diff changeset
130 input_sys.PS2 ("");
ab10403a0b50 new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents: 25356
diff changeset
131
ab10403a0b50 new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents: 25356
diff changeset
132 tree_evaluator& tw = interp.get_evaluator ();
ab10403a0b50 new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents: 25356
diff changeset
133
ab10403a0b50 new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents: 25356
diff changeset
134 tw.PS4 ("");
ab10403a0b50 new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents: 25356
diff changeset
135 }
ab10403a0b50 new input_system class to manage user input for the interpreter
John W. Eaton <jwe@octave.org>
parents: 25356
diff changeset
136
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
137 if (interp.initialized ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
138 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
139 // The interpreter should be completely ready at this point so let
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
140 // the GUI know.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
141
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
142 emit octave_ready_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
143
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
144 // Start executing commands in the command window.
23119
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
145
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
146 exit_status = interp.execute ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
147 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
148 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
149 catch (const exit_exception& ex)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
150 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
151 exit_status = ex.exit_status ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
152 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
153
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
154 // Whether or not initialization succeeds we need to clean up the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
155 // interpreter once we are done with it.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
156
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
157 m_app_context.delete_interpreter ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
158
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
159 emit octave_finished_signal (exit_status);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
160 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
161
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
162 main_window::main_window (octave_qt_app& oct_qt_app,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
163 octave_qt_link *oct_qt_lnk)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
164 : QMainWindow (),
26227
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
165 m_qt_app (oct_qt_app.qt_app ()), m_octave_qt_link (oct_qt_lnk),
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
166 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
167 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
168 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
169 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
170 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
171 m_external_editor (new external_editor_interface (this)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
172 m_active_editor (m_external_editor),
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
173 m_settings_dlg (nullptr), m_find_files_dlg (nullptr),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
174 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
175 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
176 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
177 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
178 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
179 if (resource_manager::is_first_run ())
25938
6fec0e305268 Backed out changeset 2ab0a9b66388
John W. Eaton <jwe@octave.org>
parents: 25937
diff changeset
180 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
181 // Before wizard.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
182 oct_qt_app.config_translators ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
183
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
184 welcome_wizard welcomeWizard;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
185
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
186 if (welcomeWizard.exec () == QDialog::Rejected)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
187 exit (1);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
188
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
189 // Install settings file.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
190 resource_manager::reload_settings ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
191 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
192 else
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
193 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
194 // Get settings file.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
195 resource_manager::reload_settings ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
196
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
197 // After settings.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
198 oct_qt_app.config_translators ();
25938
6fec0e305268 Backed out changeset 2ab0a9b66388
John W. Eaton <jwe@octave.org>
parents: 25937
diff changeset
199 }
6fec0e305268 Backed out changeset 2ab0a9b66388
John W. Eaton <jwe@octave.org>
parents: 25937
diff changeset
200
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
201 resource_manager::update_network_settings ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
202
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
203 // We provide specific terminal capabilities, so ensure that
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
204 // TERM is always set appropriately.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
205
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
206 #if defined (OCTAVE_USE_WINDOWS_API)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
207 sys::env::putenv ("TERM", "cygwin");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
208 #else
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
209 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
210 #endif
a4c687fec320 gui: set Qt Application and Desktop metadata for desktop integration (bug #53102)
Mike Miller <mtmiller@octave.org>
parents: 25042
diff changeset
211
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
212 shortcut_manager::init_data ();
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 construct_central_widget ();
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 m_workspace_model = new workspace_model ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
217 m_status_bar = new QStatusBar ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
218 m_command_window = new terminal_dock_widget (this);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
219 m_history_window = new history_dock_widget (this);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
220 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
221 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
222 m_editor_window = create_default_editor (this);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
223 m_variable_editor_window = new variable_editor (this);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
224 m_workspace_window = new workspace_view (this);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
225
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
226 m_active_editor = m_editor_window;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
227
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
228 #if defined (HAVE_QGUIAPPLICATION_SETDESKTOPFILENAME)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
229 QGuiApplication::setDesktopFileName ("org.octave.Octave.desktop");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
230 #endif
25938
6fec0e305268 Backed out changeset 2ab0a9b66388
John W. Eaton <jwe@octave.org>
parents: 25937
diff changeset
231
26227
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
232 m_default_style = m_qt_app->style ()->objectName ();
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
233
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
234 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
235
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
236 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
237 QDateTime last_checked;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
238 int serial = 0;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
239 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
240
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
241 if (settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
242 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
243 connect_to_web
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
244 = 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
245
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
246 last_checked
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
247 = 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
248
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
249 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
250 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
251 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
252 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
253
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
254 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
255 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
256
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
257 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
258 && (! 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
259 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
260
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
261 construct_octave_qt_link ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
262
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
263 // 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
264 // octave.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
265
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
266 construct ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
267
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
268 read_settings ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
269
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
270 init_terminal_size ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
271
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
272 // 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
273 // shown.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
274
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
275 connect_visibility_changed ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
276
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
277 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
278 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
279
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
280 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
281 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
282 // Note that we don't delete m_main_thread here. That is handled by
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
283 // deleteLater slot that is called when the m_main_thread issues a
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
284 // finished signal.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
285
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
286 // 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
287 // 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
288
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
289 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
290 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
291 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
292 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
293 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
294 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
295 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
296 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
297 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
298 delete m_variable_editor_window;
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
299
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
300 delete m_find_files_dlg;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
301 delete m_release_notes_window;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
302 delete m_settings_dlg;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
303 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
304 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
305
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
306 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
307 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
308 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
309 }
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 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
312 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
313 m_command_window->focus ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
314 }
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 // 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
317 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
318 {
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
319 // 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
320 // menu gets active, we can return immediately
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
321 if (! new_widget)
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
322 return;
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
323
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
324 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
325 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
326 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
327 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
328
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
329 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
330
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
331 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
332 {
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
333 // 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
334 // 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
335 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
336 {
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
337 if (w->isAncestorOf (w_new))
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
338 dock = w;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
339 }
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
340
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
341 if (dock)
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
342 break;
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
343
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
344 // 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
345 // 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
346 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
347
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
348 // 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
349 if (w_new == start)
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
350 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
351 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
352 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
353
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
354 // 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
355 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
356 = 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
357 // 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
358 // 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
359 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
360 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
361 // 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
362 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
363
26555
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
364 if (dock)
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
365 {
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
366 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
367 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
368 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
369 }
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 (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
372 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
373 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
374 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
375
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
376 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
377 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
378 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
379
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
380 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
381 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
382 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
383
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
384 if (settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
385 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
386 }
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 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
389 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
390 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
391 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
392
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
393 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
394 {
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
395 // 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
396 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
397 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
398 true).toBool ())
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
399 opts = QFileDialog::DontUseNativeDialog;
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
400
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
401 QString file
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
402 = 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
403 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
404
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
405 if (! file.isEmpty ())
25723
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
406 {
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
407 octave_cmd_builtin *cmd
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
408 = new octave_cmd_builtin (&Fsave, ovl (file.toStdString ()));
25907
0146d16055a8 use signal/slot to give all gui dock widgets access to the command queue
Torsten <mttl@mailbox.org>
parents: 25892
diff changeset
409 queue_cmd (cmd);
25723
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
410 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
411 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
412
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_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
414 {
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
415 // 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
416 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
417 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
418 true).toBool ())
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
419 opts = QFileDialog::DontUseNativeDialog;
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
420
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
421 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
422
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
423 if (file.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
424 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
425 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
426
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
427 if (! file.isEmpty ())
25723
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
428 {
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
429 octave_cmd_builtin *cmd
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
430 = new octave_cmd_builtin (&Fload, ovl (file.toStdString ()),
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
431 octave_cmd_builtin::CMD_UPD_WORKSPACE);
25907
0146d16055a8 use signal/slot to give all gui dock widgets access to the command queue
Torsten <mttl@mailbox.org>
parents: 25892
diff changeset
432 queue_cmd (cmd);
25723
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
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
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
436 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
437 {
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
438 if (! file_arg.isEmpty ())
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
439 octave_link::post_event (this, &main_window::open_any_callback,
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
440 file_arg.toStdString ());
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
441 }
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
442
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
443 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
444 {
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
445 octave_cmd_builtin *cmd = new octave_cmd_builtin (&Fclear, ovl ());
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
446
25907
0146d16055a8 use signal/slot to give all gui dock widgets access to the command queue
Torsten <mttl@mailbox.org>
parents: 25892
diff changeset
447 queue_cmd (cmd);
24715
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
450 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
451 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
452 octave_link::post_event (this, &main_window::clear_command_window_callback);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
453 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
454
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
455 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
456 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
457 octave_link::post_event (this, &main_window::clear_history_callback);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
458 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
459
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
460 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
461 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
462 if (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
463 octave_link::post_event (this, &main_window::command_window_undo_callback);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
464 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
465 emit undo_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
466 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
467
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
468 void main_window::handle_rename_variable_request (const QString& old_name,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
469 const QString& new_name)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
470
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
471 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
472 name_pair names (old_name.toStdString (), new_name.toStdString ());
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
473
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
474 octave_link::post_event (this, &main_window::rename_variable_callback,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
475 names);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
476 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
477
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
478 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
479 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
480 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
481 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
482
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
483 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
484 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
485 if (line < 0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
486 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
487 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
488 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
489 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
490
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
491 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
492 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
493 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
494 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
495
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
496 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
497 {
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
498 // Wait for worker to suspend
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
499 m_octave_qt_link->lock ();
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
500
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
501 // 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
502 #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
503 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
504 #else
6caf75200854 build: Silence unused parameter warning created in cset 43f6f02dd91c (bug #56097).
Rik <rik@octave.org>
parents: 27039
diff changeset
505 octave_unused_parameter (o);
6caf75200854 build: Silence unused parameter warning created in cset 43f6f02dd91c (bug #56097).
Rik <rik@octave.org>
parents: 27039
diff changeset
506 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
507 #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
508
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
509 // We are done: Unlock and wake the worker thread
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
510 m_octave_qt_link->unlock ();
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
511 m_octave_qt_link->wake_all ();
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
512 }
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
513
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
514 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
515 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
516 QDesktopServices::openUrl (
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
517 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
518 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
519
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
520 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
521 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
522 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
523 {
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
524 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
525
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
526 QString news;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
527
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
528 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
529 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
530 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
531 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
532 news = stream->readAll ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
533 if (! news.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
534 {
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
535 // 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
536 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
537 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
538 // 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
539 news.prepend ("<pre>");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
540 news.append ("</pre>");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
541 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
542 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
543 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
544 . 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
545 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
546 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
547 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
548 . 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
549
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
550 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
551
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
552 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
553 browser->setText (news);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
554
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
555 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
556 vlayout->addWidget (browser);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
557
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
558 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
559 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
560
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
561 browser->document ()->adjustSize ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
562
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
563 // 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
564 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
565 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
566 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
567 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
568 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
569 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
570 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
571 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
572 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
573 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
574
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
575 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
576 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
577 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
578 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
579
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
580 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
581
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
582 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
583 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
584 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
585
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
586 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
587 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
588 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
589
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
590 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
591 = (settings
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
592 ? 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
593 : true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
594
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
595 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
596 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
597
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
598 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
599
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
600 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
601 connect_to_web);
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 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
604
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
605 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
606 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
607
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
608 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
609 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
610
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
611 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
612
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
613 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
614
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
615 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
616 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
617
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
618 worker_thread->start ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
619 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
620
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
621 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
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_community_news_window)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
624 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
625 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
626
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
627 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
628
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
629 browser->setHtml (news);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
630 browser->setObjectName ("OctaveNews");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
631 browser->setOpenExternalLinks (true);
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 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
634
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
635 vlayout->addWidget (browser);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
636
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
637 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
638 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
639
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
640 // 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
641 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
642 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
643 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
644 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
645 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
646 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
647 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
648 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
649 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
650 (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
651 }
25805
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
652 else
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
653 {
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
654 // 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
655 QTextBrowser *browser
25819
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
656
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
657 = 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
658 #if defined (QOBJECT_FINDCHILDREN_ACCEPTS_FINDCHILDOPTIONS)
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
659 , Qt::FindDirectChildrenOnly
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
660 #endif
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
661 );
25805
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
662 if (browser)
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
663 browser->setHtml (news);
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
664 }
24715
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 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
667 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
668 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
669 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
670
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
671 // 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
672 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
673
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
674 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
675 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
676 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
677
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
678 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
679 {
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
680 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
681 }
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 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
684 {
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
685 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
686 }
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 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
689 {
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
690 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
691 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
692
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
693 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
694 {
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
695 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
696 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
697
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
698 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
699 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
700 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
701 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
702 // 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
703 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
704 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
705 return;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
706 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
707
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
708 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
709
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
710 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
711 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
712
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
713 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
714 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
715 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
716 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
717
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
718 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
719 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
720 std::string message
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
721 = 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
722
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
723 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
724 QString::fromStdString (message));
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
727 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
728 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
729 // 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
730
26227
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
731 // 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
732 // 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
733 QString preferred_style
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
734 = 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
735
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
736 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
737 preferred_style = m_default_style;
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
738
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
739 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
740 if (new_style)
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
741 m_qt_app->setStyle (new_style);
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
742
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
743 // 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
744 QString icon_set
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
745 = 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
746
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
747 static struct
19422
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
748 {
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
749 QString name;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
750 QString path;
17883
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
751 }
17599
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
752
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
753 widget_icon_data[] =
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
754 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
755 // 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
756 // 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
757 {"NONE", ":/actions/icons/logo.png"},
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
758 {"GRAPHIC", ":/actions/icons/graphic_logo_"},
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
759 {"LETTER", ":/actions/icons/letter_logo_"},
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
760 {"", ""} // end marker has empty name
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
761 };
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
762
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
763 int count = 0;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
764 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
765
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
766 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
767 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
768 // 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
769 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
770 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
771 // 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
772 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
773 break;
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 count++;
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
778 QString icon;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
779 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
780 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
781 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
782 if (! name.isEmpty ())
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
783 {
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
784 // 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
785 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
786 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
787 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
788 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
789 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
790 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
791 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
792 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
793 + "ReleaseWidget.png";
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
794 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
795 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
796
26058
ecd86b8b8979 use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents: 25994
diff changeset
797 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
798 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
799 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
800
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
801 QStyle *st = style ();
26058
ecd86b8b8979 use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents: 25994
diff changeset
802 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
803 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
804
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
805 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
806 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
807 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
808 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
809
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
810 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
811 = 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
812
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
813 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
814 = ! 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
815
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
816 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
817
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
818 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
819
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
820 configure_shortcuts ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
821 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
822 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
823
25702
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
824 // Ckeck whether some octave internal preferences have to be updated
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
825 QString new_default_encoding
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
826 = 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
827 if (new_default_encoding != m_default_encoding)
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
828 {
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
829 m_default_encoding = new_default_encoding;
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
830 octave_cmd_builtin *cmd = new octave_cmd_builtin (
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
831 &F__mfile_encoding__,
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
832 ovl (m_default_encoding.toStdString ()));
25907
0146d16055a8 use signal/slot to give all gui dock widgets access to the command queue
Torsten <mttl@mailbox.org>
parents: 25892
diff changeset
833 queue_cmd (cmd);
25702
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
834 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
835
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
836 // 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
837 // 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
838 // 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
839 // 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
840 bool cursor_blinking;
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 if (settings->contains ("cursor_blinking"))
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
843 cursor_blinking = settings->value ("cursor_blinking",true).toBool ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
844 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
845 cursor_blinking = settings->value ("terminal/cursorBlinking",true).toBool ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
846
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
847 if (cursor_blinking)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
848 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
849 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
850 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
851
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
852 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
853
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
854 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
855 {
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
856 bool closenow = true;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
857
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
858 QSettings *settings = resource_manager::get_settings ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
859
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
860 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
861 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
862 int ans = QMessageBox::question (this, tr ("Octave"),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
863 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
864 (QMessageBox::Ok
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
865 | QMessageBox::Cancel),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
866 QMessageBox::Ok);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
867
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
868 if (ans != QMessageBox::Ok)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
869 closenow = false;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
870 }
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
871
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
872 #if defined (HAVE_QSCINTILLA)
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
873 if (closenow)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
874 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
875 #endif
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
876
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
877 return closenow;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
878 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
879
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
880 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
881 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
882 // 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
883 // 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
884 // 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
885 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
886 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
887
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
888 write_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
889 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
890
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
891 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
892 {
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
893 hide ();
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
894 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
895 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
896 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
897 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
898
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
899 void main_window::change_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
900 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
901 // 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
902 // 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
903 // widget.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
904
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
905 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
906
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
907 if (index >= 0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
908 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
909
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
910 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
911 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
912 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
913
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
914 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
915 {
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
916 // 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
917 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
918 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
919 true).toBool ())
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
920 opts = QFileDialog::DontUseNativeDialog;
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
921
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
922 QString dir
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
923 = 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
924 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
925
15626
1cc10ce368ea enable entering a new directory in the current directory combobox
Torsten <ttl@justmail.de>
parents: 15607
diff changeset
926 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
927
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
928 // 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
929 // 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
930
24019
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
931 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
932 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
933
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
934 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
935 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
936 // 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
937
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
938 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
939
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
940 QFileInfo fileInfo (xdir);
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 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
943 {
7b4e99fbe9d4 include builtin functions without interpreter argument being into octave_cmd
Torsten <mttl@mailbox.org>
parents: 25702
diff changeset
944 octave_cmd_builtin *cmd
7b4e99fbe9d4 include builtin functions without interpreter argument being into octave_cmd
Torsten <mttl@mailbox.org>
parents: 25702
diff changeset
945 = new octave_cmd_builtin (&Fcd, ovl (xdir.toStdString ()));
25907
0146d16055a8 use signal/slot to give all gui dock widgets access to the command queue
Torsten <mttl@mailbox.org>
parents: 25892
diff changeset
946 queue_cmd (cmd);
25703
7b4e99fbe9d4 include builtin functions without interpreter argument being into octave_cmd
Torsten <mttl@mailbox.org>
parents: 25702
diff changeset
947 }
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
950 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
951 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
952 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
953 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
954
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
955 // 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
956 // 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
957 // 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
958
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
959 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
960 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
961 // 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
962 // 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
963 // directory.
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 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
966
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
967 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
968
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
969 if (index < 0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
970 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
971 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
972
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
973 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
974 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
975 octave_cmd_exec *cmd = new octave_cmd_exec (command);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
976
25907
0146d16055a8 use signal/slot to give all gui dock widgets access to the command queue
Torsten <mttl@mailbox.org>
parents: 25892
diff changeset
977 queue_cmd (cmd);
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 if (focus_console_after_command ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
980 focus_command_window ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
981 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
982
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
983 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
984 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
985 octave_cmd_eval *cmd = new octave_cmd_eval (info);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
986
25907
0146d16055a8 use signal/slot to give all gui dock widgets access to the command queue
Torsten <mttl@mailbox.org>
parents: 25892
diff changeset
987 queue_cmd (cmd);
24715
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 if (focus_console_after_command ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
990 focus_command_window ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
991 }
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 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
994 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
995 octave_link::post_event (this, &main_window::new_figure_callback);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
996 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
997
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
998 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
999 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1000 setWindowTitle ("Octave (Debugging)");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1001
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1002 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
1003 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
1004 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
1005 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
1006 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
1007
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1008 #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
1009 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
1010 #endif
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1011 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1012
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1013 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
1014 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1015 setWindowTitle ("Octave");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1016
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1017 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
1018 m_debug_step_into->setEnabled (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1019 m_debug_step_over->setEnabled (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1020 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
1021 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
1022
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1023 #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
1024 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
1025 #endif
24715
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::debug_continue (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1029 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1030 octave_cmd_debug *cmd
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1031 = new octave_cmd_debug ("cont", m_suppress_dbg_location);
25907
0146d16055a8 use signal/slot to give all gui dock widgets access to the command queue
Torsten <mttl@mailbox.org>
parents: 25892
diff changeset
1032 queue_cmd (cmd);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1033 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1034
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1035 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
1036 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1037 octave_cmd_debug *cmd = new octave_cmd_debug ("in", m_suppress_dbg_location);
25907
0146d16055a8 use signal/slot to give all gui dock widgets access to the command queue
Torsten <mttl@mailbox.org>
parents: 25892
diff changeset
1038 queue_cmd (cmd);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1039 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1040
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1041 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
1042 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1043 octave_cmd_debug *cmd
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1044 = new octave_cmd_debug ("step", m_suppress_dbg_location);
25907
0146d16055a8 use signal/slot to give all gui dock widgets access to the command queue
Torsten <mttl@mailbox.org>
parents: 25892
diff changeset
1045 queue_cmd (cmd);
24715
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1048 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
1049 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1050 octave_cmd_debug *cmd = new octave_cmd_debug ("out", m_suppress_dbg_location);
25907
0146d16055a8 use signal/slot to give all gui dock widgets access to the command queue
Torsten <mttl@mailbox.org>
parents: 25892
diff changeset
1051 queue_cmd (cmd);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1052 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1053
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1054 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
1055 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1056 octave_cmd_debug *cmd
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1057 = new octave_cmd_debug ("quit", m_suppress_dbg_location);
25907
0146d16055a8 use signal/slot to give all gui dock widgets access to the command queue
Torsten <mttl@mailbox.org>
parents: 25892
diff changeset
1058 queue_cmd (cmd);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1059 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1060
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1061 //
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1062 // 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
1063 //
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1064 // 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
1065 // 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
1066 //
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1067 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
1068 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1069 // 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
1070 // 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
1071
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1072 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
1073 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
1074 && ! 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
1075
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1076 // 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
1077 QWidget *p = this;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1078 if (is_internal)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1079 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
1080 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
1081 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
1082
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1083 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
1084 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
1085 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
1086 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
1087
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
1088 // 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
1089 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
1090 true).toBool ())
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
1091 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
1092
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1093 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
1094 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
1095
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1096 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
1097 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
1098 fileDialog->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1099 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1100
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1101 // 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
1102 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
1103 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1104 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
1105 }
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 // 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
1108 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
1109 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1110 bool ok;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1111 // 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
1112 // 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
1113 // 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
1114 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
1115 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
1116 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
1117 p = this;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1118 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
1119 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
1120
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1121 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
1122 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1123 // 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
1124 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
1125 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
1126 // 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
1127 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
1128 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1129 // 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
1130 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
1131 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
1132 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
1133 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1134 // 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
1135 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
1136 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1137 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1138
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1139 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
1140 const QString& ffile,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1141 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
1142 int line)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1143 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1144 interpreter& interp
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1145 = __get_interpreter__ ("main_window::clear_workspace_callback");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1146
25925
e9c24b5e8673 fix opening a function file with an error in a nested function (bug #54801)
Torsten <mttl@mailbox.org>
parents: 25923
diff changeset
1147 // Split possible subfuntions
e9c24b5e8673 fix opening a function file with an error in a nested function (bug #54801)
Torsten <mttl@mailbox.org>
parents: 25923
diff changeset
1148 QStringList fcn_list = fname.split ('>');
e9c24b5e8673 fix opening a function file with an error in a nested function (bug #54801)
Torsten <mttl@mailbox.org>
parents: 25923
diff changeset
1149 QString fcn_name = fcn_list.at (0) + ".m";
e9c24b5e8673 fix opening a function file with an error in a nested function (bug #54801)
Torsten <mttl@mailbox.org>
parents: 25923
diff changeset
1150
25892
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1151 // Is it a regular function within the search path? (Call Fexist)
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1152 octave_value_list fct = Fexist (interp, ovl (fname.toStdString ()),0);
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1153 int type = fct (0).int_value ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1154
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1155 QString message = QString ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1156 QString filename = QString ();
25892
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1157
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1158 switch (type)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1159 {
25892
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1160 case 3:
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1161 case 5:
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1162 case 103:
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1163 message = tr ("%1 is a built-in, compiled or inline\n"
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1164 "function and can not be edited.");
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1165 break;
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1166
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1167 case 2:
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1168 octave_value_list file_path
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1169 = Ffile_in_loadpath (interp, ovl (fcn_name.toStdString ()), 0);
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1170 if (file_path.length () > 0)
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1171 filename = QString::fromStdString (file_path (0).string_value ());
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1172 break;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1173 }
25892
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1174
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1175 if (filename.isEmpty () && message.isEmpty ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1176 {
25892
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1177 // No error so far, but function still not known
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1178 // -> try directory of edited file
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1179 // get directory
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1180 QDir dir;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1181 if (ffile.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1182 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1183 if (curr_dir.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1184 dir = QDir (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
1185 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1186 dir = QDir (curr_dir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1187 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1188 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1189 dir = QDir (QFileInfo (ffile).canonicalPath ());
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1190
25892
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1191 QFileInfo file = QFileInfo (dir, fcn_name);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1192 if (file.exists ())
25892
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1193 filename = file.canonicalFilePath (); // local file exists
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1194 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1195 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1196 // local file does not exist -> try private directory
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1197 file = QFileInfo (ffile);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1198 file = QFileInfo (QDir (file.canonicalPath () + "/private"),
25892
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1199 fcn_name);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1200 if (file.exists ())
25892
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1201 filename = file.canonicalFilePath (); // private function exists
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1202 else
25892
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1203 message = tr ("Can not find function %1"); // no file found
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1204
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1205 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1206 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1207
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1208 if (! message.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1209 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1210 QMessageBox *msgBox
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1211 = new QMessageBox (QMessageBox::Critical,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1212 tr ("Octave Editor"),
25892
cb440b43a236 fix editing an m-file with syntax error via edit ... menu (bug #54600)
Torsten <mttl@mailbox.org>
parents: 25883
diff changeset
1213 message.arg (fname),
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1214 QMessageBox::Ok, this);
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 msgBox->setWindowModality (Qt::NonModal);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1217 msgBox->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
1218 msgBox->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1219 return;
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1222 if (! filename.endsWith (".m"))
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1223 filename.append (".m");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1224
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1225 emit open_file_signal (filename, QString (), line); // default encoding
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1226 }
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 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
1229 int line)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1230 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1231 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
1232
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1233 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
1234
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1235 if (cmd_focus)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1236 focus_command_window ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1237 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1238
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1239 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
1240 int line)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1241 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1242 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
1243
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1244 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
1245
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1246 if (cmd_focus)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1247 focus_command_window ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1248 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1249
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1250 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
1251 const QString& file,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1252 int line,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1253 const QString& cond)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1254 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1255 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
1256
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1257 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
1258
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1259 if (cmd_focus)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1260 focus_command_window ();
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1263 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
1264 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1265 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
1266
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1267 if (! settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1268 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1269 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
1270 return;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1271 }
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 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
1274
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1275 // 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
1276 QStringList curr_dirs
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1277 = 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
1278 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
1279 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1280 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
1281 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1282 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
1283 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1284
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1285 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
1286 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1287 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
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 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
1291 {
26299
c95884eed1cf make restoring gui more robust to changes of desktop size (bug #53207)
Torsten <mttl@mailbox.org>
parents: 26277
diff changeset
1292 // 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
1293 // of an error from the default layout
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1294 if (settings)
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1295 {
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1296 if (! restoreState (
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1297 settings->value (mw_state.key, mw_state.def).toByteArray ()))
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1298 restoreState (mw_state.def.toByteArray ());
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1299
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1300 if (! restoreGeometry (
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1301 settings->value (mw_geometry.key, mw_geometry.def).toByteArray ()))
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1302 restoreGeometry (mw_geometry.def.toByteArray ());
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1303 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1304
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1305 // 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
1306 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
1307 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1308 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
1309
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1310 if (! name.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1311 {
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1312 bool floating = false;
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1313 bool visible = true;
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1314 if (settings)
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1315 {
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1316 floating = settings->value
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1317 ("DockWidgets/" + name + "Floating", false).toBool ();
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1318 visible = settings->value
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1319 ("DockWidgets/" + name + "Visible", true).toBool ();
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1320 }
17899
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17890
diff changeset
1321
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1322 // 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
1323 if (floating)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1324 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1325 widget->make_window ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1326
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1327 if (visible)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1328 {
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1329 if (settings &&
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1330 settings->value ("DockWidgets/" + name
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1331 + "_minimized").toBool ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1332 widget->showMinimized ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1333 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1334 widget->setVisible (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1335 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1336 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1337 else // not floating
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1338 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1339 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
1340 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
1341
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1342 widget->make_widget ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1343 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
1344 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1345 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1346 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1347
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1348 if (! settings)
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1349 {
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1350 restoreGeometry (mw_geometry.def.toByteArray ());
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1351 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
1352
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
1353 QDesktopWidget *m_desktop = QApplication::desktop ();
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
1354 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
1355 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
1356
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
1357 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
1358 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
1359
5d1f413ff746 adapt initial window sizes to the screen resolution (bug #55498)
Torsten <mttl@mailbox.org>
parents: 26555
diff changeset
1360 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
1361 }
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1362
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1363 show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1364 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1365
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1366 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
1367 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1368 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
1369 if (! settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1370 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1371 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
1372 return;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1373 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1374
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1375 settings->setValue ("MainWindow/geometry", saveGeometry ());
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1376 settings->setValue ("MainWindow/windowState", saveState ());
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1377 // 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
1378 QStringList curr_dirs;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1379 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
1380 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1381 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
1382 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1383 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
1384 settings->sync ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1385 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1386
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1387 // 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
1388 // 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
1389 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
1390 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1391 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
1392 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
1393
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1394 #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
1395 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
1396 #endif
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1397 }
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 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
1400 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1401 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
1402 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1403 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
1404 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
1405 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1406 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
1407 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
1408 }
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 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1411 emit copyClipboard_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1412 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1413
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1414 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
1415 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1416 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
1417 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1418 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
1419 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
1420 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
1421 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
1422 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1423 edit->insert (str);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1424 }
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 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1427 emit pasteClipboard_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1428 }
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 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
1431 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1432 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
1433 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1434 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
1435 if (edit)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1436 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1437 edit->selectAll ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1438 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1439 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1440 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1441 emit selectAll_signal ();
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1444 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
1445 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1446 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
1447 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
1448 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1449
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1450 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
1451 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1452 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
1453 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1454
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1455 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
1456 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1457 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
1458 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1459
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1460 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
1461 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1462 // 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
1463 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
1464
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1465 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
1466
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1467 if (settings)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1468 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1469 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
1470 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1471 // restore last dir from previous session
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1472 QStringList curr_dirs
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1473 = settings->value ("MainWindow/current_directory_list").toStringList ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1474 startup_dir
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1475 = 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
1476 }
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1477 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
1478 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1479 // 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
1480 startup_dir
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1481 = 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
1482 }
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
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1485 if (! startup_dir.exists ())
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1486 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1487 // 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
1488 startup_dir = QDir ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1489 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1490
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1491 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
1492
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1493 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
1494 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1495 #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
1496 // 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
1497 // 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
1498 // 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
1499 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
1500 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
1501 #endif
24715
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
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1504 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
1505 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1506
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1507 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
1508 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1509
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1510 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
1511 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1512 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
1513
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1514 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
1515 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
1516
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1517 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
1518 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
1519 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
1520
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1521 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
1522 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
1523
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1524 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
1525 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1526
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1527 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
1528 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1529 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
1530 }
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 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
1533
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1534 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
1535
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1536 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1537
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1538 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
1539 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1540 // 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
1541
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1542 // 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
1543 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
1544 return;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1545
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1546 if (set_shortcuts)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1547 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1548 // 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
1549 configure_shortcuts ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1550 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1551 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1552 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1553 // 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
1554 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
1555
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1556 // file menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1557 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
1558 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
1559 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
1560 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
1561 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
1562 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
1563 m_preferences_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
1564 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
1565
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1566 // edit menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1567 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
1568 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
1569 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
1570 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
1571 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
1572 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
1573
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1574 // window menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1575 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
1576
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1577 // help menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1578 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
1579 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
1580 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
1581 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
1582 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
1583 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
1584 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
1585
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1586 // news menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1587 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
1588 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
1589 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1590 }
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 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
1593 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1594 octave_link::post_event (this, &main_window::set_screen_size_callback,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1595 int_pair (ht, wd));
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 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
1599 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1600 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
1601 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1602 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
1603 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
1604 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1605 else
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 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
1608 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
1609 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1610 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1611
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1612 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
1613 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1614 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
1615 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1616
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1617 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
1618 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1619 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
1620
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1621 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
1622 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1623 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
1624 ++i;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1625 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1626 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1627
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1628 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
1629 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1630 // 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
1631 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
1632 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
1633 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
1634 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
1635 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1636
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1637 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
1638 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1639 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
1640 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1641
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1642 // 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
1643 // 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
1644 // m_file_encoding
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1645 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
1646 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1647 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
1648 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
1649 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1650
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1651 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
1652 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1653 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
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_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
1656 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1657 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
1658 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
1659 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1660
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1661 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1662
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1663 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
1664 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1665 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
1666 }
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 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
1669 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1670 // 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
1671 // 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
1672 // 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
1673 // 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
1674
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1675 octave_link::post_event (this, &main_window::refresh_workspace_callback);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1676 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1677
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1678 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
1679 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1680 e->ignore ();
26323
3c2264556abc gui: exit even when shadowing the 'exit' or 'quit' builtins (bug #55324)
Mike Miller <mtmiller@octave.org>
parents: 26309
diff changeset
1681 octave_cmd_builtin *cmd = new octave_cmd_builtin (&Fquit, ovl ());
25907
0146d16055a8 use signal/slot to give all gui dock widgets access to the command queue
Torsten <mttl@mailbox.org>
parents: 25892
diff changeset
1682 queue_cmd (cmd);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1683 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1684
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1685 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
1686 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1687 // 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
1688 // 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
1689 // 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
1690
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1691 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
1692 dummyWidget->setObjectName ("CentralDummyWidget");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1693 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
1694 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
1695 dummyWidget->hide ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1696 setCentralWidget (dummyWidget);
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1697 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1698
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1699 // Main subroutine of the constructor
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1700
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1701 void main_window::construct (void)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1702 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1703 setWindowIcon (QIcon (":/actions/icons/logo.png"));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1704
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1705 m_workspace_window->setModel (m_workspace_model);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1706
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1707 connect (m_workspace_model, SIGNAL (model_changed (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1708 m_workspace_window, SLOT (handle_model_changed (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1709
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1710 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1711 SIGNAL (edit_variable_signal (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1712 const octave_value&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1713 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1714 SLOT (edit_variable (const QString&, const octave_value&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1715
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1716 connect (m_octave_qt_link, SIGNAL (refresh_variable_editor_signal (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1717 this, SLOT (refresh_variable_editor (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1718
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1719 connect (m_workspace_model,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1720 SIGNAL (rename_variable (const QString&, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1721 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1722 SLOT (handle_rename_variable_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1723 const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1724
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1725 connect (m_variable_editor_window, SIGNAL (updated (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1726 this, SLOT (handle_variable_editor_update (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1727
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1728 construct_menu_bar ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1729
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1730 construct_tool_bar ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1731
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1732 // Order is important. Deleting QSettings must be last.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1733 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1734 m_command_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1735
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1736 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1737 m_history_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1738
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1739 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1740 m_file_browser_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1741
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1742 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1743 m_doc_browser_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1744
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1745 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1746 m_workspace_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1747
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1748 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1749 m_editor_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1750
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1751 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1752 m_variable_editor_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1753
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1754 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1755 this, SLOT (prepare_to_exit (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1756
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1757 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1758 shortcut_manager::instance, SLOT (cleanup_instance (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1759
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1760 // 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
1761 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1762 resource_manager::instance, SLOT (cleanup_instance (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1763
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1764 connect (qApp, SIGNAL (focusChanged (QWidget*, QWidget*)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1765 this, SLOT (focus_changed (QWidget*, QWidget*)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1766
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1767 connect (this, SIGNAL (settings_changed (const QSettings *)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1768 this, SLOT (notice_settings (const QSettings *)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1769
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1770 connect (this, SIGNAL (editor_focus_changed (bool)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1771 this, SLOT (disable_menu_shortcuts (bool)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1772
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1773 connect (this, SIGNAL (editor_focus_changed (bool)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1774 m_editor_window, SLOT (enable_menu_shortcuts (bool)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1775
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1776 connect (m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1777 SIGNAL (request_open_file_external (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1778 m_external_editor,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1779 SLOT (call_custom_editor (const QString&, int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1780
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1781 connect (m_external_editor,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1782 SIGNAL (request_settings_dialog (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1783 this, SLOT (process_settings_dialog_request (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1784
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1785 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
1786 this, SLOT (handle_load_workspace_request (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1787
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1788 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
1789 this, SLOT (handle_open_any_request (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1790
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1791 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
1792 this, SLOT (find_files (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1793
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1794 setWindowTitle ("Octave");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1795
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1796 // 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
1797 #if (QT_VERSION < 0x050601) || (QT_VERSION >= 0x050701)
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1798 setDockOptions (QMainWindow::AnimatedDocks
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1799 | QMainWindow::AllowNestedDocks
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1800 | 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
1801 #else
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1802 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
1803 #endif
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1804
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1805 addDockWidget (Qt::RightDockWidgetArea, m_command_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1806 addDockWidget (Qt::RightDockWidgetArea, m_doc_browser_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1807 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
1808
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
1809 #if defined (HAVE_QSCINTILLA)
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1810 addDockWidget (Qt::RightDockWidgetArea, m_editor_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1811 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
1812 #endif
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1813 addDockWidget (Qt::RightDockWidgetArea, m_variable_editor_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1814 tabifyDockWidget (m_command_window, m_variable_editor_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1815
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1816 addDockWidget (Qt::LeftDockWidgetArea, m_file_browser_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1817 addDockWidget (Qt::LeftDockWidgetArea, m_workspace_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1818 addDockWidget (Qt::LeftDockWidgetArea, m_history_window);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1819
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1820 int win_x = QApplication::desktop ()->width ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1821 int win_y = QApplication::desktop ()->height ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1822
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1823 if (win_x > 960)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1824 win_x = 960;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1825
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1826 if (win_y > 720)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1827 win_y = 720;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1828
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1829 setGeometry (0, 0, win_x, win_y);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1830
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1831 setStatusBar (m_status_bar);
24019
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
1832
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
1833 #if defined (HAVE_QSCINTILLA)
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1834 connect (this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1835 SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1836 m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1837 SLOT (handle_insert_debugger_pointer_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1838 int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1839
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1840 connect (this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1841 SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1842 m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1843 SLOT (handle_delete_debugger_pointer_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1844 int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1845
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1846 connect (this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1847 SIGNAL (update_breakpoint_marker_signal (bool, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1848 int, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1849 m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1850 SLOT (handle_update_breakpoint_marker_request (bool,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1851 const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1852 int,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1853 const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1854
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1855 // 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
1856 connect (m_file_browser_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1857 SIGNAL (file_remove_signal (const QString&, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1858 m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1859 SLOT (handle_file_remove (const QString&, const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1860
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1861 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
1862 m_editor_window, SLOT (handle_file_renamed (bool)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1863
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1864 // Signals for removing/renaming files/dirs in the temrinal window
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
1865 connect (m_octave_qt_link, SIGNAL (file_renamed_signal (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
1866 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
1867 #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
1868
32d9f57d7245 fix missing unlock of mutex when gui editor is not present (bug #56097)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1869 // Signals for removing/renaming files/dirs in the temrinal window
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1870 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1871 SIGNAL (file_remove_signal (const QString&, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1872 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
1873
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1874 octave_link::post_event (this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1875 &main_window::resize_command_window_callback);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1876
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1877 configure_shortcuts ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1878 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1879
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1880 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
1881 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1882 connect (m_octave_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
1883 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
1884 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
1885 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
1886
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1887 connect (m_octave_qt_link, SIGNAL (clear_workspace_signal (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1888 m_workspace_model, SLOT (clear_workspace (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1889
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1890 connect (m_octave_qt_link, SIGNAL (change_directory_signal (QString)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1891 this, SLOT (change_directory (QString)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1892
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1893 connect (m_octave_qt_link, SIGNAL (change_directory_signal (QString)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1894 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
1895
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1896 connect (m_octave_qt_link, SIGNAL (change_directory_signal (QString)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1897 m_editor_window, SLOT (update_octave_directory (QString)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1898
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1899 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1900 SIGNAL (execute_command_in_terminal_signal (QString)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1901 this, SLOT (execute_command_in_terminal (QString)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1902
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1903 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1904 SIGNAL (set_history_signal (const QStringList&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1905 m_history_window, SLOT (set_history (const QStringList&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1906
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1907 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1908 SIGNAL (append_history_signal (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1909 m_history_window, SLOT (append_history (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1910
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1911 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1912 SIGNAL (clear_history_signal (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1913 m_history_window, SLOT (clear_history (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1914
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1915 connect (m_octave_qt_link, SIGNAL (enter_debugger_signal (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1916 this, SLOT (handle_enter_debugger (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1917
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1918 connect (m_octave_qt_link, SIGNAL (exit_debugger_signal (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1919 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
1920
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1921 connect (m_octave_qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1922 SIGNAL (show_preferences_signal (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1923 this, SLOT (process_settings_dialog_request (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1924
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1925 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1926 SIGNAL (gui_preference_signal (const QString&, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1927 QString*)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1928 this, SLOT (gui_preference (const QString&, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1929 QString*)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1930
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1931 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1932 SIGNAL (edit_file_signal (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1933 m_active_editor,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1934 SLOT (handle_edit_file_request (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1935
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1936 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1937 SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
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 (handle_insert_debugger_pointer_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1940 int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1941
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1942 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1943 SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1944 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1945 SLOT (handle_delete_debugger_pointer_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1946 int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1947
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1948 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1949 SIGNAL (update_breakpoint_marker_signal (bool, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1950 int, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1951 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1952 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
1953 int, const QString&)));
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 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1956 SIGNAL (show_doc_signal (const QString &)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1957 this, SLOT (handle_show_doc (const QString &)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1958
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1959 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1960 SIGNAL (register_doc_signal (const QString &)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1961 this, SLOT (handle_register_doc (const QString &)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1962
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1963 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1964 SIGNAL (unregister_doc_signal (const QString &)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1965 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
1966 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1967
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1968 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
1969 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
1970 const QWidget *receiver)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1971 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1972 QAction *a;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1973
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1974 if (receiver)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1975 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
1976 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1977 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
1978
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1979 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
1980 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
1981 return a;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1982 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1983
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1984 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
1985 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1986 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
1987
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1988 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
1989 // 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
1990 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
1991 // remove single '&' (shortcut)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1992 base_name.remove ("&");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1993 // restore intended '&'
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1994 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
1995
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1996 // 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
1997 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
1998
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1999 return menu;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2000 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2001
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2002 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
2003 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2004 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
2005
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2006 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
2007
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2008 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
2009
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2010 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
2011
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2012 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
2013
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2014 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
2015
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2016 construct_news_menu (menu_bar);
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
2017
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2018 #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
2019 // 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
2020 // 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
2021 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
2022 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
2023 << 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
2024 << m_open_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2025 << 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
2026 << m_undo_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2027 << m_copy_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2028 << m_paste_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2029 <<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
2030 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
2031 #endif
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2032 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2033
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2034 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
2035 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2036 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
2037
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2038 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
2039
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2040 m_open_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2041 = 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
2042 tr ("Open..."));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2043 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
2044 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
2045
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2046 #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
2047 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
2048 #endif
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2049
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2050 file_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2051
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2052 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
2053 = 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
2054
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2055 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
2056 = 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
2057
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2058 file_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2059
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2060 m_exit_action = file_menu->addAction (tr ("Exit"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2061 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
2062
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2063 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
2064 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
2065
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2066 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
2067 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
2068
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2069 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
2070 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
2071
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2072 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
2073 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
2074 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2075
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2076 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
2077 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2078 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
2079
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2080 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
2081 = 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
2082 tr ("New Script"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2083 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
2084
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2085 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
2086 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
2087 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
2088
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2089 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
2090 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
2091
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2092 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
2093 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
2094
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2095 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
2096 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
2097
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2098 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
2099 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
2100
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2101 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
2102 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
2103
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2104 connect (this,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2105 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
2106 m_active_editor,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2107 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
2108
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2109 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
2110 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
2111 }
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 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
2114 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2115 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
2116
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2117 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
2118
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2119 m_undo_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2120 = 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
2121 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
2122
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2123 edit_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2124
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2125 m_copy_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2126 = 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
2127 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
2128 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
2129
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2130 m_paste_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2131 = 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
2132 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
2133 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
2134
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2135 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
2136 = 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
2137 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
2138
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2139 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
2140 = 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
2141 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
2142
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2143 edit_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2144
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2145 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
2146 = 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
2147 tr ("Find Files..."));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2148
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2149 edit_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2150
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2151 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
2152 = 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
2153
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2154 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
2155 = 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
2156
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2157 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
2158 = 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
2159
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2160 edit_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2161
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2162 m_preferences_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2163 = 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
2164 tr ("Preferences..."));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2165
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2166 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
2167 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
2168
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2169 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
2170 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
2171
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2172 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
2173 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
2174
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2175 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
2176 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
2177
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2178 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
2179 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
2180 clipboard_has_changed ();
24625
be37df6e1fb4 always enable paste action in windows (bug #52361)
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
2181 #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
2182 // 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
2183 // 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
2184 // are working again
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2185 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
2186 m_clear_clipboard_action->setEnabled (true);
24625
be37df6e1fb4 always enable paste action in windows (bug #52361)
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
2187 #endif
20039
3538c2824dd8 GUI: Move preferences to edit menu (Bug #44725)
John Donoghue
parents: 19985
diff changeset
2188
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2189 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
2190 this, SLOT (process_settings_dialog_request (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2191 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2192
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2193 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
2194 const QString& item,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2195 const char *member)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2196 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2197 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
2198 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
2199 item, member);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2200
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2201 action->setEnabled (false);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2202
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2203 #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
2204 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
2205 m_editor_window->toolbar ()->addAction (action);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2206 #endif
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2207
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2208 return action;
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2211 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
2212 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2213 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
2214
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2215 m_debug_step_over = construct_debug_menu_item (
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2216 "db-step", tr ("Step"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2217 SLOT (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
2218
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2219 m_debug_step_into = construct_debug_menu_item (
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2220 "db-step-in", tr ("Step In"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2221 SLOT (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
2222
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2223 m_debug_step_out = construct_debug_menu_item (
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2224 "db-step-out", tr ("Step Out"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2225 SLOT (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
2226
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2227 m_debug_continue = construct_debug_menu_item (
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2228 "db-cont", tr ("Continue"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2229 SLOT (debug_continue (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2230
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2231 m_debug_menu->addSeparator ();
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2232 #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
2233 m_editor_window->debug_menu ()->addSeparator ();
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2234 #endif
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2235
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2236 m_debug_quit = construct_debug_menu_item (
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2237 "db-stop", tr ("Quit Debug Mode"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2238 SLOT (debug_quit (void)));
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2241 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
2242 const QString& item,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2243 bool checkable,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2244 QWidget *widget)
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 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
2247
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2248 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
2249 action->setCheckable (checkable);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2250 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
2251
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2252 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
2253 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2254 if (checkable)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2255 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2256 // 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
2257 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
2258 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
2259
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2260 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
2261 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
2262 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2263 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2264 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2265 // action for focus of dock widget
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2266 connect (action, SIGNAL (triggered (void)), widget, SLOT (focus (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2267 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2268 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2269
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2270 return action;
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2273 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
2274 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2275 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
2276
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2277 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
2278 (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
2279
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2280 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
2281 (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
2282
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2283 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
2284 (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
2285
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2286 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
2287 (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
2288
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2289 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
2290 (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
2291
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2292 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
2293 (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
2294
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2295 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
2296 (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
2297
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2298 window_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2299
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2300 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
2301 (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
2302
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2303 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
2304 (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
2305
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2306 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
2307 (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
2308
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2309 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
2310 (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
2311
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2312 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
2313 (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
2314
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2315 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
2316 (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
2317
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2318 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
2319 (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
2320
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2321 window_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2322
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2323 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
2324 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
2325 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2326
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2327 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
2328 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2329 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
2330
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2331 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
2332
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2333 help_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2334
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2335 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
2336 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
2337
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2338 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
2339 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
2340
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2341 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
2342 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
2343
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2344 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
2345 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
2346
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2347 help_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2348
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2349 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
2350 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
2351 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2352
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2353 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
2354 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2355 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
2356
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2357 m_ondisk_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
2358 tr ("On Disk"), SLOT (focus ()), 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
2359
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2360 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
2361 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
2362 }
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 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
2365 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2366 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
2367
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2368 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
2369 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
2370
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2371 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
2372 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
2373 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2374
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2375 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
2376 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2377 m_main_tool_bar = addToolBar (tr ("Toolbar"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2378
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2379 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
2380 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
2381 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
2382
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2383 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
2384
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2385 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
2386 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
2387 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
2388
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2389 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
2390
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2391 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
2392 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
2393 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
2394 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
2395 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
2396 m_current_directory_combo_box->setToolTip (tr ("Enter directory name"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2397 m_current_directory_combo_box->setMaxVisibleItems (
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2398 current_directory_max_visible);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2399 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
2400 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
2401 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
2402
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2403 // 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
2404 // 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
2405 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
2406 m_main_tool_bar->addWidget (m_current_directory_combo_box);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2407 QAction *current_dir_up = m_main_tool_bar->addAction (
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2408 resource_manager::icon ("go-up"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2409 tr ("One directory up"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2410 QAction *current_dir_search = m_main_tool_bar->addAction (
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2411 resource_manager::icon ("folder"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2412 tr ("Browse directories"));
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_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
2415 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
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_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
2418 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
2419
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2420 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
2421 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
2422
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2423 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
2424 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
2425
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2426 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
2427 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
2428 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2429
25700
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2430 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
2431 const QString& value)
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2432 {
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2433 QString adjusted_value = value;
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2434
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2435 // 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
2436 if (adjusted_value.isEmpty ())
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2437 return adjusted_value;
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2438
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2439 // 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
2440 // 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
2441 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
2442 {
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2443 adjusted_value = adjusted_value.toUpper ();
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2444
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2445 QStringList codecs;
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2446 resource_manager::get_codecs (&codecs);
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2447
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2448 QRegExp re ("^CP(\\d+)$");
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2449 if (re.indexIn (adjusted_value) > -1)
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2450 {
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2451 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
2452 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
2453 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
2454 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
2455 else
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2456 adjusted_value.clear ();
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2457 }
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2458 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
2459 adjusted_value.clear ();
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2460 }
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2461
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2462 return adjusted_value;
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2463 }
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2464
25639
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2465 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
2466 QString* read_value)
25639
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2467 {
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2468 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
2469 *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
2470
25678
3418d3729a51 use exisitng mutex in octave_qt_link for changing gui preferences (bug #54369)
Torsten <mttl@mailbox.org>
parents: 25639
diff changeset
2471 // Wait for worker to suspend
3418d3729a51 use exisitng mutex in octave_qt_link for changing gui preferences (bug #54369)
Torsten <mttl@mailbox.org>
parents: 25639
diff changeset
2472 m_octave_qt_link->lock ();
3418d3729a51 use exisitng mutex in octave_qt_link for changing gui preferences (bug #54369)
Torsten <mttl@mailbox.org>
parents: 25639
diff changeset
2473
25700
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2474 // Some preferences need extra handling
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2475 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
2476
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2477 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
2478 {
25700
ba8227df92ae synchronize gui editor encoding when changing __mfile_encdoing__ (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25678
diff changeset
2479 // 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
2480 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
2481 emit settings_changed (settings);
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2482 }
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2483
25678
3418d3729a51 use exisitng mutex in octave_qt_link for changing gui preferences (bug #54369)
Torsten <mttl@mailbox.org>
parents: 25639
diff changeset
2484 // We are done: Unlock and wake the worker thread
3418d3729a51 use exisitng mutex in octave_qt_link for changing gui preferences (bug #54369)
Torsten <mttl@mailbox.org>
parents: 25639
diff changeset
2485 m_octave_qt_link->unlock ();
3418d3729a51 use exisitng mutex in octave_qt_link for changing gui preferences (bug #54369)
Torsten <mttl@mailbox.org>
parents: 25639
diff changeset
2486 m_octave_qt_link->wake_all ();
25639
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2487 }
7644e7f1721f change gui preferences from within the worker thread (bug #49119)
Torsten <mttl@mailbox.org>
parents: 25616
diff changeset
2488
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2489 void main_window::rename_variable_callback (const main_window::name_pair& names)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2490 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2491 // INTERPRETER THREAD
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2492
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2493 symbol_scope scope
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2494 = __get_current_scope__ ("main_window::rename_variable_callback");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2495
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2496 if (scope)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2497 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2498 scope.rename (names.first, names.second);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2499
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
2500 call_stack& cs
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
2501 = __get_call_stack__ ("main_window::rename_variable_callback");
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
2502
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
2503 octave_link::set_workspace (true, cs.get_symbol_info ());
24715
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2506 // FIXME: if this action fails, do we need a way to display that info
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2507 // in the GUI?
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2510 void main_window::command_window_undo_callback (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2511 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2512 // INTERPRETER THREAD
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2513
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2514 command_editor::undo ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2515 command_editor::redisplay ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2516 }
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 void main_window::clear_command_window_callback (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2519 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2520 // INTERPRETER THREAD
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2521
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2522 command_editor::kill_full_line ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2523 command_editor::clear_screen ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2524 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2525
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2526 void main_window::resize_command_window_callback (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2527 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2528 // INTERPRETER THREAD
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 command_editor::resize_terminal ();
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2533 void main_window::set_screen_size_callback (const int_pair& sz)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2534 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2535 // INTERPRETER THREAD
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 command_editor::set_screen_size (sz.first, sz.second);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2538 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2539
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
2540 void main_window::open_any_callback (const std::string& file)
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
2541 {
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
2542 // INTERPRETER THREAD
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
2543
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
2544 octave::feval ("open", ovl (file));
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
2545
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
2546 // Update the workspace since open.m may have loaded new variables.
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
2547 call_stack& cs
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
2548 = __get_call_stack__ ("main_window::open_any_callback");
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
2549
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
2550 octave_link::set_workspace (true, cs.get_symbol_info ());
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
2551 }
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
2552
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2553 void main_window::clear_history_callback (void)
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 // INTERPRETER THREAD
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2556
25994
f881d3e271d2 eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents: 25956
diff changeset
2557 history_system& history_sys
f881d3e271d2 eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents: 25956
diff changeset
2558 = __get_history_system__ ("main_window::clear_history_callback");
f881d3e271d2 eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents: 25956
diff changeset
2559
f881d3e271d2 eliminate global and file-scope static variables in oct-hist.cc
John W. Eaton <jwe@octave.org>
parents: 25956
diff changeset
2560 history_sys.do_history (ovl ("-c"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2561 }
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 void main_window::refresh_workspace_callback (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2564 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2565 // INTERPRETER THREAD
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2566
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
2567 call_stack& cs
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
2568 = __get_call_stack__ ("main_window::force_refresh_workspace");
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
2569
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
2570 octave_link::set_workspace (true, cs.get_symbol_info (), false);
24715
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2573 bool main_window::focus_console_after_command (void)
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 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
2576 return settings->value ("terminal/focus_after_command",false).toBool ();
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
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2579 void main_window::new_figure_callback (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2580 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2581 // INTERPRETER THREAD
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 interpreter& interp
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2584 = __get_interpreter__ ("main_window::new_figure_callback");
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 Fbuiltin (interp, ovl ("figure"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2587 Fdrawnow ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2588 }
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 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
2591 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2592 // file menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2593 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
2594 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
2595 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
2596 "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
2597 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
2598 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
2599 "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
2600 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
2601 "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
2602 shortcut_manager::set_shortcut (m_preferences_action, "main_file:preferences");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2603 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
2604
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2605 // edit menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2606 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
2607 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
2608 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
2609 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
2610 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
2611 "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
2612 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
2613 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
2614 "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
2615 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
2616 "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
2617 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
2618 "main_edit:clear_workspace");
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 // debug menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2621 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
2622 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
2623 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
2624 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
2625 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
2626
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2627 // window menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2628 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
2629 "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
2630 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
2631 "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
2632 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
2633 "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
2634 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
2635 "main_window:show_file_browser");
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
2636 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
2637 "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
2638 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
2639 "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
2640 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
2641 "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
2642 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
2643 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
2644 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
2645 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
2646 "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
2647 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
2648 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
2649 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
2650 "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
2651 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
2652
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2653 // help menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2654 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
2655 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
2656 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
2657 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
2658 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
2659 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
2660 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
2661
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2662 // news menu
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2663 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
2664 "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
2665 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
2666 "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
2667 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2668
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2669 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
2670 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2671 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
2672 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
2673 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
2674 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
2675 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
2676 #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
2677 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
2678 #endif
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2679 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
2680 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
2681 return list;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2682 }
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 void news_reader::process (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2685 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2686 QString html_text;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2687
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2688 if (m_connect_to_web)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2689 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2690 // Run this part in a separate thread so Octave can continue to
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2691 // run while we wait for the page to load. Then emit the signal
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2692 // to display it when we have the page contents.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2693
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2694 QString url = m_base_url + '/' + m_page;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2695 std::ostringstream buf;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2696 url_transfer octave_dot_org (url.toStdString (), buf);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2697
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2698 if (octave_dot_org.is_valid ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2699 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2700 Array<std::string> param;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2701 octave_dot_org.http_get (param);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2702
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2703 if (octave_dot_org.good ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2704 html_text = QString::fromStdString (buf.str ());
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2705 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2706
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2707 if (html_text.contains ("this-is-the-gnu-octave-community-news-page"))
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2708 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2709 if (m_serial >= 0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2710 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2711 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
2712
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2713 if (settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2714 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2715 settings->setValue ("news/last_time_checked",
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2716 QDateTime::currentDateTime ());
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2717
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2718 settings->sync ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2719 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2720
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2721 QString tag ("community-news-page-serial=");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2722
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2723 int b = html_text.indexOf (tag);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2724
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2725 if (b)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2726 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2727 b += tag.length ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2728
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2729 int e = html_text.indexOf ("\n", b);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2730
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2731 QString tmp = html_text.mid (b, e-b);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2732
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2733 int curr_page_serial = tmp.toInt ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2734
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2735 if (curr_page_serial > m_serial)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2736 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2737 if (settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2738 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2739 settings->setValue ("news/last_news_item",
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2740 curr_page_serial);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2741
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2742 settings->sync ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2743 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2744 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2745 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2746 return;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2747 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2748 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2749 return;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2750 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2751 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2752 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2753 html_text = QString
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2754 (tr ("<html>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2755 "<body>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2756 "<p>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2757 "Octave's community news source seems to be unavailable.\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2758 "</p>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2759 "<p>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2760 "For the latest news, please check\n"
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
2761 "<a href=\"https://octave.org/community-news.html\">https://octave.org/community-news.html</a>\n"
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2762 "when you have a connection to the web (link opens in an external browser).\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2763 "</p>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2764 "<p>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2765 "<small><em>&mdash; The Octave Developers, ") + OCTAVE_RELEASE_DATE + "</em></small>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2766 "</p>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2767 "</body>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2768 "</html>\n");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2769 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2770 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2771 html_text = QString
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2772 (tr ("<html>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2773 "<body>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2774 "<p>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2775 "Connecting to the web to display the latest Octave Community news has been disabled.\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2776 "</p>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2777 "<p>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2778 "For the latest news, please check\n"
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
2779 "<a href=\"https://octave.org/community-news.html\">https://octave.org/community-news.html</a>\n"
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2780 "when you have a connection to the web (link opens in an external browser)\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2781 "or enable web connections for news in Octave's network settings dialog.\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2782 "</p>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2783 "<p>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2784 "<small><em>&mdash; The Octave Developers, ") + OCTAVE_RELEASE_DATE + "</em></small>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2785 "</p>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2786 "</body>\n"
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2787 "</html>\n");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2788
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2789 emit display_news_signal (html_text);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2790
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2791 emit finished ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2792 }
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2793
26277
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2794 //! Reimplements QApplication::notify.
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2795 /*! Octave's own exceptions are caugh and rethrown in the interpreter
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2796 thread.*/
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2797 bool
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2798 octave_qapplication::notify (QObject *receiver, QEvent *ev)
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2799 {
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2800 try
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2801 {
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2802 return QApplication::notify (receiver, ev);
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2803 }
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2804 catch (octave::execution_exception&)
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2805 {
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2806 octave_link::post_exception (std::current_exception ());
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2807 }
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2808
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2809 return false;
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2810 }
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2811
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2812 octave_qt_app::octave_qt_app (gui_application& app_context)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2813 : QObject (), m_app_context (app_context),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2814 m_argc (m_app_context.sys_argc ()),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2815 m_argv (m_app_context.sys_argv ()), m_qt_app (nullptr),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2816 m_qt_tr (new QTranslator ()), m_gui_tr (new QTranslator ()),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2817 m_qsci_tr (new QTranslator ()), m_translators_installed (false),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2818 m_octave_qt_link (new octave_qt_link ()),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2819 m_interpreter (new octave_interpreter (m_app_context)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2820 m_main_thread (new QThread ()),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2821 m_main_window (nullptr)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2822 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2823 std::string show_gui_msgs =
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2824 sys::env::getenv ("OCTAVE_SHOW_GUI_MESSAGES");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2825
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2826 // Installing our handler suppresses the messages.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2827
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2828 if (show_gui_msgs.empty ())
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2829 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2830 #if defined (HAVE_QINSTALLMESSAGEHANDLER)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2831 qInstallMessageHandler (message_handler);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2832 #else
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2833 qInstallMsgHandler (message_handler);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2834 #endif
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2835 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2836
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2837 // Set the codec for all strings (before wizard or any GUI object)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2838 #if ! defined (Q_OS_WIN32)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2839 QTextCodec::setCodecForLocale (QTextCodec::codecForName ("UTF-8"));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2840 #endif
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2841
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2842 #if defined (HAVE_QT4)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2843 QTextCodec::setCodecForCStrings (QTextCodec::codecForName ("UTF-8"));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2844 #endif
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2845
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2846 // Initialize global Qt application metadata.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2847
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2848 QCoreApplication::setApplicationName ("GNU Octave");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2849 QCoreApplication::setApplicationVersion (OCTAVE_VERSION);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2850
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2851 // Register octave_value_list for connecting thread crossing signals.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2852
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2853 qRegisterMetaType<octave_value_list> ("octave_value_list");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2854
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2855 // Even if START_GUI is false, we still set up the QApplication so
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2856 // that we can use Qt widgets for plot windows.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2857
26277
e92a44730a6e Rethrow exceptions from the GUI to the interpreter thread (bug #54920)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26227
diff changeset
2858 m_qt_app = new octave_qapplication (m_argc, m_argv);
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2859
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2860 // Force left-to-right alignment (see bug #46204)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2861 m_qt_app->setLayoutDirection (Qt::LeftToRight);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2862
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2863 octave_link::connect_link (m_octave_qt_link);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2864
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2865 connect (m_octave_qt_link, SIGNAL (confirm_shutdown_signal (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2866 this, SLOT (confirm_shutdown_octave (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2867
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2868 connect (m_octave_qt_link,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2869 SIGNAL (copy_image_to_clipboard_signal (const QString&, bool)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2870 this, SLOT (copy_image_to_clipboard (const QString&, bool)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2871
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2872 connect_uiwidget_links ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2873
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2874 connect (m_interpreter, SIGNAL (octave_finished_signal (int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2875 this, SLOT (handle_octave_finished (int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2876
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2877 connect (m_interpreter, SIGNAL (octave_finished_signal (int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2878 m_main_thread, SLOT (quit (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2879
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2880 connect (m_main_thread, SIGNAL (finished (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2881 m_main_thread, SLOT (deleteLater (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2882
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2883 if (m_app_context.start_gui_p ())
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2884 create_main_window ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2885 else
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2886 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2887 // Get settings file.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2888 resource_manager::reload_settings ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2889
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2890 // After settings.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2891 config_translators ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2892
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2893 m_qt_app->setQuitOnLastWindowClosed (false);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2894 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2895
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2896 // Defer initializing and executing the interpreter until after the main
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2897 // window and QApplication are running to prevent race conditions
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2898 QTimer::singleShot (0, m_interpreter, SLOT (execute (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2899
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2900 m_interpreter->moveToThread (m_main_thread);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2901
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2902 m_main_thread->start ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2903 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2904
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2905 octave_qt_app::~octave_qt_app (void)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2906 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2907 delete m_main_window;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2908 delete m_interpreter;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2909 delete m_qt_app;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2910
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2911 string_vector::delete_c_str_vec (m_argv);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2912 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2913
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2914 void octave_qt_app::config_translators (void)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2915 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2916 if (m_translators_installed)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2917 return;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2918
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2919 resource_manager::config_translators (m_qt_tr, m_qsci_tr, m_gui_tr);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2920
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2921 m_qt_app->installTranslator (m_qt_tr);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2922 m_qt_app->installTranslator (m_gui_tr);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2923 m_qt_app->installTranslator (m_qsci_tr);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2924
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2925 m_translators_installed = true;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2926 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2927
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2928 void octave_qt_app::create_main_window (void)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2929 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2930 m_main_window = new main_window (*this, m_octave_qt_link);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2931
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2932 connect (m_interpreter, SIGNAL (octave_ready_signal (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2933 m_main_window, SLOT (handle_octave_ready (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2934
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2935 m_app_context.gui_running (true);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2936 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2937
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2938 int octave_qt_app::exec (void)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2939 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2940 return m_qt_app->exec ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2941 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2942
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2943 void octave_qt_app::handle_octave_finished (int exit_status)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2944 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2945 qApp->exit (exit_status);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2946 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2947
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2948 void octave_qt_app::confirm_shutdown_octave (void)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2949 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2950 bool closenow = true;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2951
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2952 if (m_main_window)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2953 closenow = m_main_window->confirm_shutdown_octave ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2954
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2955 // Wait for link thread to go to sleep state.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2956 m_octave_qt_link->lock ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2957
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2958 m_octave_qt_link->shutdown_confirmation (closenow);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2959
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2960 m_octave_qt_link->unlock ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2961
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2962 // Awake the worker thread so that it continues shutting down (or not).
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2963 m_octave_qt_link->wake_all ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2964 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2965
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2966 void octave_qt_app::copy_image_to_clipboard (const QString& file,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2967 bool remove_file)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2968 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2969 QClipboard *clipboard = QApplication::clipboard ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2970
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2971 QImage img (file);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2972
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2973 if (img.isNull ())
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2974 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2975 // Report error?
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2976 return;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2977 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2978
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2979 clipboard->setImage (img);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2980
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2981 if (remove_file)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2982 QFile::remove (file);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2983 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2984
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2985 // Create a message dialog with specified string, buttons and decorative
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2986 // text.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2987
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2988 void octave_qt_app::handle_create_dialog (const QString& message,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2989 const QString& title,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2990 const QString& icon,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2991 const QStringList& button,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2992 const QString& defbutton,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2993 const QStringList& role)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2994 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2995 MessageDialog *message_dialog = new MessageDialog (message, title, icon,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2996 button, defbutton, role);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2997 message_dialog->setAttribute (Qt::WA_DeleteOnClose);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2998 message_dialog->show ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2999 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3000
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3001 // Create a list dialog with specified list, initially selected, mode,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3002 // view size and decorative text.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3003
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3004 void octave_qt_app::handle_create_listview (const QStringList& list,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3005 const QString& mode,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3006 int wd, int ht,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3007 const QIntList& initial,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3008 const QString& name,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3009 const QStringList& prompt,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3010 const QString& ok_string,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3011 const QString& cancel_string)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3012 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3013 ListDialog *list_dialog = new ListDialog (list, mode, wd, ht,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3014 initial, name, prompt,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3015 ok_string, cancel_string);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3016
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3017 list_dialog->setAttribute (Qt::WA_DeleteOnClose);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3018 list_dialog->show ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3019 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3020
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3021 // Create an input dialog with specified prompts and defaults, title and
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3022 // row/column size specifications.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3023 void octave_qt_app::handle_create_inputlayout (const QStringList& prompt,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3024 const QString& title,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3025 const QFloatList& nr,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3026 const QFloatList& nc,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3027 const QStringList& defaults)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3028 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3029 InputDialog *input_dialog = new InputDialog (prompt, title, nr, nc,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3030 defaults);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3031
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3032 input_dialog->setAttribute (Qt::WA_DeleteOnClose);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3033 input_dialog->show ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3034 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3035
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3036 void octave_qt_app::handle_create_filedialog (const QStringList& filters,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3037 const QString& title,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3038 const QString& filename,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3039 const QString& dirname,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3040 const QString& multimode)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3041 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3042 FileDialog *file_dialog = new FileDialog (filters, title, filename,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3043 dirname, multimode);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3044
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3045 file_dialog->setAttribute (Qt::WA_DeleteOnClose);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3046 file_dialog->show ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3047 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3048
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3049 // Connect the signals emitted when the Octave thread wants to create
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3050 // a dialog box of some sort. Perhaps a better place for this would be
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3051 // as part of the QUIWidgetCreator class. However, mainWindow currently
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3052 // is not a global variable and not accessible for connecting.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3053
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3054 void octave_qt_app::connect_uiwidget_links (void)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3055 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3056 connect (&uiwidget_creator,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3057 SIGNAL (create_dialog (const QString&, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3058 const QString&, const QStringList&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3059 const QString&, const QStringList&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3060 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3061 SLOT (handle_create_dialog (const QString&, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3062 const QString&, const QStringList&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3063 const QString&, const QStringList&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3064
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3065 // Register QIntList so that list of ints may be part of a signal.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3066 qRegisterMetaType<QIntList> ("QIntList");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3067 connect (&uiwidget_creator,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3068 SIGNAL (create_listview (const QStringList&, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3069 int, int, const QIntList&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3070 const QString&, const QStringList&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3071 const QString&, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3072 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3073 SLOT (handle_create_listview (const QStringList&, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3074 int, int, const QIntList&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3075 const QString&, const QStringList&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3076 const QString&, const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3077
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3078 // Register QFloatList so that list of floats may be part of a signal.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3079 qRegisterMetaType<QFloatList> ("QFloatList");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3080 connect (&uiwidget_creator,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3081 SIGNAL (create_inputlayout (const QStringList&, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3082 const QFloatList&, const QFloatList&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3083 const QStringList&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3084 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3085 SLOT (handle_create_inputlayout (const QStringList&, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3086 const QFloatList&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3087 const QFloatList&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3088 const QStringList&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3089
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3090 connect (&uiwidget_creator,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3091 SIGNAL (create_filedialog (const QStringList &,const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3092 const QString&, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3093 const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3094 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3095 SLOT (handle_create_filedialog (const QStringList &, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3096 const QString&, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3097 const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
3098 }
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
3099 }