annotate libgui/src/main-window.cc @ 23385:41639665aa34

improve opening files from gui when built without qscintilla (bug #39179) * external-editor-interface.cc/h: new class with an interface for an external editor, which is used by preference or if qscintilla is not available; (external_editor_interface): ctor, connect a signal for opening the settings; (external_editor): check for an external editor being set in the settings; (call_custom_editor): call the custom editor; (request_open_file, request_open_file, handle_edit_file_request): slots for the various ways for opening a file * file-editor-interface.h: moved request_new_function and removed request_open_file into the main window * file-editor.cc: include external-editor-interface.h; (file_editor): file encoding tracked in main window; (request_new_function): moved into main window; (request_open_file (void)): moved to main window; (request_open_files): moved to main window; (handle_combo_enc_current_index): moved to main window; (restore_create_file_setting): moved into main window; (request_new_script): moved into main window; (restore_create_file_setting): moved into main window; (call_custom_editor): use external_editor_interface; (handle_edit_mfile_request): moved into main window; (construct): moved some signal connection into the main window; (add_file_editor_tab): update signal connection to moved slots; * file-editor.h: moved request_new_function, handle_edit_mfile_request, request_open_file (void), request_open_files, handle_combo_enc_current_index, and class variable _file_encodinginto the main window; * main-window.cc (main_window): initialize _file_encoding to empty string, set external editor interface and store active editor for connecting signals; (~main_window): delete external_editor_interface; (edit_mfile): directly use slot handle_edit_mfile_request moved here; (handle_edit_mfile_request): moved from editor to here; (request_new_function): moved from editor to here; (request_open_file): moved from file editor to here; (set_file_encoding): moved from file editor to here, old name was handle_combo_enc_current_index; (request_open_files): moved from file editor to here; (restore_create_file_setting): moved from editor to here; (construct_octave_qt_link): connect signals to slots in editor or external editor interface; (construct_file_menu): connect signals to slots in editor or external editor interface, slot for opening files now in main window (construct_new_menu): connect signals to slots in editor, external editor interface, or to slots moved here; * main-window.h: update signals according to moved slots, namely request_new_function, request_new_script, handle_edit_mfile_request, restore_create_file_setting, moved request_open_file, set_file_encoding, request_open_files, and class variable _file_encoding to here * module.mk: added new files external-editor-interface.cc/h
author Torsten <mttl@mailbox.org>
date Tue, 11 Apr 2017 08:00:23 +0200
parents c319e6d737f2
children 374465c2f3aa
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
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23160
diff changeset
3 Copyright (C) 2013-2017 John W. Eaton
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22254
diff changeset
4 Copyright (C) 2011-2016 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
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
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
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22599
diff changeset
10 the Free Software Foundation; either version 3 of the License, or
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
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
20 <http://www.gnu.org/licenses/>.
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>
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
30 #include <QInputDialog>
15257
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15204
diff changeset
31 #include <QLabel>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
32 #include <QMenuBar>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
33 #include <QMenu>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
34 #include <QAction>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
35 #include <QSettings>
14670
7fbea449737d Restructured menus, added toolbar and current directory line edit.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14669
diff changeset
36 #include <QStyle>
7fbea449737d Restructured menus, added toolbar and current directory line edit.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14669
diff changeset
37 #include <QToolBar>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
38 #include <QDesktopServices>
16391
a695ee2dc17e * main-window.cc: Include <QDesktopWidget>
John W. Eaton <jwe@octave.org>
parents: 16386
diff changeset
39 #include <QDesktopWidget>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
40 #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
41 #include <QMessageBox>
14670
7fbea449737d Restructured menus, added toolbar and current directory line edit.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14669
diff changeset
42 #include <QIcon>
17764
811b5a562680 Format release notes as preformatted text in the GUI (bug #40367)
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
43 #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
44 #include <QThread>
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
45 #include <QDateTime>
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
46 #include <QDebug>
21439
912b8828193b * main-window.cc: include QTimer header file
Mike Miller <mtmiller@octave.org>
parents: 21428
diff changeset
47 #include <QTimer>
14670
7fbea449737d Restructured menus, added toolbar and current directory line edit.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14669
diff changeset
48
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
49 #include <utility>
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
50
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
51 #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
52 # 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
53 #endif
14707
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
54 #include "main-window.h"
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
55 #include "settings-dialog.h"
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
56 #include "shortcut-manager.h"
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
57
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
58 #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
59 #include "cmd-edit.h"
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
60 #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
61
19893
67cb2f421255 restore include statement removed in changeset c7c50030e76c
John W. Eaton <jwe@octave.org>
parents: 19882
diff changeset
62 #include "builtin-defun-decls.h"
15404
f52a62a6db3a eliminate copy and paste copyright info in GUI about info box
John W. Eaton <jwe@octave.org>
parents: 15402
diff changeset
63 #include "defaults.h"
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
64 #include "octave.h"
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
65 #include "symtab.h"
15404
f52a62a6db3a eliminate copy and paste copyright info in GUI about info box
John W. Eaton <jwe@octave.org>
parents: 15402
diff changeset
66 #include "version.h"
18318
770c525a1a2b Warn when saving/running a script whose name is not a valid identifier.
Julien Bect <julien.bect@supelec.fr>
parents: 18309
diff changeset
67 #include "utils.h"
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
68 #include <oct-map.h>
23380
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
69
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
70 static file_editor_interface *
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
71 create_default_editor (QWidget *p)
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
72 {
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
73 #if defined (HAVE_QSCINTILLA)
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
74 return new file_editor (p);
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
75 #else
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
76 octave_unused_parameter (p);
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
77
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
78 return 0;
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
79 #endif
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
80 }
16457
10edb6f1ae98 improve encapsulation of file editor window object
John W. Eaton <jwe@octave.org>
parents: 16456
diff changeset
81
23119
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
82 octave_interpreter::octave_interpreter (octave::application *app_context)
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
83 : QObject (), thread_manager (), m_app_context (app_context)
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
84 { }
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
85
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
86 void
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
87 octave_interpreter::execute (void)
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
88 {
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
89 thread_manager.register_current_thread ();
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
90
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
91 octave_thread_manager::unblock_interrupt_signal ();
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
92
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
93 // The application context owns the interpreter.
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
94
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
95 m_app_context->create_interpreter ();
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
96
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
97 int exit_status = 0;
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
98
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
99 try
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
100 {
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
101 // Final initialization including executing startup files. If
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
102 // initialization fails, return the last available status from
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
103 // that process.
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
104
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
105 exit_status = m_app_context->initialize_interpreter ();
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
106
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
107 if (m_app_context->interpreter_initialized ())
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
108 {
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
109 // The interpreter should be completely ready at this point so let
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
110 // the GUI know.
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
111
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
112 emit octave_ready_signal ();
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
113
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
114 // Start executing commands in the command window.
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
115
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
116 exit_status = m_app_context->execute_interpreter ();
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
117 }
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
118 }
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
119 catch (const octave::exit_exception& ex)
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
120 {
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
121 exit_status = ex.exit_status ();
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
122 }
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
123
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
124 // Whether or not initialization succeeds we need to clean up the
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
125 // interpreter once we are done with it.
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
126
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
127 m_app_context->delete_interpreter ();
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
128
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
129 qApp->exit (exit_status);
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
130 }
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
131
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
132 void
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
133 octave_interpreter::interrupt (void)
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
134 {
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
135 thread_manager.interrupt ();
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
136 }
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
137
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
138
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
139 main_window::main_window (QWidget *p, octave::gui_application *app_context)
23119
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
140 : QMainWindow (p), m_app_context (app_context),
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
141 m_interpreter (new octave_interpreter (app_context)),
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
142 m_main_thread (new QThread ()), _workspace_model (0), status_bar (0),
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
143 command_window (0), history_window (0), file_browser_window (0),
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
144 doc_browser_window (0), editor_window (0), workspace_window (0),
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
145 _settings_dlg (0), find_files_dlg (0), release_notes_window (0),
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
146 community_news_window (0), _octave_qt_link (0),
17329
352b442a72a5 queue and synchronize mutliple commands executed fro history (bug #39723)
Torsten <ttl@justmail.de>
parents: 17117
diff changeset
147 _clipboard (QApplication::clipboard ()),
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
148 _prevent_readline_conflicts (true),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
149 _suppress_dbg_location (true),
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
150 _start_gui (app_context && app_context->start_gui_p ()),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
151 _file_encoding (QString ())
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
152 {
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
153 if (_start_gui)
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
154 {
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
155 _workspace_model = new workspace_model ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
156 status_bar = new QStatusBar ();
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
157 command_window = new terminal_dock_widget (this);
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
158 history_window = new history_dock_widget (this);
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
159 file_browser_window = new files_dock_widget (this);
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
160 doc_browser_window = new documentation_dock_widget (this);
23380
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
161 editor_window = create_default_editor (this);
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
162 workspace_window = new workspace_view (this);
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
163 }
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
164
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
165 _external_editor = new external_editor_interface (this);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
166 _active_editor = editor_window; // for connecting signals
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
167 if (! editor_window)
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
168 _active_editor = _external_editor;
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
169
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
170 QSettings *settings = resource_manager::get_settings ();
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
171
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
172 bool connect_to_web = true;
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
173 QDateTime last_checked;
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
174 int serial = 0;
19422
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
175 _active_dock = 0;
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
176
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
177 if (settings)
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
178 {
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
179 connect_to_web
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
180 = settings->value ("news/allow_web_connection", true).toBool ();
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
181
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
182 last_checked
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
183 = settings->value ("news/last_time_checked", QDateTime ()).toDateTime ();
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
184
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
185 serial = settings->value ("news/last_news_item", 0).toInt ();
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
186 }
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
187
17982
7c48493d98e1 Use currentDateTime instead of currentDateTimeUtc for Qt compatibility
Mike Miller <mtmiller@ieee.org>
parents: 17954
diff changeset
188 QDateTime current = QDateTime::currentDateTime ();
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
189 QDateTime one_day_ago = current.addDays (-1);
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
190
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
191 if (_start_gui && connect_to_web
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
192 && (! last_checked.isValid () || one_day_ago > last_checked))
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
193 load_and_display_community_news (serial);
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
194
14599
97cb9286919c Cleaned up code.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14588
diff changeset
195 // We have to set up all our windows, before we finally launch octave.
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
196 construct ();
23119
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
197
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
198 connect (m_interpreter, SIGNAL (octave_ready_signal ()),
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
199 this, SLOT (handle_octave_ready ()));
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
200
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
201 m_interpreter->moveToThread (m_main_thread);
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
202
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
203 m_main_thread->start ();
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
204 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
205
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
206 main_window::~main_window (void)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
207 {
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16484
diff changeset
208 // Destroy the terminal first so that STDERR stream is redirected back
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16484
diff changeset
209 // to its original pipe to capture error messages at exit.
16484
fa842e78f491 Restore STDERR stream pipe before exit to capture error messages.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16479
diff changeset
210
16638
3c2e457eeb72 ask for saving modified editor files if octave is closed (bug #38689)
Torsten <ttl@justmail.de>
parents: 16635
diff changeset
211 delete editor_window; // first one for dialogs of modified editor-tabs
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
212 delete _external_editor;
16484
fa842e78f491 Restore STDERR stream pipe before exit to capture error messages.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16479
diff changeset
213 delete command_window;
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16484
diff changeset
214 delete workspace_window;
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16484
diff changeset
215 delete doc_browser_window;
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16484
diff changeset
216 delete file_browser_window;
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16484
diff changeset
217 delete history_window;
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16484
diff changeset
218 delete status_bar;
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16484
diff changeset
219 delete _workspace_model;
23119
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
220 delete m_interpreter;
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
221 delete m_main_thread;
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
222 if (find_files_dlg)
16519
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
223 {
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
224 delete find_files_dlg;
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
225 find_files_dlg = 0;
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
226 }
17883
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
227 if (release_notes_window)
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
228 {
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
229 delete release_notes_window;
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
230 release_notes_window = 0;
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
231 }
19632
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
232 if (_settings_dlg)
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
233 {
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
234 delete _settings_dlg;
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
235 _settings_dlg = 0;
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
236 }
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
237 if (community_news_window)
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
238 {
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
239 delete community_news_window;
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
240 community_news_window = 0;
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
241 }
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
242 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
243
19422
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
244 // catch focus changes and determine the active dock widget
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
245 void
19425
5e93d228ff6b fix regression from 476032040df9 (endless loop while looking for active widget)
Torsten <ttl@justmail.de>
parents: 19422
diff changeset
246 main_window::focus_changed (QWidget *, QWidget *new_widget)
19422
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
247 {
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
248 octave_dock_widget* dock = 0;
19425
5e93d228ff6b fix regression from 476032040df9 (endless loop while looking for active widget)
Torsten <ttl@justmail.de>
parents: 19422
diff changeset
249 QWidget *w_new = new_widget; // get a copy of new focus widget
5e93d228ff6b fix regression from 476032040df9 (endless loop while looking for active widget)
Torsten <ttl@justmail.de>
parents: 19422
diff changeset
250 QWidget *start = w_new; // Save it as start of our search
5e93d228ff6b fix regression from 476032040df9 (endless loop while looking for active widget)
Torsten <ttl@justmail.de>
parents: 19422
diff changeset
251 int count = 0; // fallback to prevent endless loop
5e93d228ff6b fix regression from 476032040df9 (endless loop while looking for active widget)
Torsten <ttl@justmail.de>
parents: 19422
diff changeset
252
5e93d228ff6b fix regression from 476032040df9 (endless loop while looking for active widget)
Torsten <ttl@justmail.de>
parents: 19422
diff changeset
253 while (w_new && w_new != _main_tool_bar && count < 100)
19422
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
254 {
21661
1b9a36a66b01 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21568
diff changeset
255 dock = qobject_cast<octave_dock_widget *> (w_new);
19422
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
256 if (dock)
19425
5e93d228ff6b fix regression from 476032040df9 (endless loop while looking for active widget)
Torsten <ttl@justmail.de>
parents: 19422
diff changeset
257 break; // it is a QDockWidget ==> exit loop
5e93d228ff6b fix regression from 476032040df9 (endless loop while looking for active widget)
Torsten <ttl@justmail.de>
parents: 19422
diff changeset
258
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
259 #if defined (HAVE_QSCINTILLA)
21661
1b9a36a66b01 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21568
diff changeset
260 if (qobject_cast<octave_qscintilla *> (w_new))
19533
52c51472b6b9 improved search for active dock-widget after focus has changed
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
261 {
19739
3fa35defe495 Adjust spacing of static_cast<> calls to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19714
diff changeset
262 dock = static_cast<octave_dock_widget *> (editor_window);
19533
52c51472b6b9 improved search for active dock-widget after focus has changed
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
263 break; // it is the editor window ==> exit loop
52c51472b6b9 improved search for active dock-widget after focus has changed
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
264 }
19589
4fe86a372f10 Fix compilation error when building without QScintilla
Mike Miller <mtmiller@ieee.org>
parents: 19585
diff changeset
265 #endif
19533
52c51472b6b9 improved search for active dock-widget after focus has changed
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
266
21661
1b9a36a66b01 maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents: 21568
diff changeset
267 w_new = qobject_cast<QWidget *> (w_new->previousInFocusChain ());
19425
5e93d228ff6b fix regression from 476032040df9 (endless loop while looking for active widget)
Torsten <ttl@justmail.de>
parents: 19422
diff changeset
268 if (w_new == start)
5e93d228ff6b fix regression from 476032040df9 (endless loop while looking for active widget)
Torsten <ttl@justmail.de>
parents: 19422
diff changeset
269 break; // we have arrived where we began ==> exit loop
5e93d228ff6b fix regression from 476032040df9 (endless loop while looking for active widget)
Torsten <ttl@justmail.de>
parents: 19422
diff changeset
270
5e93d228ff6b fix regression from 476032040df9 (endless loop while looking for active widget)
Torsten <ttl@justmail.de>
parents: 19422
diff changeset
271 count++;
19422
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
272 }
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
273
19533
52c51472b6b9 improved search for active dock-widget after focus has changed
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
274 // editor needs extra handling
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
275 octave_dock_widget *edit_dock_widget
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
276 = static_cast<octave_dock_widget *> (editor_window);
19422
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
277 // if new dock has focus, emit signal and store active focus
19533
52c51472b6b9 improved search for active dock-widget after focus has changed
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
278 // except editor changes to a dialog (dock=0)
52c51472b6b9 improved search for active dock-widget after focus has changed
Torsten <ttl@justmail.de>
parents: 19437
diff changeset
279 if ((dock || _active_dock != edit_dock_widget) && (dock != _active_dock))
19422
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
280 {
19426
f90bb1e30de2 switching between edit and main shortcuts depending on active dock widget now
Torsten <ttl@justmail.de>
parents: 19425
diff changeset
281 // signal to all dock widgets for updating the style
19422
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
282 emit active_dock_changed (_active_dock, dock);
19426
f90bb1e30de2 switching between edit and main shortcuts depending on active dock widget now
Torsten <ttl@justmail.de>
parents: 19425
diff changeset
283
19983
643de08e524c save and restore previously active widget in a tabbed stack (bug #42980)
Torsten <ttl@justmail.de>
parents: 19970
diff changeset
284 QList<QDockWidget *> tabbed = tabifiedDockWidgets (dock);
643de08e524c save and restore previously active widget in a tabbed stack (bug #42980)
Torsten <ttl@justmail.de>
parents: 19970
diff changeset
285 if (tabbed.contains (_active_dock))
643de08e524c save and restore previously active widget in a tabbed stack (bug #42980)
Torsten <ttl@justmail.de>
parents: 19970
diff changeset
286 dock->set_predecessor_widget (_active_dock);
643de08e524c save and restore previously active widget in a tabbed stack (bug #42980)
Torsten <ttl@justmail.de>
parents: 19970
diff changeset
287
19426
f90bb1e30de2 switching between edit and main shortcuts depending on active dock widget now
Torsten <ttl@justmail.de>
parents: 19425
diff changeset
288 if (edit_dock_widget == dock)
19429
be53bf420464 fix access to already removed editor window at exit
Torsten <ttl@justmail.de>
parents: 19426
diff changeset
289 emit editor_focus_changed (true);
19426
f90bb1e30de2 switching between edit and main shortcuts depending on active dock widget now
Torsten <ttl@justmail.de>
parents: 19425
diff changeset
290 else if (edit_dock_widget == _active_dock)
19429
be53bf420464 fix access to already removed editor window at exit
Torsten <ttl@justmail.de>
parents: 19426
diff changeset
291 emit editor_focus_changed (false);
19426
f90bb1e30de2 switching between edit and main shortcuts depending on active dock widget now
Torsten <ttl@justmail.de>
parents: 19425
diff changeset
292
19422
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
293 _active_dock = dock;
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
294 }
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
295 }
476032040df9 determining the active dock from focus changes in the gui
Torsten <ttl@justmail.de>
parents: 19411
diff changeset
296
16576
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
297 bool
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
298 main_window::command_window_has_focus (void) const
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
299 {
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
300 return command_window->has_focus ();
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
301 }
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
302
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
303 void
16449
c129a8b73d25 avoid unneeded signals for window focus
John W. Eaton <jwe@octave.org>
parents: 16448
diff changeset
304 main_window::focus_command_window (void)
c129a8b73d25 avoid unneeded signals for window focus
John W. Eaton <jwe@octave.org>
parents: 16448
diff changeset
305 {
16451
d4c3736e1e28 dynamically allocate Qt widgets
John W. Eaton <jwe@octave.org>
parents: 16450
diff changeset
306 command_window->focus ();
16449
c129a8b73d25 avoid unneeded signals for window focus
John W. Eaton <jwe@octave.org>
parents: 16448
diff changeset
307 }
c129a8b73d25 avoid unneeded signals for window focus
John W. Eaton <jwe@octave.org>
parents: 16448
diff changeset
308
c129a8b73d25 avoid unneeded signals for window focus
John W. Eaton <jwe@octave.org>
parents: 16448
diff changeset
309 void
16452
744ff2fe11ce add create script context menu to history window
John Donoghue <john.donoghue@ieee.org>
parents: 16451
diff changeset
310 main_window::new_file (const QString& commands)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
311 {
16457
10edb6f1ae98 improve encapsulation of file editor window object
John W. Eaton <jwe@octave.org>
parents: 16456
diff changeset
312 emit new_file_signal (commands);
14875
3fd857c284fe Editor now gets focussed when opening a file.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14831
diff changeset
313 }
3fd857c284fe Editor now gets focussed when opening a file.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14831
diff changeset
314
3fd857c284fe Editor now gets focussed when opening a file.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14831
diff changeset
315 void
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15286
diff changeset
316 main_window::open_file (const QString& file_name)
14875
3fd857c284fe Editor now gets focussed when opening a file.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14831
diff changeset
317 {
16457
10edb6f1ae98 improve encapsulation of file editor window object
John W. Eaton <jwe@octave.org>
parents: 16456
diff changeset
318 emit open_file_signal (file_name);
13558
248b897d9f36 editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents: 13550
diff changeset
319 }
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
320
20995
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20989
diff changeset
321 void
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20989
diff changeset
322 main_window::edit_mfile (const QString& name, int line)
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20989
diff changeset
323 {
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
324 handle_edit_mfile_request (name, QString (), QString (), line);
20995
aab7a3c7168e edit a file from an error message in the terminal (bug #35619)
Torsten <ttl@justmail.de>
parents: 20989
diff changeset
325 }
13558
248b897d9f36 editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents: 13550
diff changeset
326
248b897d9f36 editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents: 13550
diff changeset
327 void
15300
fd27e10b9b05 pass QString by const reference instead of value
John W. Eaton <jwe@octave.org>
parents: 15286
diff changeset
328 main_window::report_status_message (const QString& statusMessage)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
329 {
16451
d4c3736e1e28 dynamically allocate Qt widgets
John W. Eaton <jwe@octave.org>
parents: 16450
diff changeset
330 status_bar->showMessage (statusMessage, 1000);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
331 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
332
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
333 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
334 main_window::handle_save_workspace_request (void)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
335 {
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
336 QString file
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
337 = QFileDialog::getSaveFileName (this, tr ("Save Workspace As"), ".", 0, 0,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
338 QFileDialog::DontUseNativeDialog);
16532
67d4111d078d look for save/load files starting in current directory
John W. Eaton <jwe@octave.org>
parents: 16526
diff changeset
339
67d4111d078d look for save/load files starting in current directory
John W. Eaton <jwe@octave.org>
parents: 16526
diff changeset
340 if (! file.isEmpty ())
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
341 octave_link::post_event (this, &main_window::save_workspace_callback,
16532
67d4111d078d look for save/load files starting in current directory
John W. Eaton <jwe@octave.org>
parents: 16526
diff changeset
342 file.toStdString ());
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
343 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
344
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
345 void
16504
49b059bf27c7 allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
346 main_window::handle_load_workspace_request (const QString& file_arg)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
347 {
16504
49b059bf27c7 allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
348 QString file = file_arg;
49b059bf27c7 allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
349
49b059bf27c7 allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
350 if (file.isEmpty ())
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
351 file = QFileDialog::getOpenFileName (this, tr ("Load Workspace"), ".", 0, 0,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
352 QFileDialog::DontUseNativeDialog);
16532
67d4111d078d look for save/load files starting in current directory
John W. Eaton <jwe@octave.org>
parents: 16526
diff changeset
353
16504
49b059bf27c7 allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
354 if (! file.isEmpty ())
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
355 octave_link::post_event (this, &main_window::load_workspace_callback,
16504
49b059bf27c7 allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
356 file.toStdString ());
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
357 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
358
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
359 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
360 main_window::handle_clear_workspace_request (void)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
361 {
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
362 octave_link::post_event (this, &main_window::clear_workspace_callback);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
363 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
364
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
365 void
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
366 main_window::handle_rename_variable_request (const QString& old_name,
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
367 const QString& new_name)
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
368
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
369 {
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
370 name_pair names (old_name.toStdString (), new_name.toStdString ());
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
371
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
372 octave_link::post_event (this, &main_window::rename_variable_callback,
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
373 names);
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
374 }
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
375
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
376 void
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
377 main_window::handle_undo_request (void)
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
378 {
19945
f7a805f02723 link undo in main window to editor if the latter has focus (bug #44402)
Torsten <ttl@justmail.de>
parents: 19938
diff changeset
379 if (command_window_has_focus ())
f7a805f02723 link undo in main window to editor if the latter has focus (bug #44402)
Torsten <ttl@justmail.de>
parents: 19938
diff changeset
380 octave_link::post_event (this, &main_window::command_window_undo_callback);
f7a805f02723 link undo in main window to editor if the latter has focus (bug #44402)
Torsten <ttl@justmail.de>
parents: 19938
diff changeset
381 else
f7a805f02723 link undo in main window to editor if the latter has focus (bug #44402)
Torsten <ttl@justmail.de>
parents: 19938
diff changeset
382 emit undo_signal ();
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
383 }
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
384
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
385 void
16514
db045633405c Added clear command window implementation to MainWindow Clear COmmand Window menu.
John Donoghue <john.donoghue@ieee.org>
parents: 16512
diff changeset
386 main_window::handle_clear_command_window_request (void)
db045633405c Added clear command window implementation to MainWindow Clear COmmand Window menu.
John Donoghue <john.donoghue@ieee.org>
parents: 16512
diff changeset
387 {
db045633405c Added clear command window implementation to MainWindow Clear COmmand Window menu.
John Donoghue <john.donoghue@ieee.org>
parents: 16512
diff changeset
388 octave_link::post_event (this, &main_window::clear_command_window_callback);
db045633405c Added clear command window implementation to MainWindow Clear COmmand Window menu.
John Donoghue <john.donoghue@ieee.org>
parents: 16512
diff changeset
389 }
db045633405c Added clear command window implementation to MainWindow Clear COmmand Window menu.
John Donoghue <john.donoghue@ieee.org>
parents: 16512
diff changeset
390
db045633405c Added clear command window implementation to MainWindow Clear COmmand Window menu.
John Donoghue <john.donoghue@ieee.org>
parents: 16512
diff changeset
391 void
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
392 main_window::handle_clear_history_request (void)
14814
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14813
diff changeset
393 {
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
394 octave_link::post_event (this, &main_window::clear_history_callback);
14814
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14813
diff changeset
395 }
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14813
diff changeset
396
18156
14acb08d75fa gui: optionally set focus to console when a command is run from another widget
Torsten <ttl@justmail.de>
parents: 18117
diff changeset
397 bool
14acb08d75fa gui: optionally set focus to console when a command is run from another widget
Torsten <ttl@justmail.de>
parents: 18117
diff changeset
398 main_window::focus_console_after_command ()
14acb08d75fa gui: optionally set focus to console when a command is run from another widget
Torsten <ttl@justmail.de>
parents: 18117
diff changeset
399 {
14acb08d75fa gui: optionally set focus to console when a command is run from another widget
Torsten <ttl@justmail.de>
parents: 18117
diff changeset
400 QSettings *settings = resource_manager::get_settings ();
14acb08d75fa gui: optionally set focus to console when a command is run from another widget
Torsten <ttl@justmail.de>
parents: 18117
diff changeset
401 return settings->value ("terminal/focus_after_command",false).toBool ();
14acb08d75fa gui: optionally set focus to console when a command is run from another widget
Torsten <ttl@justmail.de>
parents: 18117
diff changeset
402 }
14acb08d75fa gui: optionally set focus to console when a command is run from another widget
Torsten <ttl@justmail.de>
parents: 18117
diff changeset
403
14814
61c80e9326a8 Clearing the command history works.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14813
diff changeset
404 void
16570
d5ae5aa80d42 preserve pending command line input when running commands from GUI actions
John W. Eaton <jwe@octave.org>
parents: 16566
diff changeset
405 main_window::execute_command_in_terminal (const QString& command)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
406 {
19773
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents: 19739
diff changeset
407 octave_cmd_exec *cmd = new octave_cmd_exec (command);
21028
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
408 _cmd_queue.add_cmd (cmd);
18156
14acb08d75fa gui: optionally set focus to console when a command is run from another widget
Torsten <ttl@justmail.de>
parents: 18117
diff changeset
409 if (focus_console_after_command ())
14acb08d75fa gui: optionally set focus to console when a command is run from another widget
Torsten <ttl@justmail.de>
parents: 18117
diff changeset
410 focus_command_window ();
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
411 }
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
412
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
413 void
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16593
diff changeset
414 main_window::run_file_in_terminal (const QFileInfo& info)
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16593
diff changeset
415 {
17331
636d75a58cd9 fix running file from editor that is not in the search path (bug #39870)
Torsten <ttl@justmail.de>
parents: 17329
diff changeset
416 octave_link::post_event (this, &main_window::run_file_callback, info);
18156
14acb08d75fa gui: optionally set focus to console when a command is run from another widget
Torsten <ttl@justmail.de>
parents: 18117
diff changeset
417 if (focus_console_after_command ())
14acb08d75fa gui: optionally set focus to console when a command is run from another widget
Torsten <ttl@justmail.de>
parents: 18117
diff changeset
418 focus_command_window ();
17331
636d75a58cd9 fix running file from editor that is not in the search path (bug #39870)
Torsten <ttl@justmail.de>
parents: 17329
diff changeset
419 }
636d75a58cd9 fix running file from editor that is not in the search path (bug #39870)
Torsten <ttl@justmail.de>
parents: 17329
diff changeset
420
636d75a58cd9 fix running file from editor that is not in the search path (bug #39870)
Torsten <ttl@justmail.de>
parents: 17329
diff changeset
421 void
636d75a58cd9 fix running file from editor that is not in the search path (bug #39870)
Torsten <ttl@justmail.de>
parents: 17329
diff changeset
422 main_window::run_file_callback (const QFileInfo& info)
636d75a58cd9 fix running file from editor that is not in the search path (bug #39870)
Torsten <ttl@justmail.de>
parents: 17329
diff changeset
423 {
19773
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents: 19739
diff changeset
424 octave_cmd_eval *cmd = new octave_cmd_eval (info);
21028
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
425 _cmd_queue.add_cmd (cmd);
16635
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16593
diff changeset
426 }
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16593
diff changeset
427
25e418d23a4b fix running files from file browser's context menu
Torsten <ttl@justmail.de>
parents: 16593
diff changeset
428 void
16566
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
429 main_window::handle_new_figure_request (void)
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
430 {
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
431 octave_link::post_event (this, &main_window::new_figure_callback);
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
432 }
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
433
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
434 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
435 main_window::open_online_documentation_page (void)
15989
afc4e08f2143 Add access to documentation and to online html page via Help menu
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15987
diff changeset
436 {
21669
7cb63f3994b0 Use correct URL for Online Documentation (bug #47835).
Rik <rik@octave.org>
parents: 20243
diff changeset
437 QDesktopServices::openUrl (
7cb63f3994b0 Use correct URL for Online Documentation (bug #47835).
Rik <rik@octave.org>
parents: 20243
diff changeset
438 QUrl ("http://octave.org/doc/interpreter/index.html"));
15989
afc4e08f2143 Add access to documentation and to online html page via Help menu
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15987
diff changeset
439 }
afc4e08f2143 Add access to documentation and to online html page via Help menu
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15987
diff changeset
440
afc4e08f2143 Add access to documentation and to online html page via Help menu
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15987
diff changeset
441 void
17599
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
442 main_window::display_release_notes (void)
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
443 {
17883
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
444 if (! release_notes_window)
17764
811b5a562680 Format release notes as preformatted text in the GUI (bug #40367)
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
445 {
17883
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
446 std::string news_file = Voct_etc_dir + "/NEWS";
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
447
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
448 QString news;
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
449
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
450 QFile *file = new QFile (QString::fromStdString (news_file));
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
451 if (file->open (QFile::ReadOnly))
17764
811b5a562680 Format release notes as preformatted text in the GUI (bug #40367)
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
452 {
17883
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
453 QTextStream *stream = new QTextStream (file);
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
454 news = stream->readAll ();
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
455 if (! news.isEmpty ())
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
456 {
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
457 news.prepend ("<pre>");
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
458 news.append ("</pre>");
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
459 }
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
460 else
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
461 news = (tr ("The release notes file '%1' is empty.")
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
462 . arg (QString::fromStdString (news_file)));
17764
811b5a562680 Format release notes as preformatted text in the GUI (bug #40367)
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
463 }
811b5a562680 Format release notes as preformatted text in the GUI (bug #40367)
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
464 else
17883
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
465 news = (tr ("The release notes file '%1' cannot be read.")
17771
7690c3477da1 if NEWS file is missing, include expected file name in release notes message
John W. Eaton <jwe@octave.org>
parents: 17764
diff changeset
466 . arg (QString::fromStdString (news_file)));
17599
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
467
17883
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
468 release_notes_window = new QWidget;
17599
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
469
17883
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
470 QTextBrowser *browser = new QTextBrowser (release_notes_window);
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
471 browser->setText (news);
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
472
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
473 QVBoxLayout *vlayout = new QVBoxLayout;
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
474 vlayout->addWidget (browser);
17599
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
475
17883
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
476 release_notes_window->setLayout (vlayout);
17936
8c23f844bd30 set maximum size for release notes window from screen size
John W. Eaton <jwe@octave.org>
parents: 17935
diff changeset
477 release_notes_window->setWindowTitle (tr ("Octave Release Notes"));
8c23f844bd30 set maximum size for release notes window from screen size
John W. Eaton <jwe@octave.org>
parents: 17935
diff changeset
478
23070
bef714f45999 maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents: 22755
diff changeset
479 browser->document ()->adjustSize ();
18840
e7b5be5a7f80 improve size of the release notes window
Torsten <ttl@justmail.de>
parents: 18839
diff changeset
480
e7b5be5a7f80 improve size of the release notes window
Torsten <ttl@justmail.de>
parents: 18839
diff changeset
481 // center the window on the screen where octave is running
e7b5be5a7f80 improve size of the release notes window
Torsten <ttl@justmail.de>
parents: 18839
diff changeset
482 QDesktopWidget *m_desktop = QApplication::desktop ();
e7b5be5a7f80 improve size of the release notes window
Torsten <ttl@justmail.de>
parents: 18839
diff changeset
483 int screen = m_desktop->screenNumber (this); // screen of the main window
e7b5be5a7f80 improve size of the release notes window
Torsten <ttl@justmail.de>
parents: 18839
diff changeset
484 QRect screen_geo = m_desktop->availableGeometry (screen);
e7b5be5a7f80 improve size of the release notes window
Torsten <ttl@justmail.de>
parents: 18839
diff changeset
485 int win_x = screen_geo.width (); // width of the screen
e7b5be5a7f80 improve size of the release notes window
Torsten <ttl@justmail.de>
parents: 18839
diff changeset
486 int win_y = screen_geo.height (); // height of the screen
21396
309bba07a4f6 Change size of Release Notes window so it displays without hz scrollbar.
Rik <rik@octave.org>
parents: 21310
diff changeset
487 int reln_x = std::min (720, win_x-80); // desired width of release notes
309bba07a4f6 Change size of Release Notes window so it displays without hz scrollbar.
Rik <rik@octave.org>
parents: 21310
diff changeset
488 int reln_y = std::min (740, win_y-80); // desired height of release notes
18840
e7b5be5a7f80 improve size of the release notes window
Torsten <ttl@justmail.de>
parents: 18839
diff changeset
489 release_notes_window->resize (reln_x, reln_y); // set size
e7b5be5a7f80 improve size of the release notes window
Torsten <ttl@justmail.de>
parents: 18839
diff changeset
490 release_notes_window->move (20, 0); // move to the top left corner
17883
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
491 }
17599
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
492
17883
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
493 if (! release_notes_window->isVisible ())
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
494 release_notes_window->show ();
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
495 else if (release_notes_window->isMinimized ())
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
496 release_notes_window->showNormal ();
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
497
18002
67978cb5d269 fix icons for the release and community windows
Torsten <ttl@justmail.de>
parents: 18001
diff changeset
498 release_notes_window->setWindowIcon (QIcon (_release_notes_icon));
67978cb5d269 fix icons for the release and community windows
Torsten <ttl@justmail.de>
parents: 18001
diff changeset
499
17883
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
500 release_notes_window->raise ();
3851e5fde76d GUI: allow only one release notes windows to be open
John Donoghue <john.donoghue@ieee.org>
parents: 17824
diff changeset
501 release_notes_window->activateWindow ();
17599
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
502 }
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
503
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
504 void
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
505 news_reader::process (void)
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
506 {
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
507 QString html_text;
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
508
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
509 if (connect_to_web)
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
510 {
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
511 // Run this part in a separate thread so Octave can continue to
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
512 // run while we wait for the page to load. Then emit the signal
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
513 // to display it when we have the page contents.
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
514
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
515 QString url = base_url + "/" + page;
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
516 std::ostringstream buf;
21744
e1be0b36fbed use namespace for url_transfer class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
517 octave::url_transfer octave_dot_org (url.toStdString (), buf);
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
518
18287
9a43d8d6e29e avoid startup crash if curl library is not available (bug #41067)
John W. Eaton <jwe@octave.org>
parents: 18261
diff changeset
519 if (octave_dot_org.is_valid ())
9a43d8d6e29e avoid startup crash if curl library is not available (bug #41067)
John W. Eaton <jwe@octave.org>
parents: 18261
diff changeset
520 {
9a43d8d6e29e avoid startup crash if curl library is not available (bug #41067)
John W. Eaton <jwe@octave.org>
parents: 18261
diff changeset
521 Array<std::string> param;
9a43d8d6e29e avoid startup crash if curl library is not available (bug #41067)
John W. Eaton <jwe@octave.org>
parents: 18261
diff changeset
522 octave_dot_org.http_get (param);
9a43d8d6e29e avoid startup crash if curl library is not available (bug #41067)
John W. Eaton <jwe@octave.org>
parents: 18261
diff changeset
523
9a43d8d6e29e avoid startup crash if curl library is not available (bug #41067)
John W. Eaton <jwe@octave.org>
parents: 18261
diff changeset
524 if (octave_dot_org.good ())
9a43d8d6e29e avoid startup crash if curl library is not available (bug #41067)
John W. Eaton <jwe@octave.org>
parents: 18261
diff changeset
525 html_text = QString::fromStdString (buf.str ());
9a43d8d6e29e avoid startup crash if curl library is not available (bug #41067)
John W. Eaton <jwe@octave.org>
parents: 18261
diff changeset
526 }
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
527
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
528 if (html_text.contains ("this-is-the-gnu-octave-community-news-page"))
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
529 {
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
530 if (serial >= 0)
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
531 {
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
532 QSettings *settings = resource_manager::get_settings ();
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
533
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
534 if (settings)
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
535 {
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
536 settings->setValue ("news/last_time_checked",
17982
7c48493d98e1 Use currentDateTime instead of currentDateTimeUtc for Qt compatibility
Mike Miller <mtmiller@ieee.org>
parents: 17954
diff changeset
537 QDateTime::currentDateTime ());
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
538
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
539 settings->sync ();
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
540 }
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
541
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
542 QString tag ("community-news-page-serial=");
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
543
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
544 int b = html_text.indexOf (tag);
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
545
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
546 if (b)
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
547 {
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
548 b += tag.length ();
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
549
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
550 int e = html_text.indexOf ("\n", b);
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
551
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
552 QString tmp = html_text.mid (b, e-b);
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
553
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
554 int curr_page_serial = tmp.toInt ();
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
555
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
556 if (curr_page_serial > serial)
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
557 {
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
558 if (settings)
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
559 {
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
560 settings->setValue ("news/last_news_item",
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
561 curr_page_serial);
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
562
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
563 settings->sync ();
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
564 }
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
565 }
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
566 else
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
567 return;
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
568 }
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
569 else
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
570 return;
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
571 }
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
572 }
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
573 else
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
574 html_text = QString
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
575 (tr ("<html>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
576 "<body>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
577 "<p>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
578 "Octave's community news source seems to be unavailable.\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
579 "</p>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
580 "<p>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
581 "For the latest news, please check\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
582 "<a href=\"http://octave.org/community-news.html\">http://octave.org/community-news.html</a>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
583 "when you have a connection to the web (link opens in an external browser).\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
584 "</p>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
585 "<p>\n"
18251
0b5f669f5b03 fix some translation issues (bug #41159)
Torsten <ttl@justmail.de>
parents: 18250
diff changeset
586 "<small><em>&mdash; The Octave Developers, ") + OCTAVE_RELEASE_DATE + "</em></small>\n"
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
587 "</p>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
588 "</body>\n"
18251
0b5f669f5b03 fix some translation issues (bug #41159)
Torsten <ttl@justmail.de>
parents: 18250
diff changeset
589 "</html>\n");
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
590 }
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
591 else
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
592 html_text = QString
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
593 (tr ("<html>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
594 "<body>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
595 "<p>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
596 "Connecting to the web to display the latest Octave Community news has been disabled.\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
597 "</p>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
598 "<p>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
599 "For the latest news, please check\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
600 "<a href=\"http://octave.org/community-news.html\">http://octave.org/community-news.html</a>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
601 "when you have a connection to the web (link opens in an external browser)\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
602 "or enable web connections for news in Octave's network settings dialog.\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
603 "</p>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
604 "<p>\n"
18251
0b5f669f5b03 fix some translation issues (bug #41159)
Torsten <ttl@justmail.de>
parents: 18250
diff changeset
605 "<small><em>&mdash; The Octave Developers, ") + OCTAVE_RELEASE_DATE + "</em></small>\n"
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
606 "</p>\n"
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
607 "</body>\n"
18251
0b5f669f5b03 fix some translation issues (bug #41159)
Torsten <ttl@justmail.de>
parents: 18250
diff changeset
608 "</html>\n");
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
609
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
610 emit display_news_signal (html_text);
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
611
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
612 emit finished ();
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
613 }
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
614
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
615 void
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
616 main_window::load_and_display_community_news (int serial)
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
617 {
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
618 QSettings *settings = resource_manager::get_settings ();
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
619
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
620 bool connect_to_web
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
621 = (settings
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
622 ? settings->value ("news/allow_web_connection", true).toBool ()
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
623 : true);
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
624
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
625 QString base_url = "http://octave.org";
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
626 QString page = "community-news.html";
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
627
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
628 QThread *worker_thread = new QThread;
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
629
17940
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
630 news_reader *reader = new news_reader (base_url, page, serial,
b3e4ee8f4d6d respect option for opting out of web connections for community news
John W. Eaton <jwe@octave.org>
parents: 17939
diff changeset
631 connect_to_web);
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
632
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
633 reader->moveToThread (worker_thread);
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
634
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
635 connect (reader, SIGNAL (display_news_signal (const QString&)),
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
636 this, SLOT (display_community_news (const QString&)));
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
637
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
638 connect (worker_thread, SIGNAL (started (void)),
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
639 reader, SLOT (process ()));
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
640
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
641 connect (reader, SIGNAL (finished (void)), worker_thread, SLOT (quit ()));
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
642
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
643 connect (reader, SIGNAL (finished (void)), reader, SLOT (deleteLater ()));
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
644
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
645 connect (worker_thread, SIGNAL (finished (void)),
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
646 worker_thread, SLOT (deleteLater ()));
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
647
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
648 worker_thread->start ();
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
649 }
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
650
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
651 void
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
652 main_window::display_community_news (const QString& news)
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
653 {
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
654 if (! community_news_window)
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
655 {
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
656 community_news_window = new QWidget;
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
657
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
658 QTextBrowser *browser = new QTextBrowser (community_news_window);
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
659
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
660 browser->setHtml (news);
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
661 browser->setObjectName ("OctaveNews");
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
662 browser->setOpenExternalLinks (true);
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
663
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
664 QVBoxLayout *vlayout = new QVBoxLayout;
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
665
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
666 vlayout->addWidget (browser);
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
667
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
668 community_news_window->setLayout (vlayout);
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
669 community_news_window->setWindowTitle (tr ("Octave Community News"));
18839
41980d0a5fd2 center the community news window on the screen not on the desktop (bug #42567)
Torsten <ttl@justmail.de>
parents: 18833
diff changeset
670
41980d0a5fd2 center the community news window on the screen not on the desktop (bug #42567)
Torsten <ttl@justmail.de>
parents: 18833
diff changeset
671 // center the window on the screen where octave is running
41980d0a5fd2 center the community news window on the screen not on the desktop (bug #42567)
Torsten <ttl@justmail.de>
parents: 18833
diff changeset
672 QDesktopWidget *m_desktop = QApplication::desktop ();
41980d0a5fd2 center the community news window on the screen not on the desktop (bug #42567)
Torsten <ttl@justmail.de>
parents: 18833
diff changeset
673 int screen = m_desktop->screenNumber (this); // screen of the main window
41980d0a5fd2 center the community news window on the screen not on the desktop (bug #42567)
Torsten <ttl@justmail.de>
parents: 18833
diff changeset
674 QRect screen_geo = m_desktop->availableGeometry (screen);
41980d0a5fd2 center the community news window on the screen not on the desktop (bug #42567)
Torsten <ttl@justmail.de>
parents: 18833
diff changeset
675 int win_x = screen_geo.width (); // width of the screen
41980d0a5fd2 center the community news window on the screen not on the desktop (bug #42567)
Torsten <ttl@justmail.de>
parents: 18833
diff changeset
676 int win_y = screen_geo.height (); // height of the screen
41980d0a5fd2 center the community news window on the screen not on the desktop (bug #42567)
Torsten <ttl@justmail.de>
parents: 18833
diff changeset
677 int news_x = std::min (640, win_x-80); // desired width of news window
41980d0a5fd2 center the community news window on the screen not on the desktop (bug #42567)
Torsten <ttl@justmail.de>
parents: 18833
diff changeset
678 int news_y = std::min (480, win_y-80); // desired height of news window
41980d0a5fd2 center the community news window on the screen not on the desktop (bug #42567)
Torsten <ttl@justmail.de>
parents: 18833
diff changeset
679 community_news_window->resize (news_x, news_y); // set size and center
17948
73f46593a51c Center the Octave Community News window only when constructed (bug #40618)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17947
diff changeset
680 community_news_window->move ((win_x - community_news_window->width ())/2,
73f46593a51c Center the Octave Community News window only when constructed (bug #40618)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 17947
diff changeset
681 (win_y - community_news_window->height ())/2);
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
682 }
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
683
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
684 if (! community_news_window->isVisible ())
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
685 community_news_window->show ();
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
686 else if (community_news_window->isMinimized ())
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
687 community_news_window->showNormal ();
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
688
18002
67978cb5d269 fix icons for the release and community windows
Torsten <ttl@justmail.de>
parents: 18001
diff changeset
689 // same icon as release notes
67978cb5d269 fix icons for the release and community windows
Torsten <ttl@justmail.de>
parents: 18001
diff changeset
690 community_news_window->setWindowIcon (QIcon (_release_notes_icon));
67978cb5d269 fix icons for the release and community windows
Torsten <ttl@justmail.de>
parents: 18001
diff changeset
691
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
692 community_news_window->raise ();
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
693 community_news_window->activateWindow ();
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
694 }
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
695
17599
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
696 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
697 main_window::open_bug_tracker_page (void)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
698 {
17509
d0fa3568eb5d update links in Help menu
John W. Eaton <jwe@octave.org>
parents: 17331
diff changeset
699 QDesktopServices::openUrl (QUrl ("http://octave.org/bugs.html"));
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
700 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
701
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
702 void
17509
d0fa3568eb5d update links in Help menu
John W. Eaton <jwe@octave.org>
parents: 17331
diff changeset
703 main_window::open_octave_packages_page (void)
15989
afc4e08f2143 Add access to documentation and to online html page via Help menu
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15987
diff changeset
704 {
17509
d0fa3568eb5d update links in Help menu
John W. Eaton <jwe@octave.org>
parents: 17331
diff changeset
705 QDesktopServices::openUrl (QUrl ("http://octave.org/packages.html"));
15989
afc4e08f2143 Add access to documentation and to online html page via Help menu
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15987
diff changeset
706 }
afc4e08f2143 Add access to documentation and to online html page via Help menu
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15987
diff changeset
707
afc4e08f2143 Add access to documentation and to online html page via Help menu
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15987
diff changeset
708 void
17509
d0fa3568eb5d update links in Help menu
John W. Eaton <jwe@octave.org>
parents: 17331
diff changeset
709 main_window::open_contribute_page (void)
d0fa3568eb5d update links in Help menu
John W. Eaton <jwe@octave.org>
parents: 17331
diff changeset
710 {
22211
6065bd58db2b use contribute/donate consistently in GUI (bug #44335)
Sahil Badyal <sbadyals@gmail.com>
parents: 22177
diff changeset
711 QDesktopServices::openUrl (QUrl ("http://octave.org/contribute.html"));
17509
d0fa3568eb5d update links in Help menu
John W. Eaton <jwe@octave.org>
parents: 17331
diff changeset
712 }
d0fa3568eb5d update links in Help menu
John W. Eaton <jwe@octave.org>
parents: 17331
diff changeset
713
d0fa3568eb5d update links in Help menu
John W. Eaton <jwe@octave.org>
parents: 17331
diff changeset
714 void
22211
6065bd58db2b use contribute/donate consistently in GUI (bug #44335)
Sahil Badyal <sbadyals@gmail.com>
parents: 22177
diff changeset
715 main_window::open_donate_page (void)
17509
d0fa3568eb5d update links in Help menu
John W. Eaton <jwe@octave.org>
parents: 17331
diff changeset
716 {
22211
6065bd58db2b use contribute/donate consistently in GUI (bug #44335)
Sahil Badyal <sbadyals@gmail.com>
parents: 22177
diff changeset
717 QDesktopServices::openUrl (QUrl ("http://octave.org/donate.html"));
13533
edaf8e72070e Added urls for Agora and Octave Forge in Community Window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13532
diff changeset
718 }
edaf8e72070e Added urls for Agora and Octave Forge in Community Window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13532
diff changeset
719
edaf8e72070e Added urls for Agora and Octave Forge in Community Window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13532
diff changeset
720 void
17676
c060ad097056 add menu entries to the editor for directly accessing the editor's settings
Torsten <ttl@justmail.de>
parents: 17674
diff changeset
721 main_window::process_settings_dialog_request (const QString& desired_tab)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
722 {
19632
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
723 if (_settings_dlg) // _settings_dlg is a guarded pointer!
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
724 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
725 // here the dialog is still open and called once again
19632
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
726 if (! desired_tab.isEmpty ())
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
727 _settings_dlg->show_tab (desired_tab);
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
728 return;
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
729 }
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
730
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
731 _settings_dlg = new settings_dialog (this, desired_tab);
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
732
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
733 connect (_settings_dlg, SIGNAL (apply_new_settings ()),
19631
4e85ca0b4887 add apply button to the settings dialog (bug #44081)
Torsten <ttl@justmail.de>
parents: 19589
diff changeset
734 this, SLOT (request_reload_settings ()));
4e85ca0b4887 add apply button to the settings dialog (bug #44081)
Torsten <ttl@justmail.de>
parents: 19589
diff changeset
735
19632
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
736 _settings_dlg->setModal (false);
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
737 _settings_dlg->setAttribute (Qt::WA_DeleteOnClose);
101ce4eaa56c prevent opening the settings dialog multiple times
Torsten <ttl@justmail.de>
parents: 19631
diff changeset
738 _settings_dlg->show ();
14588
fa52c6e84ae0 Added controls and settings for changing the terminal font.
"Israel Herraiz <israel.herraiz@upm.es>"
parents: 14586
diff changeset
739 }
fa52c6e84ae0 Added controls and settings for changing the terminal font.
"Israel Herraiz <israel.herraiz@upm.es>"
parents: 14586
diff changeset
740
19631
4e85ca0b4887 add apply button to the settings dialog (bug #44081)
Torsten <ttl@justmail.de>
parents: 19589
diff changeset
741 void
20113
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
742 main_window::copy_image_to_clipboard (const QString& file, bool remove_file)
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
743 {
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
744 QClipboard *clipboard = QApplication::clipboard ();
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
745
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
746 QImage img (file);
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
747
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
748 if (img.isNull ())
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
749 {
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
750 // Report error?
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
751 return;
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
752 }
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
753
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
754 clipboard->setImage (img);
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
755
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
756 if (remove_file)
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
757 QFile::remove (file);
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
758 }
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
759
c36f2b083613 make copying figures to clipboard work (bug #44866)
John W. Eaton <jwe@octave.org>
parents: 20091
diff changeset
760 void
19631
4e85ca0b4887 add apply button to the settings dialog (bug #44081)
Torsten <ttl@justmail.de>
parents: 19589
diff changeset
761 main_window::request_reload_settings ()
4e85ca0b4887 add apply button to the settings dialog (bug #44081)
Torsten <ttl@justmail.de>
parents: 19589
diff changeset
762 {
4e85ca0b4887 add apply button to the settings dialog (bug #44081)
Torsten <ttl@justmail.de>
parents: 19589
diff changeset
763 QSettings *settings = resource_manager::get_settings ();
4e85ca0b4887 add apply button to the settings dialog (bug #44081)
Torsten <ttl@justmail.de>
parents: 19589
diff changeset
764
4e85ca0b4887 add apply button to the settings dialog (bug #44081)
Torsten <ttl@justmail.de>
parents: 19589
diff changeset
765 if (settings)
4e85ca0b4887 add apply button to the settings dialog (bug #44081)
Torsten <ttl@justmail.de>
parents: 19589
diff changeset
766 emit settings_changed (settings);
4e85ca0b4887 add apply button to the settings dialog (bug #44081)
Torsten <ttl@justmail.de>
parents: 19589
diff changeset
767 }
15914
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15900
diff changeset
768
14588
fa52c6e84ae0 Added controls and settings for changing the terminal font.
"Israel Herraiz <israel.herraiz@upm.es>"
parents: 14586
diff changeset
769 void
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16399
diff changeset
770 main_window::notice_settings (const QSettings *settings)
14588
fa52c6e84ae0 Added controls and settings for changing the terminal font.
"Israel Herraiz <israel.herraiz@upm.es>"
parents: 14586
diff changeset
771 {
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16399
diff changeset
772 // QSettings pointer is checked before emitting.
14998
de3a318128f2 Added support for changing the terminal cursor and the cursor blinking.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14996
diff changeset
773
15787
b081fbe80174 provide separate icons for gui's floating widgets
Torsten <ttl@justmail.de>
parents: 15758
diff changeset
774 // the widget's icons (when floating)
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
775 QString icon_set
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
776 = settings->value ("DockWidgets/widget_icon_set", "NONE").toString ();
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
777
15914
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15900
diff changeset
778 static struct
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
779 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
780 QString name;
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
781 QString path;
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
782 }
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
783
15914
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15900
diff changeset
784 widget_icon_data[] =
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
785 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
786 // array of possible icon sets (name, path (complete for NONE))
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
787 // the first entry here is the default!
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
788 {"NONE", ":/actions/icons/logo.png"},
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
789 {"GRAPHIC", ":/actions/icons/graphic_logo_"},
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
790 {"LETTER", ":/actions/icons/letter_logo_"},
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
791 {"", ""} // end marker has empty name
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
792 };
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
793
15914
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15900
diff changeset
794 int count = 0;
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15900
diff changeset
795 int icon_set_found = 0; // default
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
796
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20278
diff changeset
797 while (! widget_icon_data[count].name.isEmpty ())
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
798 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
799 // while not end of data
15914
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15900
diff changeset
800 if (widget_icon_data[count].name == icon_set)
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
801 {
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
802 // data of desired icon set found
15914
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15900
diff changeset
803 icon_set_found = count;
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15900
diff changeset
804 break;
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15900
diff changeset
805 }
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15900
diff changeset
806 count++;
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15900
diff changeset
807 }
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
808
15787
b081fbe80174 provide separate icons for gui's floating widgets
Torsten <ttl@justmail.de>
parents: 15758
diff changeset
809 QString icon;
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16699
diff changeset
810 foreach (octave_dock_widget *widget, dock_widget_list ())
15787
b081fbe80174 provide separate icons for gui's floating widgets
Torsten <ttl@justmail.de>
parents: 15758
diff changeset
811 {
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16699
diff changeset
812 QString name = widget->objectName ();
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16699
diff changeset
813 if (! name.isEmpty ())
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16699
diff changeset
814 { // if children has a name
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
815 icon = widget_icon_data[icon_set_found].path; // prefix | octave-logo
15914
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15900
diff changeset
816 if (widget_icon_data[icon_set_found].name != "NONE")
20230
e914b5399c67 Use in-place operators in C++ code where possible.
Rik <rik@octave.org>
parents: 20186
diff changeset
817 icon += name + ".png"; // add widget name and ext.
15787
b081fbe80174 provide separate icons for gui's floating widgets
Torsten <ttl@justmail.de>
parents: 15758
diff changeset
818 widget->setWindowIcon (QIcon (icon));
b081fbe80174 provide separate icons for gui's floating widgets
Torsten <ttl@justmail.de>
parents: 15758
diff changeset
819 }
b081fbe80174 provide separate icons for gui's floating widgets
Torsten <ttl@justmail.de>
parents: 15758
diff changeset
820 }
17619
4288b90f18c4 icons for news and release notes widgets
Torsten <ttl@justmail.de>
parents: 17617
diff changeset
821 if (widget_icon_data[icon_set_found].name != "NONE")
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
822 _release_notes_icon = widget_icon_data[icon_set_found].path
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
823 + "ReleaseWidget.png";
17619
4288b90f18c4 icons for news and release notes widgets
Torsten <ttl@justmail.de>
parents: 17617
diff changeset
824 else
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
825 _release_notes_icon = ":/actions/icons/logo.png";
15787
b081fbe80174 provide separate icons for gui's floating widgets
Torsten <ttl@justmail.de>
parents: 15758
diff changeset
826
19847
597fc0fd8e54 make size of toolbar icons depending on scaling of display
Torsten <ttl@justmail.de>
parents: 19846
diff changeset
827 int icon_size_settings = settings->value ("toolbar_icon_size",0).toInt ();
597fc0fd8e54 make size of toolbar icons depending on scaling of display
Torsten <ttl@justmail.de>
parents: 19846
diff changeset
828 QStyle *st = style ();
597fc0fd8e54 make size of toolbar icons depending on scaling of display
Torsten <ttl@justmail.de>
parents: 19846
diff changeset
829 int icon_size = st->pixelMetric (QStyle::PM_ToolBarIconSize);
597fc0fd8e54 make size of toolbar icons depending on scaling of display
Torsten <ttl@justmail.de>
parents: 19846
diff changeset
830
597fc0fd8e54 make size of toolbar icons depending on scaling of display
Torsten <ttl@justmail.de>
parents: 19846
diff changeset
831 if (icon_size_settings == 1)
597fc0fd8e54 make size of toolbar icons depending on scaling of display
Torsten <ttl@justmail.de>
parents: 19846
diff changeset
832 icon_size = st->pixelMetric (QStyle::PM_LargeIconSize);
597fc0fd8e54 make size of toolbar icons depending on scaling of display
Torsten <ttl@justmail.de>
parents: 19846
diff changeset
833 else if (icon_size_settings == -1)
597fc0fd8e54 make size of toolbar icons depending on scaling of display
Torsten <ttl@justmail.de>
parents: 19846
diff changeset
834 icon_size = st->pixelMetric (QStyle::PM_SmallIconSize);
597fc0fd8e54 make size of toolbar icons depending on scaling of display
Torsten <ttl@justmail.de>
parents: 19846
diff changeset
835
16525
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
836 _main_tool_bar->setIconSize (QSize (icon_size,icon_size));
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
837
18733
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18717
diff changeset
838 if (settings->value ("show_status_bar",true).toBool ())
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18717
diff changeset
839 status_bar->show ();
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18717
diff changeset
840 else
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18717
diff changeset
841 status_bar->hide ();
f6f1f27026bb status bars and code folding a user preference (bug #42306)
Torsten <ttl@justmail.de>
parents: 18717
diff changeset
842
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
843 _prevent_readline_conflicts
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
844 = settings->value ("shortcuts/prevent_readline_conflicts", true).toBool ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
845
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
846 _suppress_dbg_location
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
847 = ! settings->value ("terminal/print_debug_location", false).toBool ();
19585
f9a944b9e1cb provide a user preference for printing the debug location in the terminal
Torsten <ttl@justmail.de>
parents: 19572
diff changeset
848
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15106
diff changeset
849 resource_manager::update_network_settings ();
19882
b403780efe90 make sure shortcuts are active in editor after settings dialog (bug #44397)
Torsten <ttl@justmail.de>
parents: 19868
diff changeset
850
b403780efe90 make sure shortcuts are active in editor after settings dialog (bug #44397)
Torsten <ttl@justmail.de>
parents: 19868
diff changeset
851 emit active_dock_changed (0, _active_dock); // update dock widget styles
19907
7d888f9e94eb fix some shortcut issues
Torsten <ttl@justmail.de>
parents: 19899
diff changeset
852
7d888f9e94eb fix some shortcut issues
Torsten <ttl@justmail.de>
parents: 19899
diff changeset
853 configure_shortcuts ();
7d888f9e94eb fix some shortcut issues
Torsten <ttl@justmail.de>
parents: 19899
diff changeset
854 set_global_shortcuts (_active_dock == command_window);
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
855 disable_menu_shortcuts (_active_dock == editor_window);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
856 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
857
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
858 void
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
859 main_window::confirm_shutdown_octave (void)
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
860 {
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
861 bool closenow = true;
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
862
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
863 if (_start_gui)
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
864 {
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
865 QSettings *settings = resource_manager::get_settings ();
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
866
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
867 if (settings->value ("prompt_to_exit", false).toBool ())
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
868 {
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
869 int ans = QMessageBox::question (this, tr ("Octave"),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
870 tr ("Are you sure you want to exit Octave?"),
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
871 (QMessageBox::Ok
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
872 | QMessageBox::Cancel),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
873 QMessageBox::Ok);
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
874
21568
3d60ed163b70 maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents: 21439
diff changeset
875 if (ans != QMessageBox::Ok)
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
876 closenow = false;
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
877 }
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
878
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
879 #if defined (HAVE_QSCINTILLA)
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
880 if (closenow)
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
881 closenow = 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
882 #endif
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
883 }
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
884
20091
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 20039
diff changeset
885 // Wait for link thread to go to sleep state.
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 20039
diff changeset
886 _octave_qt_link->mutex.lock ();
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 20039
diff changeset
887
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
888 _octave_qt_link->shutdown_confirmation (closenow);
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
889
20091
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 20039
diff changeset
890 _octave_qt_link->mutex.unlock ();
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 20039
diff changeset
891
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
892 // Awake the worker thread so that it continues shutting down (or not).
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
893 _octave_qt_link->waitcondition.wakeAll ();
20091
89d843d6de14 Add mutex lock to shutdown confirmation for proper thread timing (bug #44751).
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 20039
diff changeset
894
19714
21015ca26566 Restructure shutdown flow and behavior for improved robustness
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 19702
diff changeset
895 }
15914
85f9aca30c76 gui: reorganized handling of different icons for dock widgets
Torsten <ttl@justmail.de>
parents: 15900
diff changeset
896
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
897 void
16468
0f143f68078d use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents: 16460
diff changeset
898 main_window::prepare_to_exit (void)
14693
c952f1e35e50 Added patch from Marco Atzeri for QTerminal to build with cygwin. Removed some compiler warnings.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14692
diff changeset
899 {
22177
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
900 // Find files dialog is constructed dynamically, not at time of main_window
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
901 // construction. Connecting it to qApp aboutToQuit signal would have
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
902 // caused it to run after QSettings deleted.
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
903 if (find_files_dlg)
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
904 find_files_dlg->save_settings ();
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
905
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
906 write_settings ();
14693
c952f1e35e50 Added patch from Marco Atzeri for QTerminal to build with cygwin. Removed some compiler warnings.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14692
diff changeset
907 }
c952f1e35e50 Added patch from Marco Atzeri for QTerminal to build with cygwin. Removed some compiler warnings.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14692
diff changeset
908
c952f1e35e50 Added patch from Marco Atzeri for QTerminal to build with cygwin. Removed some compiler warnings.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14692
diff changeset
909 void
16593
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
910 main_window::reset_windows (void)
14700
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
911 {
16593
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
912 QSettings *settings = resource_manager::get_default_settings ();
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
913
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
914 set_window_layout (settings);
18117
a829f40933a8 fix minimized main window after resetting window layout (bug #40832)
Torsten <ttl@justmail.de>
parents: 18034
diff changeset
915 showNormal (); // make sure main window is not minimized
14700
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
916 }
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
917
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
918 void
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
919 main_window::change_directory (const QString& dir)
14700
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
920 {
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
921 // Remove existing entry, if any, then add new directory at top and
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
922 // mark it as the current directory. Finally, update the file list
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
923 // widget.
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
924
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
925 int index = _current_directory_combo_box->findText (dir);
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
926
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
927 if (index >= 0)
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
928 _current_directory_combo_box->removeItem (index);
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
929
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
930 _current_directory_combo_box->insertItem (0, dir);
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
931 _current_directory_combo_box->setCurrentIndex (0);
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
932 }
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
933
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
934 void
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
935 main_window::browse_for_directory (void)
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
936 {
16578
0eca6c5657c9 force focus to command window after browsing for directory
John W. Eaton <jwe@octave.org>
parents: 16576
diff changeset
937 QString dir
18000
b1271fc57779 use same string for tool tip and dialog box for searching new directory in gui
Torsten <ttl@justmail.de>
parents: 17997
diff changeset
938 = QFileDialog::getExistingDirectory (this, tr ("Browse directories"), 0,
18778
6e2b1de8348e only show directories in dialog box for setting new octave directory
Torsten <ttl@justmail.de>
parents: 18572
diff changeset
939 QFileDialog::ShowDirsOnly |
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
940 QFileDialog::DontUseNativeDialog);
16578
0eca6c5657c9 force focus to command window after browsing for directory
John W. Eaton <jwe@octave.org>
parents: 16576
diff changeset
941
0eca6c5657c9 force focus to command window after browsing for directory
John W. Eaton <jwe@octave.org>
parents: 16576
diff changeset
942 set_current_working_directory (dir);
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
943
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
944 // FIXME: on Windows systems, the command window freezes after the
16578
0eca6c5657c9 force focus to command window after browsing for directory
John W. Eaton <jwe@octave.org>
parents: 16576
diff changeset
945 // previous actions. Forcing the focus appears to unstick it.
0eca6c5657c9 force focus to command window after browsing for directory
John W. Eaton <jwe@octave.org>
parents: 16576
diff changeset
946
0eca6c5657c9 force focus to command window after browsing for directory
John W. Eaton <jwe@octave.org>
parents: 16576
diff changeset
947 focus_command_window ();
14700
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
948 }
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
949
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
950 void
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
951 main_window::set_current_working_directory (const QString& dir)
14700
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
952 {
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
953 // Change to dir if it is an existing directory.
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
954
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
955 QString xdir = dir.isEmpty () ? "." : dir;
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
956
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
957 QFileInfo fileInfo (xdir);
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
958
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
959 if (fileInfo.exists () && fileInfo.isDir ())
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
960 octave_link::post_event (this, &main_window::change_directory_callback,
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
961 xdir.toStdString ());
14700
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
962 }
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
963
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
964 void
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
965 main_window::change_directory_up (void)
14700
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
966 {
16526
01541f7321f7 correctly track directory for cd ..
John W. Eaton <jwe@octave.org>
parents: 16525
diff changeset
967 set_current_working_directory ("..");
14700
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
968 }
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
969
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
970 // Slot that is called if return is pressed in the line edit of the
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
971 // combobox to change to a new directory or a directory that is already
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
972 // in the drop down list.
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
973
15626
1cc10ce368ea enable entering a new directory in the current directory combobox
Torsten <ttl@justmail.de>
parents: 15607
diff changeset
974 void
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
975 main_window::accept_directory_line_edit (void)
15626
1cc10ce368ea enable entering a new directory in the current directory combobox
Torsten <ttl@justmail.de>
parents: 15607
diff changeset
976 {
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
977 // Get new directory name, and change to it if it is new. Otherwise,
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
978 // the combo box will triggers the "activated" signal to change to the
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
979 // directory.
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
980
16518
59dbdaeeea40 * main_window.cc(construct_tool_bar): code cleanup and tool tips for combo box
Torsten <ttl@justmail.de>
parents: 16514
diff changeset
981 QString dir = _current_directory_combo_box->currentText ();
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
982
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
983 int index = _current_directory_combo_box->findText (dir);
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
984
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
985 if (index < 0)
15626
1cc10ce368ea enable entering a new directory in the current directory combobox
Torsten <ttl@justmail.de>
parents: 15607
diff changeset
986 set_current_working_directory (dir);
1cc10ce368ea enable entering a new directory in the current directory combobox
Torsten <ttl@justmail.de>
parents: 15607
diff changeset
987 }
1cc10ce368ea enable entering a new directory in the current directory combobox
Torsten <ttl@justmail.de>
parents: 15607
diff changeset
988
14726
e94a54ee0f46 Added debug events, debug mode detection and fixed compiling error.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14721
diff changeset
989 void
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
990 main_window::handle_enter_debugger (void)
14726
e94a54ee0f46 Added debug events, debug mode detection and fixed compiling error.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14721
diff changeset
991 {
e94a54ee0f46 Added debug events, debug mode detection and fixed compiling error.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14721
diff changeset
992 setWindowTitle ("Octave (Debugging)");
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
993
14795
e3ae0850b105 Fixed integrating debug menu in the editor window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14784
diff changeset
994 _debug_continue->setEnabled (true);
e3ae0850b105 Fixed integrating debug menu in the editor window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14784
diff changeset
995 _debug_step_into->setEnabled (true);
e3ae0850b105 Fixed integrating debug menu in the editor window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14784
diff changeset
996 _debug_step_over->setEnabled (true);
e3ae0850b105 Fixed integrating debug menu in the editor window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14784
diff changeset
997 _debug_step_out->setEnabled (true);
e3ae0850b105 Fixed integrating debug menu in the editor window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14784
diff changeset
998 _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
999
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1000 #if defined (HAVE_QSCINTILLA)
16457
10edb6f1ae98 improve encapsulation of file editor window object
John W. Eaton <jwe@octave.org>
parents: 16456
diff changeset
1001 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
1002 #endif
14726
e94a54ee0f46 Added debug events, debug mode detection and fixed compiling error.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14721
diff changeset
1003 }
e94a54ee0f46 Added debug events, debug mode detection and fixed compiling error.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14721
diff changeset
1004
e94a54ee0f46 Added debug events, debug mode detection and fixed compiling error.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14721
diff changeset
1005 void
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
1006 main_window::handle_exit_debugger (void)
14726
e94a54ee0f46 Added debug events, debug mode detection and fixed compiling error.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14721
diff changeset
1007 {
e94a54ee0f46 Added debug events, debug mode detection and fixed compiling error.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14721
diff changeset
1008 setWindowTitle ("Octave");
16438
a971d8bdaadc use signals instead of event queue for entering/leaving debug mode
John W. Eaton <jwe@octave.org>
parents: 16437
diff changeset
1009
14795
e3ae0850b105 Fixed integrating debug menu in the editor window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14784
diff changeset
1010 _debug_continue->setEnabled (false);
e3ae0850b105 Fixed integrating debug menu in the editor window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14784
diff changeset
1011 _debug_step_into->setEnabled (false);
e3ae0850b105 Fixed integrating debug menu in the editor window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14784
diff changeset
1012 _debug_step_over->setEnabled (false);
e3ae0850b105 Fixed integrating debug menu in the editor window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14784
diff changeset
1013 _debug_step_out->setEnabled (false);
e3ae0850b105 Fixed integrating debug menu in the editor window.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14784
diff changeset
1014 _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
1015
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1016 #if defined (HAVE_QSCINTILLA)
16457
10edb6f1ae98 improve encapsulation of file editor window object
John W. Eaton <jwe@octave.org>
parents: 16456
diff changeset
1017 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
1018 #endif
14752
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1019 }
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1020
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1021 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
1022 main_window::debug_continue (void)
14752
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1023 {
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1024 octave_cmd_debug *cmd
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1025 = new octave_cmd_debug ("cont", _suppress_dbg_location);
21028
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
1026 _cmd_queue.add_cmd (cmd);
14752
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1027 }
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1028
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1029 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
1030 main_window::debug_step_into (void)
14752
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1031 {
21027
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20995
diff changeset
1032 octave_cmd_debug *cmd = new octave_cmd_debug ("in", _suppress_dbg_location);
21028
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
1033 _cmd_queue.add_cmd (cmd);
14752
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1034 }
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1035
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1036 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
1037 main_window::debug_step_over (void)
14752
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1038 {
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1039 octave_cmd_debug *cmd
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1040 = new octave_cmd_debug ("step", _suppress_dbg_location);
21028
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
1041 _cmd_queue.add_cmd (cmd);
14752
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1042 }
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1043
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1044 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
1045 main_window::debug_step_out (void)
14752
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1046 {
21027
8000dacaea98 GUI: no more extra command queue for debug commands
Torsten <ttl@justmail.de>
parents: 20995
diff changeset
1047 octave_cmd_debug *cmd = new octave_cmd_debug ("out", _suppress_dbg_location);
21028
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
1048 _cmd_queue.add_cmd (cmd);
14752
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1049 }
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1050
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1051 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
1052 main_window::debug_quit (void)
14752
564cc673bcc5 Added menu for debugging. Now sending debug control events, but these seem to not work flawlessly
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14727
diff changeset
1053 {
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1054 octave_cmd_debug *cmd
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1055 = new octave_cmd_debug ("quit", _suppress_dbg_location);
21028
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
1056 _cmd_queue.add_cmd (cmd);
14726
e94a54ee0f46 Added debug events, debug mode detection and fixed compiling error.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14721
diff changeset
1057 }
e94a54ee0f46 Added debug events, debug mode detection and fixed compiling error.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14721
diff changeset
1058
14700
7623bece76df Implemented logic for current directory bar.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14698
diff changeset
1059 void
16576
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1060 main_window::handle_insert_debugger_pointer_request (const QString& file,
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1061 int line)
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1062 {
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1063 bool cmd_focus = command_window_has_focus ();
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1064
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1065 emit insert_debugger_pointer_signal (file, line);
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1066
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1067 if (cmd_focus)
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1068 focus_command_window ();
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1069 }
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1070
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1071 void
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1072 main_window::handle_delete_debugger_pointer_request (const QString& file,
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1073 int line)
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1074 {
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1075 bool cmd_focus = command_window_has_focus ();
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1076
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1077 emit delete_debugger_pointer_signal (file, line);
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1078
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1079 if (cmd_focus)
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1080 focus_command_window ();
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1081 }
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1082
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1083 void
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1084 main_window::handle_update_breakpoint_marker_request (bool insert,
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1085 const QString& file,
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
1086 int line,
22599
51b395d24782 maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents: 22587
diff changeset
1087 const QString& cond)
16576
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1088 {
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1089 bool cmd_focus = command_window_has_focus ();
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1090
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
1091 emit update_breakpoint_marker_signal (insert, file, line, cond);
16576
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1092
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1093 if (cmd_focus)
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1094 focus_command_window ();
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1095 }
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1096
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1097 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
1098 main_window::show_about_octave (void)
13548
5c2ea445e100 Added about boxes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13546
diff changeset
1099 {
17510
7542f4496974 eliminate some macros in version.h
John W. Eaton <jwe@octave.org>
parents: 17509
diff changeset
1100 std::string message
7542f4496974 eliminate some macros in version.h
John W. Eaton <jwe@octave.org>
parents: 17509
diff changeset
1101 = octave_name_version_copyright_copying_warranty_and_bugs (true);
13548
5c2ea445e100 Added about boxes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13546
diff changeset
1102
17510
7542f4496974 eliminate some macros in version.h
John W. Eaton <jwe@octave.org>
parents: 17509
diff changeset
1103 QMessageBox::about (this, tr ("About Octave"),
7542f4496974 eliminate some macros in version.h
John W. Eaton <jwe@octave.org>
parents: 17509
diff changeset
1104 QString::fromStdString (message));
13548
5c2ea445e100 Added about boxes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13546
diff changeset
1105 }
5c2ea445e100 Added about boxes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13546
diff changeset
1106
5c2ea445e100 Added about boxes.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13546
diff changeset
1107 void
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
1108 main_window::closeEvent (QCloseEvent *e)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
1109 {
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
1110 e->ignore ();
19773
034bcac0b61c use of C++ API for running a file (bug #42307)
Torsten <ttl@justmail.de>
parents: 19739
diff changeset
1111 octave_cmd_exec *cmd = new octave_cmd_exec ("exit");
21028
4a7d9c335402 GUI: move the command queue into a separate class
Torsten <ttl@justmail.de>
parents: 21027
diff changeset
1112 _cmd_queue.add_cmd (cmd);
15367
501a9cc2c68f maint: whitespace cleanup in GUI code
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15365
diff changeset
1113 }
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
1114
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
1115 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
1116 main_window::read_settings (void)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
1117 {
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15106
diff changeset
1118 QSettings *settings = resource_manager::get_settings ();
16593
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1119
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20278
diff changeset
1120 if (! settings)
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16399
diff changeset
1121 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1122 qDebug ("Error: QSettings pointer from resource manager is NULL.");
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16399
diff changeset
1123 return;
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16399
diff changeset
1124 }
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15106
diff changeset
1125
16593
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1126 set_window_layout (settings);
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1127
15465
ded4ce76ee7a save and restore the list of recently visited directories
Torsten <ttl@justmail.de>
parents: 15426
diff changeset
1128 // restore the list of the last directories
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1129 QStringList curr_dirs
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1130 = settings->value ("MainWindow/current_directory_list").toStringList ();
15465
ded4ce76ee7a save and restore the list of recently visited directories
Torsten <ttl@justmail.de>
parents: 15426
diff changeset
1131 for (int i=0; i < curr_dirs.size (); i++)
ded4ce76ee7a save and restore the list of recently visited directories
Torsten <ttl@justmail.de>
parents: 15426
diff changeset
1132 {
ded4ce76ee7a save and restore the list of recently visited directories
Torsten <ttl@justmail.de>
parents: 15426
diff changeset
1133 _current_directory_combo_box->addItem (curr_dirs.at (i));
ded4ce76ee7a save and restore the list of recently visited directories
Torsten <ttl@justmail.de>
parents: 15426
diff changeset
1134 }
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16399
diff changeset
1135 emit settings_changed (settings);
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
1136 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
1137
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
1138 void
19303
c6615ca0a11d horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents: 19302
diff changeset
1139 main_window::init_terminal_size (void)
c6615ca0a11d horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents: 19302
diff changeset
1140 {
c6615ca0a11d horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents: 19302
diff changeset
1141 emit init_terminal_size_signal ();
c6615ca0a11d horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents: 19302
diff changeset
1142 }
c6615ca0a11d horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents: 19302
diff changeset
1143
c6615ca0a11d horizontal scrollbar for GUI terminal on Windows systems
John W. Eaton <jwe@octave.org>
parents: 19302
diff changeset
1144 void
16593
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1145 main_window::set_window_layout (QSettings *settings)
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1146 {
18435
4e49bc41f899 fix problems with gui startup (bug #41452) and focus issues (bug #40823)
Torsten <ttl@justmail.de>
parents: 18287
diff changeset
1147 #if ! defined (Q_OS_WIN32)
4e49bc41f899 fix problems with gui startup (bug #41452) and focus issues (bug #40823)
Torsten <ttl@justmail.de>
parents: 18287
diff changeset
1148 restoreState (settings->value ("MainWindow/windowState").toByteArray ());
4e49bc41f899 fix problems with gui startup (bug #41452) and focus issues (bug #40823)
Torsten <ttl@justmail.de>
parents: 18287
diff changeset
1149 restoreGeometry (settings->value ("MainWindow/geometry").toByteArray ());
4e49bc41f899 fix problems with gui startup (bug #41452) and focus issues (bug #40823)
Torsten <ttl@justmail.de>
parents: 18287
diff changeset
1150 #endif
17083
ceca3e65a8fe make sure a central menu bar does not show a widgets title but "Octave"
Torsten <ttl@justmail.de>
parents: 17029
diff changeset
1151
16593
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1152 // Restore the geometry of all dock-widgets
16811
81344ade678f fix resetting the window layout when some widgets are floating
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
1153 foreach (octave_dock_widget *widget, dock_widget_list ())
16593
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1154 {
16811
81344ade678f fix resetting the window layout when some widgets are floating
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
1155 QString name = widget->objectName ();
16593
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1156
16811
81344ade678f fix resetting the window layout when some widgets are floating
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
1157 if (! name.isEmpty ())
16593
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1158 {
16798
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16699
diff changeset
1159 bool floating = settings->value
d749c9b588e5 make stand-alone windows from dock widgets when floating (bug #38785)
Torsten <ttl@justmail.de>
parents: 16699
diff changeset
1160 ("DockWidgets/" + name + "Floating", false).toBool ();
17899
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17890
diff changeset
1161 bool visible = settings->value
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17890
diff changeset
1162 ("DockWidgets/" + name + "Visible", true).toBool ();
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17890
diff changeset
1163
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17890
diff changeset
1164 // If floating, make window from widget.
16811
81344ade678f fix resetting the window layout when some widgets are floating
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
1165 if (floating)
16818
caf3d2a45da0 clean up some code for undocking and docking widgets
Torsten <ttl@justmail.de>
parents: 16811
diff changeset
1166 widget->make_window ();
16811
81344ade678f fix resetting the window layout when some widgets are floating
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
1167 else if (! widget->parent ()) // should not be floating but is
17090
1d544ac39369 show correct undock-button of widgets when window layout is resetted
Torsten <ttl@justmail.de>
parents: 17083
diff changeset
1168 widget->make_widget (false); // no docking, just reparent
18435
4e49bc41f899 fix problems with gui startup (bug #41452) and focus issues (bug #40823)
Torsten <ttl@justmail.de>
parents: 18287
diff changeset
1169 #if ! defined (Q_OS_WIN32)
16811
81344ade678f fix resetting the window layout when some widgets are floating
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
1170 // restore geometry
17686
65544374c1cf restore (un)docking of widgets without reparenting on non-windows systems
Torsten <ttl@justmail.de>
parents: 17676
diff changeset
1171 QVariant val = settings->value ("DockWidgets/" + name);
16811
81344ade678f fix resetting the window layout when some widgets are floating
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
1172 widget->restoreGeometry (val.toByteArray ());
17899
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17890
diff changeset
1173 #endif
16811
81344ade678f fix resetting the window layout when some widgets are floating
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
1174 // make widget visible if desired
17083
ceca3e65a8fe make sure a central menu bar does not show a widgets title but "Octave"
Torsten <ttl@justmail.de>
parents: 17029
diff changeset
1175 if (floating && visible) // floating and visible
18435
4e49bc41f899 fix problems with gui startup (bug #41452) and focus issues (bug #40823)
Torsten <ttl@justmail.de>
parents: 18287
diff changeset
1176 {
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1177 if (settings->value ("DockWidgets/" + widget->objectName ()
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1178 + "_minimized").toBool ())
18435
4e49bc41f899 fix problems with gui startup (bug #41452) and focus issues (bug #40823)
Torsten <ttl@justmail.de>
parents: 18287
diff changeset
1179 widget->showMinimized ();
4e49bc41f899 fix problems with gui startup (bug #41452) and focus issues (bug #40823)
Torsten <ttl@justmail.de>
parents: 18287
diff changeset
1180 else
4e49bc41f899 fix problems with gui startup (bug #41452) and focus issues (bug #40823)
Torsten <ttl@justmail.de>
parents: 18287
diff changeset
1181 widget->setVisible (true);
4e49bc41f899 fix problems with gui startup (bug #41452) and focus issues (bug #40823)
Torsten <ttl@justmail.de>
parents: 18287
diff changeset
1182 }
17083
ceca3e65a8fe make sure a central menu bar does not show a widgets title but "Octave"
Torsten <ttl@justmail.de>
parents: 17029
diff changeset
1183 else
17090
1d544ac39369 show correct undock-button of widgets when window layout is resetted
Torsten <ttl@justmail.de>
parents: 17083
diff changeset
1184 {
1d544ac39369 show correct undock-button of widgets when window layout is resetted
Torsten <ttl@justmail.de>
parents: 17083
diff changeset
1185 widget->make_widget ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1186 widget->setVisible (visible); // not floating -> show
17090
1d544ac39369 show correct undock-button of widgets when window layout is resetted
Torsten <ttl@justmail.de>
parents: 17083
diff changeset
1187 }
16593
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1188 }
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1189 }
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1190
18435
4e49bc41f899 fix problems with gui startup (bug #41452) and focus issues (bug #40823)
Torsten <ttl@justmail.de>
parents: 18287
diff changeset
1191 #if defined (Q_OS_WIN32)
16811
81344ade678f fix resetting the window layout when some widgets are floating
Torsten <ttl@justmail.de>
parents: 16798
diff changeset
1192 restoreState (settings->value ("MainWindow/windowState").toByteArray ());
16593
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1193 restoreGeometry (settings->value ("MainWindow/geometry").toByteArray ());
18435
4e49bc41f899 fix problems with gui startup (bug #41452) and focus issues (bug #40823)
Torsten <ttl@justmail.de>
parents: 18287
diff changeset
1194 #endif
4e49bc41f899 fix problems with gui startup (bug #41452) and focus issues (bug #40823)
Torsten <ttl@justmail.de>
parents: 18287
diff changeset
1195
17995
ea1db0ede4ce make sure Octave is displayed in a global menu bar, not another widget name
Torsten <ttl@justmail.de>
parents: 17988
diff changeset
1196 show ();
16593
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1197 }
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1198
e13051d7a472 allow GUI window layout to be restored
John W. Eaton <jwe@octave.org>
parents: 16581
diff changeset
1199 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
1200 main_window::write_settings (void)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
1201 {
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15106
diff changeset
1202 QSettings *settings = resource_manager::get_settings ();
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20278
diff changeset
1203 if (! settings)
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16399
diff changeset
1204 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1205 qDebug ("Error: QSettings pointer from resource manager is NULL.");
16413
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16399
diff changeset
1206 return;
28136851099a remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16399
diff changeset
1207 }
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15106
diff changeset
1208
13537
a43ecce77eec Introduced a central ResourceManager class.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13536
diff changeset
1209 settings->setValue ("MainWindow/geometry", saveGeometry ());
15552
bbbb89cc338f make a floating widget behave like a normal window (bug #37190)
Torsten <ttl@justmail.de>
parents: 15465
diff changeset
1210 settings->setValue ("MainWindow/windowState", saveState ());
15465
ded4ce76ee7a save and restore the list of recently visited directories
Torsten <ttl@justmail.de>
parents: 15426
diff changeset
1211 // write the list of recent used directories
ded4ce76ee7a save and restore the list of recently visited directories
Torsten <ttl@justmail.de>
parents: 15426
diff changeset
1212 QStringList curr_dirs;
ded4ce76ee7a save and restore the list of recently visited directories
Torsten <ttl@justmail.de>
parents: 15426
diff changeset
1213 for (int i=0; i<_current_directory_combo_box->count (); i++)
ded4ce76ee7a save and restore the list of recently visited directories
Torsten <ttl@justmail.de>
parents: 15426
diff changeset
1214 {
ded4ce76ee7a save and restore the list of recently visited directories
Torsten <ttl@justmail.de>
parents: 15426
diff changeset
1215 curr_dirs.append (_current_directory_combo_box->itemText (i));
ded4ce76ee7a save and restore the list of recently visited directories
Torsten <ttl@justmail.de>
parents: 15426
diff changeset
1216 }
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
1217 settings->setValue ("MainWindow/current_directory_list", curr_dirs);
14694
ea11c9d8aa47 Calling qApp->quit () via QMetaObject::invoke caused a segfault, now exits cleanly.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14693
diff changeset
1218 settings->sync ();
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
1219 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
1220
15987
47a4c92924a7 gui: prevent error messages at start-up (regression from changeset 6c0fce0632a4)
Torsten <ttl@justmail.de>
parents: 15983
diff changeset
1221 // Connecting the signals emitted when the visibility of a widget changes.
47a4c92924a7 gui: prevent error messages at start-up (regression from changeset 6c0fce0632a4)
Torsten <ttl@justmail.de>
parents: 15983
diff changeset
1222 // This has to be done after the window is shown (see octave-gui.cc)
47a4c92924a7 gui: prevent error messages at start-up (regression from changeset 6c0fce0632a4)
Torsten <ttl@justmail.de>
parents: 15983
diff changeset
1223 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
1224 main_window::connect_visibility_changed (void)
15987
47a4c92924a7 gui: prevent error messages at start-up (regression from changeset 6c0fce0632a4)
Torsten <ttl@justmail.de>
parents: 15983
diff changeset
1225 {
17617
9abb1422d60b correct indication of news-windows visibility in the window menu
Torsten <ttl@justmail.de>
parents: 17599
diff changeset
1226 foreach (octave_dock_widget *widget, dock_widget_list ())
9abb1422d60b correct indication of news-windows visibility in the window menu
Torsten <ttl@justmail.de>
parents: 17599
diff changeset
1227 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
1228
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1229 #if defined (HAVE_QSCINTILLA)
18944
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
1230 editor_window->enable_menu_shortcuts (false);
19589
4fe86a372f10 Fix compilation error when building without QScintilla
Mike Miller <mtmiller@ieee.org>
parents: 19585
diff changeset
1231 #endif
15987
47a4c92924a7 gui: prevent error messages at start-up (regression from changeset 6c0fce0632a4)
Torsten <ttl@justmail.de>
parents: 15983
diff changeset
1232 }
47a4c92924a7 gui: prevent error messages at start-up (regression from changeset 6c0fce0632a4)
Torsten <ttl@justmail.de>
parents: 15983
diff changeset
1233
16648
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16642
diff changeset
1234 void
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16642
diff changeset
1235 main_window::copyClipboard (void)
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16642
diff changeset
1236 {
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1237 if (_current_directory_combo_box->hasFocus ())
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1238 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1239 QLineEdit * edit = _current_directory_combo_box->lineEdit ();
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1240 if (edit && edit->hasSelectedText ())
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1241 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1242 QClipboard *clipboard = QApplication::clipboard ();
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1243 clipboard->setText (edit->selectedText ());
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1244 }
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1245 }
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1246 else
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1247 emit copyClipboard_signal ();
16648
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16642
diff changeset
1248 }
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16642
diff changeset
1249
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16642
diff changeset
1250 void
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16642
diff changeset
1251 main_window::pasteClipboard (void)
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16642
diff changeset
1252 {
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1253 if (_current_directory_combo_box->hasFocus ())
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1254 {
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1255 QLineEdit * edit = _current_directory_combo_box->lineEdit ();
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1256 QClipboard *clipboard = QApplication::clipboard ();
21568
3d60ed163b70 maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents: 21439
diff changeset
1257 QString str = clipboard->text ();
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1258 if (edit && str.length () > 0)
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1259 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1260 edit->insert (str);
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1261 }
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1262 }
16881
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1263 else
944ade6e7f66 Make main window copy and paste global for current focused window
John Donoghue <john.donoghue@ieee.org>
parents: 16818
diff changeset
1264 emit pasteClipboard_signal ();
16648
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16642
diff changeset
1265 }
b04413e5a811 improve handling of interrupts, copy and paste shortcuts
John W. Eaton <jwe@octave.org>
parents: 16642
diff changeset
1266
18555
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1267 void
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1268 main_window::selectAll (void)
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1269 {
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1270 if (_current_directory_combo_box->hasFocus ())
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1271 {
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1272 QLineEdit * edit = _current_directory_combo_box->lineEdit ();
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1273 if (edit)
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1274 {
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1275 edit->selectAll ();
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1276 }
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1277 }
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1278 else
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1279 emit selectAll_signal ();
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1280 }
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
1281
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1282 // Connect the signals emitted when the Octave thread wants to create
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1283 // a dialog box of some sort. Perhaps a better place for this would be
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1284 // as part of the QUIWidgetCreator class. However, mainWindow currently
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1285 // is not a global variable and not accessible for connecting.
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1286
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1287 void
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1288 main_window::connect_uiwidget_links (void)
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1289 {
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1290 connect (&uiwidget_creator,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1291 SIGNAL (create_dialog (const QString&, const QString&,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1292 const QString&, const QStringList&,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1293 const QString&, const QStringList&)),
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1294 this,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1295 SLOT (handle_create_dialog (const QString&, const QString&,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1296 const QString&, const QStringList&,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1297 const QString&, const QStringList&)));
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1298
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1299 // Register QIntList so that list of ints may be part of a signal.
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1300 qRegisterMetaType<QIntList> ("QIntList");
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1301 connect (&uiwidget_creator,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1302 SIGNAL (create_listview (const QStringList&, const QString&,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1303 int, int, const QIntList&,
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
1304 const QString&, const QStringList&,
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1305 const QString&, const QString&)),
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1306 this,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1307 SLOT (handle_create_listview (const QStringList&, const QString&,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1308 int, int, const QIntList&,
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
1309 const QString&, const QStringList&,
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1310 const QString&, const QString&)));
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1311
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
1312 // Register QFloatList so that list of floats may be part of a signal.
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1313 qRegisterMetaType<QFloatList> ("QFloatList");
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1314 connect (&uiwidget_creator,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1315 SIGNAL (create_inputlayout (const QStringList&, const QString&,
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
1316 const QFloatList&, const QFloatList&,
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1317 const QStringList&)),
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1318 this,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1319 SLOT (handle_create_inputlayout (const QStringList&, const QString&,
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1320 const QFloatList&,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1321 const QFloatList&,
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1322 const QStringList&)));
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16578
diff changeset
1323
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16578
diff changeset
1324 connect (&uiwidget_creator,
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
1325 SIGNAL (create_filedialog (const QStringList &,const QString&,
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1326 const QString&, const QString&,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1327 const QString&)),
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16578
diff changeset
1328 this,
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
1329 SLOT (handle_create_filedialog (const QStringList &, const QString&,
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
1330 const QString&, const QString&,
16581
fa4a035e0cf4 Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16580
diff changeset
1331 const QString&)));
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1332 }
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1333
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1334 // Create a message dialog with specified string, buttons and decorative
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1335 // text.
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1336
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1337 void
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1338 main_window::handle_create_dialog (const QString& message,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1339 const QString& title,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1340 const QString& icon,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1341 const QStringList& button,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1342 const QString& defbutton,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1343 const QStringList& role)
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1344 {
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1345 MessageDialog *message_dialog = new MessageDialog (message, title, icon,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1346 button, defbutton, role);
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1347 message_dialog->setAttribute (Qt::WA_DeleteOnClose);
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1348 message_dialog->show ();
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1349 }
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1350
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1351 // Create a list dialog with specified list, initially selected, mode,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1352 // view size and decorative text.
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1353
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1354 void
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1355 main_window::handle_create_listview (const QStringList& list,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1356 const QString& mode,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1357 int wd, int ht,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1358 const QIntList& initial,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1359 const QString& name,
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
1360 const QStringList& prompt,
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1361 const QString& ok_string,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1362 const QString& cancel_string)
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1363 {
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1364 ListDialog *list_dialog = new ListDialog (list, mode, wd, ht,
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
1365 initial, name, prompt,
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1366 ok_string, cancel_string);
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1367
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1368 list_dialog->setAttribute (Qt::WA_DeleteOnClose);
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1369 list_dialog->show ();
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1370 }
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1371
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1372 // Create an input dialog with specified prompts and defaults, title and
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1373 // row/column size specifications.
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1374 void
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1375 main_window::handle_create_inputlayout (const QStringList& prompt,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1376 const QString& title,
16551
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
1377 const QFloatList& nr,
6ae555fc8c43 Add questdlg dialog function and fix variety of dialog bugs.
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 16547
diff changeset
1378 const QFloatList& nc,
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1379 const QStringList& defaults)
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1380 {
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1381 InputDialog *input_dialog = new InputDialog (prompt, title, nr, nc,
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1382 defaults);
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1383
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1384 input_dialog->setAttribute (Qt::WA_DeleteOnClose);
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1385 input_dialog->show ();
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1386 }
15987
47a4c92924a7 gui: prevent error messages at start-up (regression from changeset 6c0fce0632a4)
Torsten <ttl@justmail.de>
parents: 15983
diff changeset
1387
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16578
diff changeset
1388 void
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
1389 main_window::handle_create_filedialog (const QStringList& filters,
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1390 const QString& title,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
1391 const QString& filename,
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
1392 const QString& dirname,
16581
fa4a035e0cf4 Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16580
diff changeset
1393 const QString& multimode)
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16578
diff changeset
1394 {
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
1395 FileDialog *file_dialog = new FileDialog (filters, title, filename,
16581
fa4a035e0cf4 Add octave_link uiputfile implementation
John Donoghue <john.donoghue@ieee.org>
parents: 16580
diff changeset
1396 dirname, multimode);
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
1397
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16578
diff changeset
1398 file_dialog->setAttribute (Qt::WA_DeleteOnClose);
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16578
diff changeset
1399 file_dialog->show ();
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16578
diff changeset
1400 }
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 16578
diff changeset
1401
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1402
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1403 //
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1404 // Functions related to file editing
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1405 //
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1406 // These are moved from editor to here for also using them when octave
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1407 // is built without qscintilla
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1408 //
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1409 void
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1410 main_window::request_open_file (void)
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1411 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1412 // Open file isn't a file_editor_tab or editor function since the file
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1413 // might be opened in an external editor. Hence, functionality is here.
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1414
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1415 QSettings *settings = resource_manager::get_settings ();
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1416 bool is_internal = editor_window
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1417 && ! settings->value ("useCustomFileEditor",false).toBool ();
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1418
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1419 // Create a NonModal message.
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1420 QWidget *p = this;
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1421 if (is_internal)
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1422 p = editor_window;
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1423 QFileDialog *fileDialog = new QFileDialog (p);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1424 fileDialog->setNameFilter (tr ("Octave Files (*.m);;All Files (*)"));
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1425
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1426 // Giving trouble under KDE (problem is related to Qt signal handling on unix,
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1427 // see https://bugs.kde.org/show_bug.cgi?id=260719 ,
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1428 // it had/has no effect on Windows, though)
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1429 fileDialog->setOption (QFileDialog::DontUseNativeDialog, true);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1430
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1431 // define a new grid layout with the extra elements
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1432 QGridLayout *extra = new QGridLayout (fileDialog);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1433 QFrame *separator = new QFrame (fileDialog);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1434 separator->setFrameShape (QFrame::HLine); // horizontal line as separator
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1435 separator->setFrameStyle (QFrame::Sunken);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1436
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1437 if (is_internal)
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1438 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1439 // combo box for encoding, only when using the internal editor
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1440 QLabel *label_enc = new QLabel (tr ("File Encoding:"));
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1441 QComboBox *combo_enc = new QComboBox ();
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1442 resource_manager::combo_encoding (combo_enc);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1443 _file_encoding = QString (); // default
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1444
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1445 // track changes in the combo boxes
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1446 connect (combo_enc, SIGNAL (currentIndexChanged (QString)),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1447 this, SLOT (set_file_encoding (QString)));
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1448
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1449 // build the extra grid layout
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1450 extra->addWidget (separator,0,0,1,3);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1451 extra->addWidget (label_enc,1,0);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1452 extra->addWidget (combo_enc,1,1);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1453 extra->addItem (new QSpacerItem (1,20,QSizePolicy::Expanding,
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1454 QSizePolicy::Fixed), 1,2);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1455
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1456 // and add the extra grid layout to the dialog's layout
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1457 QGridLayout *dialog_layout = dynamic_cast<QGridLayout*> (
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1458 fileDialog->layout ());
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1459 dialog_layout->addLayout (extra,dialog_layout->rowCount (),0,
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1460 1,dialog_layout->columnCount ());
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1461 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1462
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1463 fileDialog->setAcceptMode (QFileDialog::AcceptOpen);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1464 fileDialog->setViewMode (QFileDialog::Detail);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1465 fileDialog->setFileMode (QFileDialog::ExistingFiles);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1466 fileDialog->setDirectory (_current_directory_combo_box->itemText (0));
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1467
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1468 connect (fileDialog, SIGNAL (filesSelected (const QStringList&)),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1469 this, SLOT (request_open_files (const QStringList&)));
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1470
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1471 fileDialog->setWindowModality (Qt::NonModal);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1472 fileDialog->setAttribute (Qt::WA_DeleteOnClose);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1473 fileDialog->show ();
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1474 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1475
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1476 void
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1477 main_window::set_file_encoding (const QString& new_encoding)
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1478 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1479 _file_encoding = new_encoding;
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1480 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1481
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1482 // The following slot is called after files have been selected in the
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1483 // open file dialog., possibly with a new selected encoding stored in
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1484 // _file_encoding
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1485 void
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1486 main_window::request_open_files (const QStringList& open_file_names)
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1487 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1488 for (int i = 0; i < open_file_names.count (); i++)
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1489 emit open_file_signal (open_file_names.at (i), _file_encoding, -1);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1490 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1491
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1492 void
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1493 main_window::handle_edit_mfile_request (const QString& fname,
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1494 const QString& ffile,
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1495 const QString& curr_dir, int line)
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1496 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1497 // Is it a regular function within the search path? (Call __which__)
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1498 octave_value_list fct = F__which__ (ovl (fname.toStdString ()),0);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1499 octave_map map = fct(0).map_value ();
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1500
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1501 QString type = QString::fromStdString (
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1502 map.contents ("type").data ()[0].string_value ());
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1503 QString name = QString::fromStdString (
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1504 map.contents ("name").data ()[0].string_value ());
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1505
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1506 QString message = QString ();
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1507 QString filename = QString ();
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1508
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1509 if (type == QString ("built-in function"))
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1510 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1511 // built in function: can't edit
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1512 message = tr ("%1 is a built-in function");
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1513 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1514 else if (type.isEmpty ())
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1515 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1516 // function not known to octave -> try directory of edited file
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1517 // get directory
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1518 QDir dir;
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1519 if (ffile.isEmpty ())
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1520 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1521 if (curr_dir.isEmpty ())
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1522 dir = QDir (_current_directory_combo_box->itemText (0));
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1523 else
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1524 dir = QDir (curr_dir);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1525 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1526 else
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1527 dir = QDir (QFileInfo (ffile).canonicalPath ());
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1528
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1529 // function not known to octave -> try directory of edited file
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1530 QFileInfo file = QFileInfo (dir, fname + ".m");
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1531
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1532 if (file.exists ())
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1533 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1534 filename = file.canonicalFilePath (); // local file exists
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1535 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1536 else
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1537 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1538 // local file does not exist -> try private directory
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1539 file = QFileInfo (ffile);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1540 file = QFileInfo (QDir (file.canonicalPath () + "/private"),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1541 fname + ".m");
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1542
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1543 if (file.exists ())
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1544 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1545 filename = file.canonicalFilePath (); // private function exists
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1546 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1547 else
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1548 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1549 message = tr ("Can not find function %1"); // no file found
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1550 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1551 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1552 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1553
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1554 if (! message.isEmpty ())
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1555 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1556 QMessageBox *msgBox
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1557 = new QMessageBox (QMessageBox::Critical,
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1558 tr ("Octave Editor"),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1559 message.arg (name),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1560 QMessageBox::Ok, this);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1561
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1562 msgBox->setWindowModality (Qt::NonModal);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1563 msgBox->setAttribute (Qt::WA_DeleteOnClose);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1564 msgBox->show ();
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1565 return;
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1566 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1567
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1568 if (filename.isEmpty ())
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1569 filename = QString::fromStdString (
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1570 map.contents ("file").data ()[0].string_value ());
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1571
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1572 if (! filename.endsWith (".m"))
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1573 filename.append (".m");
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1574
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1575 emit open_file_signal (filename, QString (), line); // default encoding
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1576 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1577
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1578 // Create a new script
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1579 void
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1580 main_window::request_new_script (const QString& commands)
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1581 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1582 emit new_file_signal (commands);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1583 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1584
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1585 // Create a new function and open it
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1586 void
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1587 main_window::request_new_function (bool)
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1588 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1589 bool ok;
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1590 // Get the name of the new function: Parent of the input dialog is the
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1591 // editor window or the main window. The latter is chosen, if a custom
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1592 // editor is used or qscintilla is not available
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1593 QWidget *p = editor_window;
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1594 QSettings *settings = resource_manager::get_settings ();
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1595 if (! p || settings->value ("useCustomFileEditor",false).toBool ())
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1596 p = this;
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1597 QString new_name = QInputDialog::getText (p, tr ("New Function"),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1598 tr ("New function name:\n"), QLineEdit::Normal, "", &ok);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1599
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1600 if (ok && new_name.length () > 0)
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1601 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1602 // append suffix if it not already exists
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1603 if (new_name.rightRef (2) != ".m")
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1604 new_name.append (".m");
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1605 // check whether new files are created without prompt
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1606 QSettings *settings = resource_manager::get_settings ();
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1607 if (! settings->value ("editor/create_new_file",false).toBool ())
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1608 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1609 // no, so enable this settings and wait for end of new file loading
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1610 settings->setValue ("editor/create_new_file",true);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1611 connect (editor_window, SIGNAL (file_loaded_signal ()),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1612 this, SLOT (restore_create_file_setting ()));
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1613 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1614 // start the edit command
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1615 execute_command_in_terminal ("edit " + new_name);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1616 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1617 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1618
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1619 void
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1620 main_window::restore_create_file_setting ()
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1621 {
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1622 // restore the new files creation setting
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1623 QSettings *settings = resource_manager::get_settings ();
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1624 settings->setValue ("editor/create_new_file",false);
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1625 disconnect (editor_window, SIGNAL (file_loaded_signal ()),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1626 this, SLOT (restore_create_file_setting ()));
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1627 }
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1628
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1629
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1630 //
15987
47a4c92924a7 gui: prevent error messages at start-up (regression from changeset 6c0fce0632a4)
Torsten <ttl@justmail.de>
parents: 15983
diff changeset
1631 // Main subroutine of the constructor
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1632 //
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
1633 void
16456
203efbbcea63 * main-window.h, main-window.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents: 16455
diff changeset
1634 main_window::construct (void)
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
1635 {
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
1636 _closing = false; // flag for editor files when closed
16445
3f8d3fc907af store workspace model in main_window, not in workspace view
John W. Eaton <jwe@octave.org>
parents: 16443
diff changeset
1637
15607
c9c79d4a0a00 Delete dynamic objects in the main_window destructor for proper cleanup. (bug #37234)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15591
diff changeset
1638 // Create and set the central widget. QMainWindow takes ownership of
c9c79d4a0a00 Delete dynamic objects in the main_window destructor for proper cleanup. (bug #37234)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15591
diff changeset
1639 // the widget (pointer) so there is no need to delete the object upon
c9c79d4a0a00 Delete dynamic objects in the main_window destructor for proper cleanup. (bug #37234)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 15591
diff changeset
1640 // destroying this main_window.
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1641
14693
c952f1e35e50 Added patch from Marco Atzeri for QTerminal to build with cygwin. Removed some compiler warnings.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14692
diff changeset
1642 QWidget *dummyWidget = new QWidget ();
14698
79c9a6d06590 Wrote SymbolInformation struct and refactored code that updates the symbol table.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14695
diff changeset
1643 dummyWidget->setObjectName ("CentralDummyWidget");
79c9a6d06590 Wrote SymbolInformation struct and refactored code that updates the symbol table.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14695
diff changeset
1644 dummyWidget->resize (10, 10);
14693
c952f1e35e50 Added patch from Marco Atzeri for QTerminal to build with cygwin. Removed some compiler warnings.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14692
diff changeset
1645 dummyWidget->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum);
14698
79c9a6d06590 Wrote SymbolInformation struct and refactored code that updates the symbol table.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14695
diff changeset
1646 dummyWidget->hide ();
79c9a6d06590 Wrote SymbolInformation struct and refactored code that updates the symbol table.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14695
diff changeset
1647 setCentralWidget (dummyWidget);
14692
d6d250812c01 Made the terminal window dockable, too. Now the whole interface is fully dockable.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14690
diff changeset
1648
16512
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1649 connect_uiwidget_links ();
7f2395651a1c dialog boxes with Qt widgets
Daniel J Sebald <daniel.sebald@ieee.org>, John W. Eaton <jwe@octave.org>
parents: 16504
diff changeset
1650
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1651 construct_octave_qt_link ();
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1652
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1653 if (_start_gui)
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1654 {
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1655 setWindowIcon (QIcon (":/actions/icons/logo.png"));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1656
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1657 workspace_window->setModel (_workspace_model);
23119
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
1658
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1659 connect (_workspace_model, SIGNAL (model_changed (void)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1660 workspace_window, SLOT (handle_model_changed (void)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1661
23119
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
1662 connect (_workspace_model,
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
1663 SIGNAL (rename_variable (const QString&, const QString&)),
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
1664 this,
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
1665 SLOT (handle_rename_variable_request (const QString&,
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
1666 const QString&)));
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
1667
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
1668 connect (command_window, SIGNAL (interrupt_signal (void)),
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
1669 this, SLOT (interrupt_interpreter (void)));
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
1670
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1671 construct_menu_bar ();
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1672
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1673 construct_tool_bar ();
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1674
22177
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1675 // Order is important. Deleting QSettings must be last.
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1676 connect (qApp, SIGNAL (aboutToQuit ()),
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1677 command_window, SLOT (save_settings ()));
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1678 connect (qApp, SIGNAL (aboutToQuit ()),
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1679 history_window, SLOT (save_settings ()));
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1680 connect (qApp, SIGNAL (aboutToQuit ()),
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1681 file_browser_window, SLOT (save_settings ()));
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1682 connect (qApp, SIGNAL (aboutToQuit ()),
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1683 doc_browser_window, SLOT (save_settings ()));
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1684 connect (qApp, SIGNAL (aboutToQuit ()),
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1685 workspace_window, SLOT (save_settings ()));
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1686 connect (qApp, SIGNAL (aboutToQuit ()),
23160
50e3a3e962c0 make editor save its widget settings again when octave quits
Torsten <mttl@mailbox.org>
parents: 22599
diff changeset
1687 editor_window, SLOT (save_settings ()));
50e3a3e962c0 make editor save its widget settings again when octave quits
Torsten <mttl@mailbox.org>
parents: 22599
diff changeset
1688 connect (qApp, SIGNAL (aboutToQuit ()),
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1689 this, SLOT (prepare_to_exit ()));
22177
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1690 connect (qApp, SIGNAL (aboutToQuit ()),
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1691 shortcut_manager::instance, SLOT (cleanup_instance ()));
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1692 // QSettings are saved upon deletion (i.e., cleanup_instance)
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1693 connect (qApp, SIGNAL (aboutToQuit ()),
6e9f5408c0db Save settings in Qt convention, delete all children in destructors (bug #45366)
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 22089
diff changeset
1694 resource_manager::instance, SLOT (cleanup_instance ()));
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1695
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1696 connect (qApp, SIGNAL (focusChanged (QWidget*, QWidget*)),
23070
bef714f45999 maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents: 22755
diff changeset
1697 this, SLOT (focus_changed (QWidget*, QWidget*)));
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1698
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1699 connect (this, SIGNAL (settings_changed (const QSettings *)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1700 this, SLOT (notice_settings (const QSettings *)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1701
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1702 connect (this, SIGNAL (editor_focus_changed (bool)),
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
1703 this, SLOT (disable_menu_shortcuts (bool)));
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1704
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1705 connect (this, SIGNAL (editor_focus_changed (bool)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1706 editor_window, SLOT (enable_menu_shortcuts (bool)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1707
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1708 connect (editor_window,
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1709 SIGNAL (request_open_file_external (const QString&, int)),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1710 _external_editor,
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1711 SLOT (call_custom_editor (const QString&, int)));
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1712
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1713 connect (_external_editor,
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1714 SIGNAL (request_settings_dialog (const QString&)),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1715 this, SLOT (process_settings_dialog_request (const QString&)));
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1716
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1717 connect (file_browser_window, SIGNAL (load_file_signal (const QString&)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1718 this, SLOT (handle_load_workspace_request (const QString&)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1719
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1720 connect (file_browser_window, SIGNAL (find_files_signal (const QString&)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1721 this, SLOT (find_files (const QString&)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1722
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1723 setWindowTitle ("Octave");
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1724
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1725 setDockOptions (QMainWindow::AnimatedDocks
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1726 | QMainWindow::AllowNestedDocks
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1727 | QMainWindow::AllowTabbedDocks);
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1728
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1729 addDockWidget (Qt::RightDockWidgetArea, command_window);
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1730 addDockWidget (Qt::RightDockWidgetArea, doc_browser_window);
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1731 tabifyDockWidget (command_window, doc_browser_window);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1732
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1733 #if defined (HAVE_QSCINTILLA)
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1734 addDockWidget (Qt::RightDockWidgetArea, editor_window);
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1735 tabifyDockWidget (command_window, editor_window);
16379
4bb1b82076e5 gui: provide defaults for all values read from the settings file
Torsten <ttl@justmail.de>
parents: 16377
diff changeset
1736 #endif
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1737
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1738 addDockWidget (Qt::LeftDockWidgetArea, file_browser_window);
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1739 addDockWidget (Qt::LeftDockWidgetArea, workspace_window);
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1740 addDockWidget (Qt::LeftDockWidgetArea, history_window);
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1741
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1742 int win_x = QApplication::desktop ()->width ();
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1743 int win_y = QApplication::desktop ()->height ();
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1744
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1745 if (win_x > 960)
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1746 win_x = 960;
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1747
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1748 if (win_y > 720)
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1749 win_y = 720;
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1750
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1751 setGeometry (0, 0, win_x, win_y);
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1752
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1753 setStatusBar (status_bar);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1754
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1755 #if defined (HAVE_QSCINTILLA)
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1756 connect (this,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1757 SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1758 editor_window,
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1759 SLOT (handle_insert_debugger_pointer_request (const QString&,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1760 int)));
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1761
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1762 connect (this,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1763 SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1764 editor_window,
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1765 SLOT (handle_delete_debugger_pointer_request (const QString&,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1766 int)));
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1767
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1768 connect (this,
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
1769 SIGNAL (update_breakpoint_marker_signal (bool, const QString&,
22599
51b395d24782 maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents: 22587
diff changeset
1770 int, const QString&)),
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1771 editor_window,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1772 SLOT (handle_update_breakpoint_marker_request (bool,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1773 const QString&,
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
1774 int,
22599
51b395d24782 maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents: 22587
diff changeset
1775 const QString&)));
16672
fd43631f09c2 Fix Qt error messages w/o QScintilla-dev installed (Bug #38878)
John Donoghue <john.donoghue@ieee.org>
parents: 16649
diff changeset
1776 #endif
16576
2754c5fd6ae0 keep focus in the command window after dbstop, dbstep, etc.
John W. Eaton <jwe@octave.org>
parents: 16572
diff changeset
1777
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1778 octave_link::post_event (this,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1779 &main_window::resize_command_window_callback);
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1780
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1781 configure_shortcuts ();
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1782 }
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1783 }
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1784
18309
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1785 void
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1786 main_window::handle_octave_ready ()
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1787 {
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1788 // actions after the startup files are executed
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1789 QSettings *settings = resource_manager::get_settings ();
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1790
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1791 QDir startup_dir = QDir (); // current octave dir after startup
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1792
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1793 if (settings)
18309
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1794 {
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1795 if (settings->value ("restore_octave_dir").toBool ())
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1796 {
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1797 // restore last dir from previous session
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1798 QStringList curr_dirs
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1799 = settings->value ("MainWindow/current_directory_list").toStringList ();
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1800 startup_dir
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1801 = QDir (curr_dirs.at (0)); // last dir in previous session
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1802 }
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1803 else if (! settings->value ("octave_startup_dir").toString ().isEmpty ())
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1804 {
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1805 // do not restore but there is a startup dir configured
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1806 startup_dir
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1807 = QDir (settings->value ("octave_startup_dir").toString ());
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1808 }
18309
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1809 }
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1810
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1811 if (! startup_dir.exists ())
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1812 {
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1813 // the configured startup dir does not exist, take actual one
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1814 startup_dir = QDir ();
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1815 }
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1816
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1817 set_current_working_directory (startup_dir.absolutePath ());
18833
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18823
diff changeset
1818
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1819 if (editor_window)
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1820 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1821 #if defined (HAVE_QSCINTILLA)
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1822 // Octave ready, determine whether to create an empty script.
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1823 // This can not be done when the editor is created because all functions
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1824 // must be known for the lexer's auto completion informations
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1825 editor_window->empty_script (true, false);
18833
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18823
diff changeset
1826 #endif
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1827 }
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1828
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1829 if (_start_gui)
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1830 focus_command_window (); // make sure that the command window has focus
18945
d2100cb2331a make sure the command has focus at startup
Torsten <ttl@justmail.de>
parents: 18944
diff changeset
1831
18309
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1832 }
024940bd5b77 gui: provide prefernces for the octave directory at startup
Torsten <ttl@justmail.de>
parents: 18288
diff changeset
1833
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1834 void
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1835 main_window::construct_octave_qt_link (void)
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1836 {
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
1837 _octave_qt_link = new octave_qt_link (this, m_app_context);
16485
8b783661e03f improve exit sequence for GUI
John W. Eaton <jwe@octave.org>
parents: 16484
diff changeset
1838
23092
0fed4c678795 additional restructuring of startup and shutdown
John W. Eaton <jwe@octave.org>
parents: 23070
diff changeset
1839 octave_link::connect_link (_octave_qt_link);
16479
7a71ea0b7ae9 eliminate event listener class
John W. Eaton <jwe@octave.org>
parents: 16478
diff changeset
1840
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1841 connect (_octave_qt_link, SIGNAL (confirm_shutdown_signal ()),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1842 this, SLOT (confirm_shutdown_octave ()));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1843
20243
ede7224d062f Allow copying a figure to clipboard even in --no-gui mode (bug #44886)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20186
diff changeset
1844 connect (_octave_qt_link,
ede7224d062f Allow copying a figure to clipboard even in --no-gui mode (bug #44886)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20186
diff changeset
1845 SIGNAL (copy_image_to_clipboard_signal (const QString&, bool)),
ede7224d062f Allow copying a figure to clipboard even in --no-gui mode (bug #44886)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20186
diff changeset
1846 this, SLOT (copy_image_to_clipboard (const QString&, bool)));
ede7224d062f Allow copying a figure to clipboard even in --no-gui mode (bug #44886)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20186
diff changeset
1847
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1848 if (_start_gui)
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1849 {
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1850 connect (_octave_qt_link,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1851 SIGNAL (set_workspace_signal
19970
f7846f0ea6db GUI: enable workspace update when debugging (Bug #44455)
John Donoghue
parents: 19949
diff changeset
1852 (bool, bool, const QString&, const QStringList&,
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1853 const QStringList&, const QStringList&,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1854 const QStringList&, const QIntList&)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1855 _workspace_model,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1856 SLOT (set_workspace
19970
f7846f0ea6db GUI: enable workspace update when debugging (Bug #44455)
John Donoghue
parents: 19949
diff changeset
1857 (bool, bool, const QString&, const QStringList&,
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1858 const QStringList&, const QStringList&,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1859 const QStringList&, const QIntList&)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1860
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1861 connect (_octave_qt_link, SIGNAL (clear_workspace_signal ()),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1862 _workspace_model, SLOT (clear_workspace ()));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1863
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1864 connect (_octave_qt_link, SIGNAL (change_directory_signal (QString)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1865 this, SLOT (change_directory (QString)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1866 connect (_octave_qt_link, SIGNAL (change_directory_signal (QString)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1867 file_browser_window, SLOT (update_octave_directory (QString)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1868 connect (_octave_qt_link, SIGNAL (change_directory_signal (QString)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1869 editor_window, SLOT (update_octave_directory (QString)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1870
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1871 connect (_octave_qt_link,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1872 SIGNAL (execute_command_in_terminal_signal (QString)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1873 this, SLOT (execute_command_in_terminal (QString)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1874
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1875 connect (_octave_qt_link,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1876 SIGNAL (set_history_signal (const QStringList&)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1877 history_window, SLOT (set_history (const QStringList&)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1878
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1879 connect (_octave_qt_link,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1880 SIGNAL (append_history_signal (const QString&)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1881 history_window, SLOT (append_history (const QString&)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1882
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1883 connect (_octave_qt_link,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1884 SIGNAL (clear_history_signal (void)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1885 history_window, SLOT (clear_history (void)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1886
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1887 connect (_octave_qt_link, SIGNAL (enter_debugger_signal ()),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1888 this, SLOT (handle_enter_debugger ()));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1889
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1890 connect (_octave_qt_link, SIGNAL (exit_debugger_signal ()),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1891 this, SLOT (handle_exit_debugger ()));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1892
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1893 connect (_octave_qt_link,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1894 SIGNAL (show_preferences_signal (void)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1895 this, SLOT (process_settings_dialog_request ()));
17010
c50ee84842a9 Add preferences and prefdir functions
John Donoghue <john.donoghue@ieee.org>
parents: 16970
diff changeset
1896
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1897 connect (_octave_qt_link,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1898 SIGNAL (edit_file_signal (const QString&)),
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
1899 _active_editor,
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1900 SLOT (handle_edit_file_request (const QString&)));
16424
ad052cdc89ad use signal for octave_link::edit_file
John W. Eaton <jwe@octave.org>
parents: 16423
diff changeset
1901
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1902 connect (_octave_qt_link,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1903 SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1904 this,
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1905 SLOT (handle_insert_debugger_pointer_request (const QString&,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1906 int)));
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1907
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1908 connect (_octave_qt_link,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1909 SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1910 this,
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1911 SLOT (handle_delete_debugger_pointer_request (const QString&,
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
1912 int)));
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1913
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1914 connect (_octave_qt_link,
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
1915 SIGNAL (update_breakpoint_marker_signal (bool, const QString&,
22599
51b395d24782 maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents: 22587
diff changeset
1916 int, const QString&)),
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1917 this,
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
1918 SLOT (handle_update_breakpoint_marker_request (bool,
22599
51b395d24782 maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents: 22587
diff changeset
1919 const QString&,
21158
65827e9cccb8 Gui support for enhancement of dbstop.
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21148
diff changeset
1920 int,
22599
51b395d24782 maint: strip tabs and trailing whitespace from C++ sources.
John W. Eaton <jwe@octave.org>
parents: 22587
diff changeset
1921 const QString&)));
19949
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1922
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1923 connect (_octave_qt_link,
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1924 SIGNAL (show_doc_signal (const QString &)),
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1925 this, SLOT (handle_show_doc (const QString &)));
857a8f018f53 set up octave_link when running with --no-gui option (bug #44116)
John W. Eaton <jwe@octave.org>
parents: 19945
diff changeset
1926 }
17920
5c3f22dd0bbb raise SIGINT in octave_interpreter instead of in QTerminal
John W. Eaton <jwe@octave.org>
parents: 17918
diff changeset
1927
21428
217e6e97085b Prevent race conditions in GUI and interpreter initialization (bug #47326)
Mike Miller <mtmiller@octave.org>
parents: 21396
diff changeset
1928 // Defer initializing and executing the interpreter until after the main
217e6e97085b Prevent race conditions in GUI and interpreter initialization (bug #47326)
Mike Miller <mtmiller@octave.org>
parents: 21396
diff changeset
1929 // window and QApplication are running to prevent race conditions
23119
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
1930 QTimer::singleShot (0, m_interpreter, SLOT (execute ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1931 }
16437
919796a440c6 use signal for changing directory
John W. Eaton <jwe@octave.org>
parents: 16432
diff changeset
1932
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1933 void
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1934 main_window::construct_menu_bar (void)
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1935 {
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1936 QMenuBar *menu_bar = menuBar ();
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1937
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1938 construct_file_menu (menu_bar);
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1939
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1940 construct_edit_menu (menu_bar);
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1941
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1942 construct_debug_menu (menu_bar);
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1943
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1944 construct_window_menu (menu_bar);
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1945
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1946 construct_help_menu (menu_bar);
17599
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
1947
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
1948 construct_news_menu (menu_bar);
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
1949
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1950 #if defined (HAVE_QSCINTILLA)
20989
98e75f952a36 add find files action also to the editor menu
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
1951 // call the editor to add actions which should also be available in the
98e75f952a36 add find files action also to the editor menu
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
1952 // editor's menu and tool bar
98e75f952a36 add find files action also to the editor menu
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
1953 QList<QAction*> shared_actions;
98e75f952a36 add find files action also to the editor menu
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
1954 shared_actions << _new_script_action
98e75f952a36 add find files action also to the editor menu
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
1955 << _new_function_action
98e75f952a36 add find files action also to the editor menu
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
1956 << _open_action
98e75f952a36 add find files action also to the editor menu
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
1957 << _find_files_action
98e75f952a36 add find files action also to the editor menu
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
1958 << _undo_action
98e75f952a36 add find files action also to the editor menu
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
1959 << _copy_action
98e75f952a36 add find files action also to the editor menu
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
1960 << _paste_action
98e75f952a36 add find files action also to the editor menu
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
1961 <<_select_all_action;
98e75f952a36 add find files action also to the editor menu
Torsten <ttl@justmail.de>
parents: 20986
diff changeset
1962 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
1963 #endif
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1964 }
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1965
18697
908523bd79b4 use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents: 18684
diff changeset
1966 QAction*
908523bd79b4 use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents: 18684
diff changeset
1967 main_window::add_action (QMenu *menu, const QIcon &icon, const QString &text,
18710
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
1968 const char *member, const QWidget *receiver)
18697
908523bd79b4 use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents: 18684
diff changeset
1969 {
18710
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
1970 QAction *a;
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
1971
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
1972 if (receiver)
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
1973 a = menu->addAction (icon, text, receiver, member);
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
1974 else
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
1975 a = menu->addAction (icon, text, this, member);
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
1976
18697
908523bd79b4 use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents: 18684
diff changeset
1977 addAction (a); // important for shortcut context
908523bd79b4 use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents: 18684
diff changeset
1978 a->setShortcutContext (Qt::ApplicationShortcut);
908523bd79b4 use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents: 18684
diff changeset
1979 return a;
908523bd79b4 use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents: 18684
diff changeset
1980 }
908523bd79b4 use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents: 18684
diff changeset
1981
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
1982 void
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
1983 main_window::disable_menu_shortcuts (bool disable)
18944
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
1984 {
23070
bef714f45999 maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents: 22755
diff changeset
1985 QHash<QMenu*, QStringList>::const_iterator i = _hash_menu_text.constBegin ();
bef714f45999 maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents: 22755
diff changeset
1986
bef714f45999 maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents: 22755
diff changeset
1987 while (i != _hash_menu_text.constEnd ())
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
1988 {
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
1989 i.key ()->setTitle (i.value ().at (disable));
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
1990 ++i;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
1991 }
18944
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
1992 }
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
1993
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
1994 QMenu*
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
1995 main_window::m_add_menu (QMenuBar *p, QString name)
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
1996 {
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
1997 QMenu *menu = p->addMenu (name);
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
1998
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
1999 QString base_name = name; // get a copy
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2000 // replace intended '&' ("&&") by a temp. string
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2001 base_name.replace ("&&","___octave_amp_replacement___");
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2002 // remove single '&' (shortcut)
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2003 base_name.remove ("&");
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2004 // restore intended '&'
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2005 base_name.replace ("___octave_amp_replacement___","&&");
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2006
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2007 // remember names with and without shortcut
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2008 _hash_menu_text[menu] = QStringList () << name << base_name;
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2009
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2010 return menu;
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2011 }
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2012
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2013 void
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2014 main_window::construct_file_menu (QMenuBar *p)
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2015 {
18944
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2016 QMenu *file_menu = m_add_menu (p, tr ("&File"));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2017
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2018 construct_new_menu (file_menu);
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2019
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2020 _open_action
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2021 = file_menu->addAction (resource_manager::icon ("document-open"),
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2022 tr ("Open..."));
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2023 _open_action->setShortcutContext (Qt::ApplicationShortcut);
19180
a748865bfafb improve some menu texts and tool tips (bug #43200)
Torsten <ttl@justmail.de>
parents: 18945
diff changeset
2024 _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
2025
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2026 #if defined (HAVE_QSCINTILLA)
16457
10edb6f1ae98 improve encapsulation of file editor window object
John W. Eaton <jwe@octave.org>
parents: 16456
diff changeset
2027 file_menu->addMenu (editor_window->get_mru_menu ());
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2028 #endif
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2029
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2030 file_menu->addSeparator ();
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2031
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2032 _load_workspace_action
18257
cae24b7cfaf4 minor fix of text strings and related translations (part of bug #41201)
Torsten <ttl@justmail.de>
parents: 18251
diff changeset
2033 = file_menu->addAction (tr ("Load Workspace..."));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2034
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2035 _save_workspace_action
18257
cae24b7cfaf4 minor fix of text strings and related translations (part of bug #41201)
Torsten <ttl@justmail.de>
parents: 18251
diff changeset
2036 = file_menu->addAction (tr ("Save Workspace As..."));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2037
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2038 file_menu->addSeparator ();
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2039
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2040 _exit_action = file_menu->addAction (tr ("Exit"));
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2041 _exit_action->setShortcutContext (Qt::ApplicationShortcut);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2042
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2043 connect (_open_action, SIGNAL (triggered ()),
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
2044 this, SLOT (request_open_file ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2045
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2046 connect (_load_workspace_action, SIGNAL (triggered ()),
16566
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
2047 this, SLOT (handle_load_workspace_request ()));
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
2048
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2049 connect (_save_workspace_action, SIGNAL (triggered ()),
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2050 this, SLOT (handle_save_workspace_request ()));
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2051
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2052 connect (_exit_action, SIGNAL (triggered ()),
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2053 this, SLOT (close ()));
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2054 }
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2055
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2056 void
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2057 main_window::construct_new_menu (QMenu *p)
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2058 {
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2059 QMenu *new_menu = p->addMenu (tr ("New"));
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2060
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2061 _new_script_action
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2062 = new_menu->addAction (resource_manager::icon ("document-new"),
18345
dfc6ef6ac455 some text improvements in the gui (#bug 41201)
Torsten <ttl@justmail.de>
parents: 18318
diff changeset
2063 tr ("New Script"));
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2064 _new_script_action->setShortcutContext (Qt::ApplicationShortcut);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2065
19180
a748865bfafb improve some menu texts and tool tips (bug #43200)
Torsten <ttl@justmail.de>
parents: 18945
diff changeset
2066 _new_function_action = new_menu->addAction (tr ("New Function..."));
17901
2c241092b47b use edit.m for creating a new function with the gui (bug #40502)
Torsten <ttl@justmail.de>
parents: 17899
diff changeset
2067 _new_function_action->setEnabled (true);
2c241092b47b use edit.m for creating a new function with the gui (bug #40502)
Torsten <ttl@justmail.de>
parents: 17899
diff changeset
2068 _new_function_action->setShortcutContext (Qt::ApplicationShortcut);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2069
19180
a748865bfafb improve some menu texts and tool tips (bug #43200)
Torsten <ttl@justmail.de>
parents: 18945
diff changeset
2070 _new_figure_action = new_menu->addAction (tr ("New Figure"));
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2071 _new_figure_action->setEnabled (true);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2072
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2073 connect (_new_script_action, SIGNAL (triggered ()),
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
2074 this, SLOT (request_new_script ()));
17901
2c241092b47b use edit.m for creating a new function with the gui (bug #40502)
Torsten <ttl@justmail.de>
parents: 17899
diff changeset
2075 connect (_new_function_action, SIGNAL (triggered ()),
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
2076 this, SLOT (request_new_function ()));
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
2077 connect (this, SIGNAL (new_file_signal (const QString&)),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
2078 _active_editor, SLOT (request_new_file (const QString&)));
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
2079 connect (this, SIGNAL (open_file_signal (const QString&)),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
2080 _active_editor, SLOT (request_open_file (const QString&)));
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
2081 connect (this,
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
2082 SIGNAL (open_file_signal (const QString&, const QString&, int)),
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
2083 _active_editor,
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
2084 SLOT (request_open_file (const QString&, const QString&, int)));
16566
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
2085
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2086 connect (_new_figure_action, SIGNAL (triggered ()),
16566
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
2087 this, SLOT (handle_new_figure_request ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2088 }
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2089
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2090 void
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2091 main_window::construct_edit_menu (QMenuBar *p)
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2092 {
18944
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2093 QMenu *edit_menu = m_add_menu (p, tr ("&Edit"));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2094
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2095 QKeySequence ctrl_shift = Qt::ControlModifier + Qt::ShiftModifier;
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2096
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2097 _undo_action
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2098 = edit_menu->addAction (resource_manager::icon ("edit-undo"), tr ("Undo"));
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
2099 _undo_action->setShortcutContext (Qt::ApplicationShortcut);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2100
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2101 edit_menu->addSeparator ();
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2102
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2103 _copy_action
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2104 = edit_menu->addAction (resource_manager::icon ("edit-copy"),
16649
de1f8e4b6b9b more copy/paste tweaks
John W. Eaton <jwe@octave.org>
parents: 16648
diff changeset
2105 tr ("Copy"), this, SLOT (copyClipboard ()));
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
2106 _copy_action->setShortcutContext (Qt::ApplicationShortcut);
17117
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2107
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2108 _paste_action
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2109 = edit_menu->addAction (resource_manager::icon ("edit-paste"),
16649
de1f8e4b6b9b more copy/paste tweaks
John W. Eaton <jwe@octave.org>
parents: 16648
diff changeset
2110 tr ("Paste"), this, SLOT (pasteClipboard ()));
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
2111 _paste_action->setShortcutContext (Qt::ApplicationShortcut);
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2112
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2113 _select_all_action
18555
2d5d0d86432e gui: Add select all menu (Bug #41797)
John Donoghue <john.donoghue@ieee.org>
parents: 18498
diff changeset
2114 = edit_menu->addAction (tr ("Select All"), this, SLOT (selectAll ()));
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
2115 _select_all_action->setShortcutContext (Qt::ApplicationShortcut);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2116
17117
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2117 _clear_clipboard_action
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2118 = edit_menu->addAction (tr ("Clear Clipboard"), this,
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2119 SLOT (clear_clipboard ()));
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2120
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2121 edit_menu->addSeparator ();
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2122
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20132
diff changeset
2123 _find_files_action
19908
4e15e8cb16ae gui: added icons menu items that have icons used elsewhere
John Donoghue
parents: 19907
diff changeset
2124 = edit_menu->addAction (resource_manager::icon ("edit-find"),
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
2125 tr ("Find Files..."));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2126
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2127 edit_menu->addSeparator ();
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2128
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2129 _clear_command_window_action
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2130 = edit_menu->addAction (tr ("Clear Command Window"));
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2131
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2132 _clear_command_history_action
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2133 = edit_menu->addAction (tr ("Clear Command History"));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2134
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2135 _clear_workspace_action
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2136 = edit_menu->addAction (tr ("Clear Workspace"));
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2137
20039
3538c2824dd8 GUI: Move preferences to edit menu (Bug #44725)
John Donoghue
parents: 19985
diff changeset
2138 edit_menu->addSeparator ();
3538c2824dd8 GUI: Move preferences to edit menu (Bug #44725)
John Donoghue
parents: 19985
diff changeset
2139
3538c2824dd8 GUI: Move preferences to edit menu (Bug #44725)
John Donoghue
parents: 19985
diff changeset
2140 _preferences_action
3538c2824dd8 GUI: Move preferences to edit menu (Bug #44725)
John Donoghue
parents: 19985
diff changeset
2141 = edit_menu->addAction (resource_manager::icon ("preferences-system"),
3538c2824dd8 GUI: Move preferences to edit menu (Bug #44725)
John Donoghue
parents: 19985
diff changeset
2142 tr ("Preferences..."));
3538c2824dd8 GUI: Move preferences to edit menu (Bug #44725)
John Donoghue
parents: 19985
diff changeset
2143
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2144 connect (_find_files_action, SIGNAL (triggered ()),
16519
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2145 this, SLOT (find_files ()));
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2146
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2147 connect (_clear_command_window_action, SIGNAL (triggered ()),
16514
db045633405c Added clear command window implementation to MainWindow Clear COmmand Window menu.
John Donoghue <john.donoghue@ieee.org>
parents: 16512
diff changeset
2148 this, SLOT (handle_clear_command_window_request ()));
db045633405c Added clear command window implementation to MainWindow Clear COmmand Window menu.
John Donoghue <john.donoghue@ieee.org>
parents: 16512
diff changeset
2149
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2150 connect (_clear_command_history_action, SIGNAL (triggered ()),
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2151 this, SLOT (handle_clear_history_request ()));
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2152
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2153 connect (_clear_workspace_action, SIGNAL (triggered ()),
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2154 this, SLOT (handle_clear_workspace_request ()));
17117
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2155
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2156 connect (_clipboard, SIGNAL (changed (QClipboard::Mode)),
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2157 this, SLOT (clipboard_has_changed (QClipboard::Mode)));
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2158 clipboard_has_changed (QClipboard::Clipboard);
20039
3538c2824dd8 GUI: Move preferences to edit menu (Bug #44725)
John Donoghue
parents: 19985
diff changeset
2159
3538c2824dd8 GUI: Move preferences to edit menu (Bug #44725)
John Donoghue
parents: 19985
diff changeset
2160 connect (_preferences_action, SIGNAL (triggered ()),
3538c2824dd8 GUI: Move preferences to edit menu (Bug #44725)
John Donoghue
parents: 19985
diff changeset
2161 this, SLOT (process_settings_dialog_request ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2162 }
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2163
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2164 QAction *
18697
908523bd79b4 use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents: 18684
diff changeset
2165 main_window::construct_debug_menu_item (const char *icon, const QString& item,
908523bd79b4 use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents: 18684
diff changeset
2166 const char *member)
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2167 {
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20132
diff changeset
2168 QAction *action = add_action (_debug_menu,
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
2169 resource_manager::icon (QString (icon)),
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2170 item, member);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2171
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2172 action->setEnabled (false);
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2173
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2174 #if defined (HAVE_QSCINTILLA)
16457
10edb6f1ae98 improve encapsulation of file editor window object
John W. Eaton <jwe@octave.org>
parents: 16456
diff changeset
2175 editor_window->debug_menu ()->addAction (action);
10edb6f1ae98 improve encapsulation of file editor window object
John W. Eaton <jwe@octave.org>
parents: 16456
diff changeset
2176 editor_window->toolbar ()->addAction (action);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2177 #endif
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2178
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2179 return action;
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2180 }
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2181
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2182 void
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2183 main_window::construct_debug_menu (QMenuBar *p)
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2184 {
18944
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2185 _debug_menu = m_add_menu (p, tr ("De&bug"));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2186
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2187 _debug_step_over = construct_debug_menu_item (
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
2188 "db-step", tr ("Step"),
18697
908523bd79b4 use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents: 18684
diff changeset
2189 SLOT (debug_step_over ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2190
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2191 _debug_step_into = construct_debug_menu_item (
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
2192 "db-step-in", tr ("Step In"),
18697
908523bd79b4 use shortcut manager for the debug menu
Torsten <ttl@justmail.de>
parents: 18684
diff changeset
2193 SLOT (debug_step_into ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2194
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2195 _debug_step_out = construct_debug_menu_item (
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2196 "db-step-out", tr ("Step Out"),
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
2197 SLOT (debug_step_out ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2198
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2199 _debug_continue = construct_debug_menu_item (
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2200 "db-cont", tr ("Continue"),
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
2201 SLOT (debug_continue ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2202
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2203 _debug_menu->addSeparator ();
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2204 #if defined (HAVE_QSCINTILLA)
16457
10edb6f1ae98 improve encapsulation of file editor window object
John W. Eaton <jwe@octave.org>
parents: 16456
diff changeset
2205 editor_window->debug_menu ()->addSeparator ();
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
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2208 _debug_quit = construct_debug_menu_item (
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
2209 "db-stop", tr ("Quit Debug Mode"),
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
2210 SLOT (debug_quit ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2211 }
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2212
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2213 QAction *
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2214 main_window::construct_window_menu_item (QMenu *p, const QString& item,
18707
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2215 bool checkable, QWidget *widget)
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2216 {
18707
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2217 QAction *action = p->addAction (QIcon (), item);
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2218
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2219 addAction (action); // important for shortcut context
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2220 action->setCheckable (checkable);
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2221 action->setShortcutContext (Qt::ApplicationShortcut);
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2222
18707
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2223 if (widget) // might be zero for editor_window
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2224 {
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2225 if (checkable)
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2226 {
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2227 // action for visibilty of dock widget
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2228 connect (action, SIGNAL (toggled (bool)),
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2229 widget, SLOT (setVisible (bool)));
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2230
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2231 connect (widget, SIGNAL (active_changed (bool)),
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2232 action, SLOT (setChecked (bool)));
18707
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2233 }
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2234 else
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2235 {
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2236 // action for focus of dock widget
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2237 connect (action, SIGNAL (triggered ()), widget, SLOT (focus ()));
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2238 }
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2239 }
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2240
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2241 return action;
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2242 }
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2243
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2244 void
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2245 main_window::construct_window_menu (QMenuBar *p)
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2246 {
18944
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2247 QMenu *window_menu = m_add_menu (p, tr ("&Window"));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2248
18707
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2249 _show_command_window_action = construct_window_menu_item
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2250 (window_menu, tr ("Show Command Window"), true, command_window);
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2251
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2252 _show_history_action = construct_window_menu_item
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2253 (window_menu, tr ("Show Command History"), true, history_window);
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2254
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2255 _show_file_browser_action = construct_window_menu_item
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2256 (window_menu, tr ("Show File Browser"), true, file_browser_window);
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2257
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2258 _show_workspace_action = construct_window_menu_item
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2259 (window_menu, tr ("Show Workspace"), true, workspace_window);
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2260
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2261 _show_editor_action = construct_window_menu_item
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2262 (window_menu, tr ("Show Editor"), true, editor_window);
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2263
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2264 _show_documentation_action = construct_window_menu_item
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2265 (window_menu, tr ("Show Documentation"), true, doc_browser_window);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2266
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2267 window_menu->addSeparator ();
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2268
18707
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2269 _command_window_action = construct_window_menu_item
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2270 (window_menu, tr ("Command Window"), false, command_window);
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2271
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2272 _history_action = construct_window_menu_item
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2273 (window_menu, tr ("Command History"), false, history_window);
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2274
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2275 _file_browser_action = construct_window_menu_item
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2276 (window_menu, tr ("File Browser"), false, file_browser_window);
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2277
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2278 _workspace_action = construct_window_menu_item
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2279 (window_menu, tr ("Workspace"), false, workspace_window);
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2280
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2281 _editor_action = construct_window_menu_item
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2282 (window_menu, tr ("Editor"), false, editor_window);
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2283
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2284 _documentation_action = construct_window_menu_item
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2285 (window_menu, tr ("Documentation"), false, doc_browser_window);
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2286
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2287 window_menu->addSeparator ();
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2288
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2289 _reset_windows_action = add_action (window_menu, QIcon (),
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2290 tr ("Reset Default Window Layout"), SLOT (reset_windows ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2291 }
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2292
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2293 void
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2294 main_window::construct_help_menu (QMenuBar *p)
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2295 {
18944
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2296 QMenu *help_menu = m_add_menu (p, tr ("&Help"));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2297
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2298 construct_documentation_menu (help_menu);
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2299
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2300 help_menu->addSeparator ();
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2301
18710
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2302 _report_bug_action = add_action (help_menu, QIcon (),
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2303 tr ("Report Bug"), SLOT (open_bug_tracker_page ()));
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2304
21568
3d60ed163b70 maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents: 21439
diff changeset
2305 _octave_packages_action = add_action (help_menu, QIcon (),
18710
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2306 tr ("Octave Packages"), SLOT (open_octave_packages_page ()));
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2307
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2308 _contribute_action = add_action (help_menu, QIcon (),
22211
6065bd58db2b use contribute/donate consistently in GUI (bug #44335)
Sahil Badyal <sbadyals@gmail.com>
parents: 22177
diff changeset
2309 tr ("Contribute"), SLOT (open_contribute_page ()));
18710
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2310
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2311 _developer_action = add_action (help_menu, QIcon (),
22211
6065bd58db2b use contribute/donate consistently in GUI (bug #44335)
Sahil Badyal <sbadyals@gmail.com>
parents: 22177
diff changeset
2312 tr ("Donate to Octave"), SLOT (open_donate_page ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2313
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2314 help_menu->addSeparator ();
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2315
18710
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2316 _about_octave_action = add_action (help_menu, QIcon (),
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2317 tr ("About Octave"), SLOT (show_about_octave ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2318 }
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2319
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2320 void
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2321 main_window::construct_documentation_menu (QMenu *p)
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2322 {
18710
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2323 QMenu *doc_menu = p->addMenu (tr ("Documentation"));
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2324
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2325 _ondisk_doc_action = add_action (doc_menu, QIcon (),
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2326 tr ("On Disk"), SLOT (focus ()), doc_browser_window);
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2327
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2328 _online_doc_action = add_action (doc_menu, QIcon (),
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2329 tr ("Online"), SLOT (open_online_documentation_page ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2330 }
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2331
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2332 void
17599
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
2333 main_window::construct_news_menu (QMenuBar *p)
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
2334 {
18944
b2c4d6d461f0 fix conflict between main and editor menus when using alt keys (bug #42659)
Torsten <ttl@justmail.de>
parents: 18840
diff changeset
2335 QMenu *news_menu = m_add_menu (p, tr ("&News"));
17599
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
2336
18711
9ef65c422f53 use shortcut manager for the main news menu
Torsten <ttl@justmail.de>
parents: 18710
diff changeset
2337 _release_notes_action = add_action (news_menu, QIcon (),
9ef65c422f53 use shortcut manager for the main news menu
Torsten <ttl@justmail.de>
parents: 18710
diff changeset
2338 tr ("Release Notes"), SLOT (display_release_notes ()));
9ef65c422f53 use shortcut manager for the main news menu
Torsten <ttl@justmail.de>
parents: 18710
diff changeset
2339
9ef65c422f53 use shortcut manager for the main news menu
Torsten <ttl@justmail.de>
parents: 18710
diff changeset
2340 _current_news_action = add_action (news_menu, QIcon (),
9ef65c422f53 use shortcut manager for the main news menu
Torsten <ttl@justmail.de>
parents: 18710
diff changeset
2341 tr ("Community News"), SLOT (load_and_display_community_news ()));
17599
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
2342 }
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
2343
f5950975a172 community news dock widget and other user info in GUI
John W. Eaton <jwe@octave.org>
parents: 17576
diff changeset
2344 void
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2345 main_window::construct_tool_bar (void)
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2346 {
19985
8f59e3cca4e7 remove undo-button from main toolbar and rename toolbar title
Torsten <ttl@justmail.de>
parents: 19983
diff changeset
2347 _main_tool_bar = addToolBar (tr ("Toolbar"));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2348
16525
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
2349 _main_tool_bar->setObjectName ("MainToolBar");
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
2350 _main_tool_bar->addAction (_new_script_action);
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
2351 _main_tool_bar->addAction (_open_action);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2352
16525
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
2353 _main_tool_bar->addSeparator ();
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2354
16525
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
2355 _main_tool_bar->addAction (_copy_action);
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
2356 _main_tool_bar->addAction (_paste_action);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2357
16525
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
2358 _main_tool_bar->addSeparator ();
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2359
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2360 _current_directory_combo_box = new QComboBox (this);
19846
72fe9df87fe8 improve scalability of gui objects (as discussed in bug #41938)
Torsten <ttl@justmail.de>
parents: 19803
diff changeset
2361 QFontMetrics fm = _current_directory_combo_box->fontMetrics ();
72fe9df87fe8 improve scalability of gui objects (as discussed in bug #41938)
Torsten <ttl@justmail.de>
parents: 19803
diff changeset
2362 _current_directory_combo_box->setFixedWidth (48*fm.averageCharWidth ());
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2363 _current_directory_combo_box->setEditable (true);
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2364 _current_directory_combo_box->setInsertPolicy (QComboBox::NoInsert);
16518
59dbdaeeea40 * main_window.cc(construct_tool_bar): code cleanup and tool tips for combo box
Torsten <ttl@justmail.de>
parents: 16514
diff changeset
2365 _current_directory_combo_box->setToolTip (tr ("Enter directory name"));
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2366 _current_directory_combo_box->setMaxVisibleItems (
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2367 current_directory_max_visible);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2368 _current_directory_combo_box->setMaxCount (current_directory_max_count);
19846
72fe9df87fe8 improve scalability of gui objects (as discussed in bug #41938)
Torsten <ttl@justmail.de>
parents: 19803
diff changeset
2369 QSizePolicy sizePol (QSizePolicy::Preferred, QSizePolicy::Preferred);
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2370 _current_directory_combo_box->setSizePolicy (sizePol);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2371
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2372 // addWidget takes ownership of the objects so there is no
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2373 // need to delete these upon destroying this main_window.
16525
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
2374 _main_tool_bar->addWidget (new QLabel (tr ("Current Directory: ")));
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
2375 _main_tool_bar->addWidget (_current_directory_combo_box);
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
2376 QAction *current_dir_up = _main_tool_bar->addAction (
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2377 resource_manager::icon ("go-up"),
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2378 tr ("One directory up"));
16525
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
2379 QAction *current_dir_search = _main_tool_bar->addAction (
19899
a8a5415b05cb new gui icons
Torsten <ttl@justmail.de>
parents: 19893
diff changeset
2380 resource_manager::icon ("folder"),
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2381 tr ("Browse directories"));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2382
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2383 connect (_current_directory_combo_box, SIGNAL (activated (QString)),
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2384 this, SLOT (set_current_working_directory (QString)));
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2385
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2386 connect (_current_directory_combo_box->lineEdit (), SIGNAL (returnPressed ()),
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2387 this, SLOT (accept_directory_line_edit ()));
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2388
16525
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
2389 connect (current_dir_search, SIGNAL (triggered ()),
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2390 this, SLOT (browse_for_directory ()));
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2391
16525
e192525236ad configurable size of toolbar icons
Torsten <ttl@justmail.de>
parents: 16519
diff changeset
2392 connect (current_dir_up, SIGNAL (triggered ()),
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2393 this, SLOT (change_directory_up ()));
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
2394
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
2395 connect (_undo_action, SIGNAL (triggered ()),
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
2396 this, SLOT (handle_undo_request ()));
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
2397 }
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
2398
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2399 void
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2400 main_window::save_workspace_callback (const std::string& file)
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2401 {
15420
1249a615c91b call built-in functions directly in GUI callbacks
John W. Eaton <jwe@octave.org>
parents: 15404
diff changeset
2402 Fsave (ovl (file));
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2403 }
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2404
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2405 void
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2406 main_window::load_workspace_callback (const std::string& file)
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2407 {
15420
1249a615c91b call built-in functions directly in GUI callbacks
John W. Eaton <jwe@octave.org>
parents: 15404
diff changeset
2408 Fload (ovl (file));
16504
49b059bf27c7 allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
2409
49b059bf27c7 allow loading files from file browser
John W. Eaton <jwe@octave.org>
parents: 16502
diff changeset
2410 octave_link::set_workspace (true, symbol_table::workspace_info ());
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2411 }
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2412
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2413 void
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2414 main_window::clear_workspace_callback (void)
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2415 {
15420
1249a615c91b call built-in functions directly in GUI callbacks
John W. Eaton <jwe@octave.org>
parents: 15404
diff changeset
2416 Fclear ();
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2417 }
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2418
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2419 void
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
2420 main_window::rename_variable_callback (const main_window::name_pair& names)
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
2421 {
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
2422 /* bool status = */ symbol_table::rename (names.first, names.second);
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
2423
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
2424 // if (status)
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2425 octave_link::set_workspace (true, symbol_table::workspace_info ());
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
2426
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
2427 // else
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
2428 // ; // we need an octave_link action that runs a GUI error option.
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
2429 }
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
2430
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
2431 void
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
2432 main_window::command_window_undo_callback (void)
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
2433 {
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21744
diff changeset
2434 octave::command_editor::undo ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21744
diff changeset
2435 octave::command_editor::redisplay ();
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
2436 }
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
2437
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
2438 void
16514
db045633405c Added clear command window implementation to MainWindow Clear COmmand Window menu.
John Donoghue <john.donoghue@ieee.org>
parents: 16512
diff changeset
2439 main_window::clear_command_window_callback (void)
db045633405c Added clear command window implementation to MainWindow Clear COmmand Window menu.
John Donoghue <john.donoghue@ieee.org>
parents: 16512
diff changeset
2440 {
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21744
diff changeset
2441 octave::command_editor::kill_full_line ();
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21744
diff changeset
2442 octave::command_editor::clear_screen ();
16514
db045633405c Added clear command window implementation to MainWindow Clear COmmand Window menu.
John Donoghue <john.donoghue@ieee.org>
parents: 16512
diff changeset
2443 }
db045633405c Added clear command window implementation to MainWindow Clear COmmand Window menu.
John Donoghue <john.donoghue@ieee.org>
parents: 16512
diff changeset
2444
db045633405c Added clear command window implementation to MainWindow Clear COmmand Window menu.
John Donoghue <john.donoghue@ieee.org>
parents: 16512
diff changeset
2445 void
16541
6afb29359968 set size of command window terminal at GUI startup
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
2446 main_window::resize_command_window_callback (void)
6afb29359968 set size of command window terminal at GUI startup
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
2447 {
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21744
diff changeset
2448 octave::command_editor::resize_terminal ();
16541
6afb29359968 set size of command window terminal at GUI startup
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
2449 }
6afb29359968 set size of command window terminal at GUI startup
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
2450
6afb29359968 set size of command window terminal at GUI startup
John W. Eaton <jwe@octave.org>
parents: 16539
diff changeset
2451 void
19302
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 19180
diff changeset
2452 main_window::set_screen_size_callback (const int_pair& sz)
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 19180
diff changeset
2453 {
21748
176536b15d68 use namespace for command_editor and command_history classes
John W. Eaton <jwe@octave.org>
parents: 21744
diff changeset
2454 octave::command_editor::set_screen_size (sz.first, sz.second);
19302
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 19180
diff changeset
2455 }
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 19180
diff changeset
2456
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 19180
diff changeset
2457 void
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2458 main_window::clear_history_callback (void)
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2459 {
16431
5982d469f79b use signal for setting, appending to, and clearing history widget
John W. Eaton <jwe@octave.org>
parents: 16426
diff changeset
2460 Fhistory (ovl ("-c"));
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2461 }
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2462
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2463 void
16566
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
2464 main_window::new_figure_callback (void)
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
2465 {
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
2466 Fbuiltin (ovl ("figure"));
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
2467 Fdrawnow ();
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
2468 }
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
2469
662a712b8fd5 partial menu bar cleanup
John W. Eaton <jwe@octave.org>
parents: 16565
diff changeset
2470 void
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2471 main_window::change_directory_callback (const std::string& directory)
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2472 {
15420
1249a615c91b call built-in functions directly in GUI callbacks
John W. Eaton <jwe@octave.org>
parents: 15404
diff changeset
2473 Fcd (ovl (directory));
20132
d7bea5b11fc3 only update file browser and dir selection box when on top-level (bug #44622)
Torsten <ttl@justmail.de>
parents: 20113
diff changeset
2474 _octave_qt_link->update_directory ();
15402
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2475 }
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2476
7f423c6111c6 refactor GUI event handling to use new event_queue class
John W. Eaton <jwe@octave.org>
parents: 15388
diff changeset
2477 void
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2478 main_window::find_files (const QString &start_dir)
16519
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2479 {
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2480
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2481 if (! find_files_dlg)
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2482 {
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2483 find_files_dlg = new find_files_dialog (this);
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2484
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2485 connect (find_files_dlg, SIGNAL (finished (int)),
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2486 this, SLOT (find_files_finished (int)));
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2487
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2488 connect (find_files_dlg, SIGNAL (dir_selected (const QString &)),
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2489 file_browser_window,
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2490 SLOT (set_current_directory (const QString&)));
16519
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2491
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2492 connect (find_files_dlg, SIGNAL (file_selected (const QString &)),
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2493 this, SLOT (open_file (const QString &)));
16519
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2494
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2495 find_files_dlg->setWindowModality (Qt::NonModal);
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2496 }
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2497
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2498 if (! find_files_dlg->isVisible ())
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2499 {
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2500 find_files_dlg->show ();
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2501 }
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2502
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2503 find_files_dlg->set_search_dir (start_dir);
16519
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2504
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2505 find_files_dlg->activateWindow ();
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2506
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2507 }
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2508
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2509 void
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17771
diff changeset
2510 main_window::find_files_finished (int)
16519
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2511 {
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2512
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2513 }
3e8fd0c479b4 Add find files implemtation to main window menu
John Donoghue <john.donoghue@ieee.org>
parents: 16518
diff changeset
2514
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2515 void
18717
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2516 main_window::configure_shortcuts ()
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2517 {
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2518 // file menu
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2519 shortcut_manager::set_shortcut (_open_action, "main_file:open_file");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2520 shortcut_manager::set_shortcut (_new_script_action, "main_file:new_file");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2521 shortcut_manager::set_shortcut (_new_function_action, "main_file:new_function");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2522 shortcut_manager::set_shortcut (_new_function_action, "main_file:new_figure");
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2523 shortcut_manager::set_shortcut (_load_workspace_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2524 "main_file:load_workspace");
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2525 shortcut_manager::set_shortcut (_save_workspace_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2526 "main_file:save_workspace");
18717
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2527 shortcut_manager::set_shortcut (_preferences_action, "main_file:preferences");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2528 shortcut_manager::set_shortcut (_exit_action,"main_file:exit");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2529
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2530 // edit menu
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2531 shortcut_manager::set_shortcut (_copy_action, "main_edit:copy");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2532 shortcut_manager::set_shortcut (_paste_action, "main_edit:paste");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2533 shortcut_manager::set_shortcut (_undo_action, "main_edit:undo");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2534 shortcut_manager::set_shortcut (_select_all_action, "main_edit:select_all");
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2535 shortcut_manager::set_shortcut (_clear_clipboard_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2536 "main_edit:clear_clipboard");
18717
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2537 shortcut_manager::set_shortcut (_find_files_action, "main_edit:find_in_files");
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2538 shortcut_manager::set_shortcut (_clear_command_history_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2539 "main_edit:clear_history");
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2540 shortcut_manager::set_shortcut (_clear_command_window_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2541 "main_edit:clear_command_window");
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2542 shortcut_manager::set_shortcut (_clear_workspace_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2543 "main_edit:clear_workspace");
18717
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2544
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2545 // debug menu
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2546 shortcut_manager::set_shortcut (_debug_step_over, "main_debug:step_over");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2547 shortcut_manager::set_shortcut (_debug_step_into, "main_debug:step_into");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2548 shortcut_manager::set_shortcut (_debug_step_out, "main_debug:step_out");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2549 shortcut_manager::set_shortcut (_debug_continue, "main_debug:continue");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2550 shortcut_manager::set_shortcut (_debug_quit, "main_debug:quit");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2551
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2552 // window menu
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2553 shortcut_manager::set_shortcut (_show_command_window_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2554 "main_window:show_command");
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2555 shortcut_manager::set_shortcut (_show_history_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2556 "main_window:show_history");
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2557 shortcut_manager::set_shortcut (_show_workspace_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2558 "main_window:show_workspace");
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2559 shortcut_manager::set_shortcut (_show_file_browser_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2560 "main_window:show_file_browser");
18717
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2561 shortcut_manager::set_shortcut (_show_editor_action, "main_window:show_editor");
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2562 shortcut_manager::set_shortcut (_show_documentation_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2563 "main_window:show_doc");
18717
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2564 shortcut_manager::set_shortcut (_command_window_action, "main_window:command");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2565 shortcut_manager::set_shortcut (_history_action, "main_window:history");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2566 shortcut_manager::set_shortcut (_workspace_action, "main_window:workspace");
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2567 shortcut_manager::set_shortcut (_file_browser_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2568 "main_window:file_browser");
18717
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2569 shortcut_manager::set_shortcut (_editor_action, "main_window:editor");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2570 shortcut_manager::set_shortcut (_documentation_action, "main_window:doc");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2571 shortcut_manager::set_shortcut (_reset_windows_action, "main_window:reset");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2572
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2573 // help menu
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2574 shortcut_manager::set_shortcut (_ondisk_doc_action, "main_help:ondisk_doc");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2575 shortcut_manager::set_shortcut (_online_doc_action, "main_help:online_doc");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2576 shortcut_manager::set_shortcut (_report_bug_action, "main_help:report_bug");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2577 shortcut_manager::set_shortcut (_octave_packages_action, "main_help:packages");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2578 shortcut_manager::set_shortcut (_contribute_action, "main_help:contribute");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2579 shortcut_manager::set_shortcut (_developer_action, "main_help:developer");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2580 shortcut_manager::set_shortcut (_about_octave_action, "main_help:about");
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2581
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2582 // news menu
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2583 shortcut_manager::set_shortcut (_release_notes_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2584 "main_news:release_notes");
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2585 shortcut_manager::set_shortcut (_current_news_action,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2586 "main_news:community_news");
18717
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2587 }
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2588
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2589 void
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2590 main_window::set_global_shortcuts (bool set_shortcuts)
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2591 {
18717
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2592 // this slot is called when the terminal gets/loses focus
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2593
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2594 // return if the user don't want to use readline shortcuts
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2595 if (! _prevent_readline_conflicts)
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2596 return;
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2597
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2598 if (set_shortcuts)
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2599 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2600 // terminal loses focus: set the global shortcuts
18717
f017240310fb disabling global shortcuts when terminal has focus as user preference
Torsten <ttl@justmail.de>
parents: 18711
diff changeset
2601 configure_shortcuts ();
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2602 }
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2603 else
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2604 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19855
diff changeset
2605 // terminal gets focus: disable some shortcuts
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2606 QKeySequence no_key = QKeySequence ();
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2607
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2608 // file menu
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2609 _open_action->setShortcut (no_key);
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2610 _new_script_action->setShortcut (no_key);
17901
2c241092b47b use edit.m for creating a new function with the gui (bug #40502)
Torsten <ttl@justmail.de>
parents: 17899
diff changeset
2611 _new_function_action->setShortcut (no_key);
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2612 _new_function_action->setShortcut (no_key);
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2613 _load_workspace_action->setShortcut (no_key);
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2614 _save_workspace_action->setShortcut (no_key);
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2615 _preferences_action->setShortcut (no_key);
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2616 _exit_action->setShortcut (no_key);
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2617
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2618 // edit menu
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2619 _select_all_action->setShortcut (no_key);
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2620 _clear_clipboard_action->setShortcut (no_key);
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2621 _find_files_action->setShortcut (no_key);
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2622 _clear_command_history_action->setShortcut (no_key);
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2623 _clear_command_window_action->setShortcut (no_key);
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
2624 _clear_workspace_action->setShortcut (no_key);
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2625
18707
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2626 // window menu
f31fde98c872 use shortcut manager for the window menu
Torsten <ttl@justmail.de>
parents: 18697
diff changeset
2627 _reset_windows_action->setShortcut (no_key);
18710
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2628
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2629 // help menu
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2630 _ondisk_doc_action->setShortcut (no_key);
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2631 _online_doc_action->setShortcut (no_key);
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2632 _report_bug_action->setShortcut (no_key);
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2633 _octave_packages_action->setShortcut (no_key);
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2634 _contribute_action->setShortcut (no_key);
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2635 _developer_action->setShortcut (no_key);
584b20e9112c use shortcut manager for the main help menu
Torsten <ttl@justmail.de>
parents: 18708
diff changeset
2636 _about_octave_action->setShortcut (no_key);
18711
9ef65c422f53 use shortcut manager for the main news menu
Torsten <ttl@justmail.de>
parents: 18710
diff changeset
2637
9ef65c422f53 use shortcut manager for the main news menu
Torsten <ttl@justmail.de>
parents: 18710
diff changeset
2638 // news menu
9ef65c422f53 use shortcut manager for the main news menu
Torsten <ttl@justmail.de>
parents: 18710
diff changeset
2639 _release_notes_action->setShortcut (no_key);
9ef65c422f53 use shortcut manager for the main news menu
Torsten <ttl@justmail.de>
parents: 18710
diff changeset
2640 _current_news_action->setShortcut (no_key);
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2641 }
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2642 }
17029
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
2643
20278
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2644 QList<octave_dock_widget *>
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2645 main_window::dock_widget_list ()
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2646 {
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2647 QList<octave_dock_widget *> list = QList<octave_dock_widget *> ();
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2648 list.append (static_cast<octave_dock_widget *> (command_window));
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2649 list.append (static_cast<octave_dock_widget *> (history_window));
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2650 list.append (static_cast<octave_dock_widget *> (file_browser_window));
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2651 list.append (static_cast<octave_dock_widget *> (doc_browser_window));
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2652 #if defined (HAVE_QSCINTILLA)
20278
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2653 list.append (static_cast<octave_dock_widget *> (editor_window));
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2654 #endif
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2655 list.append (static_cast<octave_dock_widget *> (workspace_window));
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2656 return list;
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2657 }
3b25741a9927 Avoid HAVE_ macro in header file.
John W. Eaton <jwe@octave.org>
parents: 20253
diff changeset
2658
17029
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
2659 void
19302
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 19180
diff changeset
2660 main_window::set_screen_size (int ht, int wd)
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 19180
diff changeset
2661 {
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 19180
diff changeset
2662 octave_link::post_event (this, &main_window::set_screen_size_callback,
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 19180
diff changeset
2663 int_pair (ht, wd));
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 19180
diff changeset
2664 }
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 19180
diff changeset
2665
37159a873c96 preserve text on Windows terminal resize (bug #41893; patch #8532)
John W. Eaton <jwe@octave.org>
parents: 19180
diff changeset
2666 void
17029
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
2667 main_window::handle_show_doc (const QString& file)
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
2668 {
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
2669 doc_browser_window->setVisible (true);
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
2670 emit show_doc_signal (file);
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
2671 }
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
2672
17117
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2673 void
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2674 main_window::clipboard_has_changed (QClipboard::Mode cp_mode)
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2675 {
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2676 if (cp_mode == QClipboard::Clipboard)
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2677 {
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2678 if (_clipboard->text ().isEmpty ())
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2679 {
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2680 _paste_action->setEnabled (false);
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2681 _clear_clipboard_action->setEnabled (false);
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2682 }
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2683 else
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2684 {
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2685 _paste_action->setEnabled (true);
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2686 _clear_clipboard_action->setEnabled (true);
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2687 }
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2688 }
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2689 }
17029
359c5ca795cd Display doc info pages using documentation browser when in GUI mode (Bug #39451)
John Donoghue <john.donoghue@ieee.org>
parents: 17010
diff changeset
2690
17117
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2691 void
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2692 main_window::clear_clipboard ()
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2693 {
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2694 _clipboard->clear (QClipboard::Clipboard);
47b504503a3f disable global paste action when clipboard is empty
Torsten <ttl@justmail.de>
parents: 17090
diff changeset
2695 }
23119
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
2696
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
2697 void
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
2698 main_window::interrupt_interpreter (void)
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
2699 {
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
2700 m_interpreter->interrupt ();
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
2701 }