annotate libgui/src/main-window.cc @ 29503:3bfec185c9e2

experimental command window widget with server loop This changeset provides a new experimental proof-of-concept cross-platform command window. It is intended to demonstrate how communication between the GUI command window and the Octave interpreter can work when the GUI is completely responsible for user input instead of having the interpreter wait for input inside readline. This initial implementation uses a simple text box for input and a separate text edit area for output. This design is not intended to be the final arrangement, but was easy to implement for demonstration purposes. These changes also make it possible to run the command-line version of Octave in a similar client-server mode with a function gathering input in one thread and the Octave intepreter running in another. The new command window is not intended to provide a general-purpose terminal window. So running something like "system ('emacs')" will not bring up an instance of Emacs running in the command window. This also means that it will no longer be possible to use an external output pager such as "less" in the command window. OTOH, it is also no longer necessary to fork and exec a separate process on some Unixy systems when Octave starts solely to give up the controlling terminal so that "less" will function properly. With the new terminal window, it is now possible to start Octave in command line mode and later open the GUI desktop window and then return to the command line when the GUI window is closed. Some things that need to be finished: * Merge the input and output windows so that command input and output are interleaved as they are in a normal command window. * Provide real readline command editing in the GUI command window and at the client-server CLI prompt. We can use the readline callback interface for the GUI and the normal readline interface for the CLI. With this design, the command widget and the CLI front end hold a copy of the command history. They do not need to communicate with the interpreter to navigate the command history. * Create interpreter_event messages for handling user input so that the interpreter can ask the GUI to gather user input for functions like "input". * Consider passing results back to the command widget as octave_value objects and allowing the command widget to format and display them instead of passing formatted text from the interpreter to the command widget. * Provide an output pager feature for the GUI command window? Maybe this feature is not necessary since we have scroll bars in the GUI and we can also have the GUI ask the user whether to display output if it is large. ChangeLog: * options-usage.h (usage_string, octave_print_verbose_usage_and_exit): Include --experimental-terminal-widget in list of options. (EXPERIMENTAL_TERMINAL_WIDGET_OPTION): New macro. (long_opts): Include "experimental-terminal-widget" in the list. * octave.h, octave.cc (cmdline_options::cmdline_options): Handle EXPERIMENTAL_TERMINAL_WIDGET_OPTION. (cmdline_options::m_experimental_terminal_widget): New data member. (application::experimental_terminal_widget, cmdline_options::experimental_terminal_widget interpreter::experimental_terminal_widget): New functions. * main.in.cc (fork_and_exec): New static variable. (main): Don't fork and exec if argv includes --experimental-terminal-widget. * interpreter-qobject.h, interpreter-qobject.cc (interpreter_qobject::pause, interpreter_qobject::stop, interpreter_qobject::resume): New functions. (interpreter_qobject::execute): Don't set prompt strings here if using the new terminal widget. If using the new terminal widget, call interpreter::shutdown and emit the shutdown_finished signal after interpreter::execute returns. (interpreter_qobject::shutdown): Don't do anything if using the new terminal widget. * main-window.h, main-window.cc (main_window::handle_octave_ready): Set interpreter prompt strings here if using the new terminal widget. (main_window::close_gui_signal): New signal. (main_window::closeEvent): If using new terminal widget and shutdown is confirmed, simply emit close_gui_signal. (main_window::construct_octave_qt_link): If using new terminal widget, connect qt_interpreter_events::interpreter_output_signal to the terminal_dock_widget::interpreter_output slot and the qt_interpreter_events::update_prompt_signal to the terminal_dock_widget::update_prompt slot. * octave-qobject.h, octave-qobject.cc (base_qobject::interpreter_pause, base_qobject::interpreter_stop, base_qobject::interpreter_resume): New functions. (base_qobject::base_qobject): If using new terminal widget: Don't connect interpreter_qobject::execution_finished signal to octave_qobject::handle_interpreter_execution_finished slot Don't connect octave_qobject::request_interpreter_shutdown signal to the interpreter_qobject::shutdown slot. Do connect the qt_interpreter_events::start_gui_signal signal to the octave_qobject::start_gui slot and simply reload settings and call qt_application::setQuitOnLastWindowClosed. There is no need to create the main window here. (base_qobject::exec): If using new terminal widget, wait for main thread to finish after qt_application::exec returns. (base_qojbect::experimental_terminal_widget, base_qobject::gui_running): New functions. (base_qojbect::start_gui, base_qojbect::close_gui, base_qojbect::interpreter_pause, base_qojbect::interpreter_stop, base_qojbect::interpreter_resume): New slots. (base_qojbect::handle_interpreter_execution_finished): Do nothing if using new terminal widget. * qt-application.cc (qt_application::start_gui_p): Return dummy value if using new terminal widget. * qt-interpreter-events.h, qt-interpreter-events.cc (qt_interpreter_events::start_gui, qt_interpreter_events::close_gui, qt_interpreter_events::interpreter_output, qt_interpreter_events::display_exception, qt_interpreter_events::update_prompt): New functions. (qt_interpreter_events::start_gui_signal, qt_interpreter_events::close_gui_signal, qt_interpreter_events::update_prompt_signal, qt_interpreter_events::interpreter_output_signal): New signals. * command-widget.h, command-widget.cc: New files. * libgui/src/module.mk: Update. * terminal-dock-widget.h, terminal-dock-widget.cc (terminal_dock_widget::m_experimental_terminal_widget): New data member. (terminal_dock_widget::terminal_dock_widget): Optionally create and use new terminal widget. If using new terminal widget, connect command_widget::interpreter_event signals to terminal_dock_widget::interpreter_event signals. (terminal_dock_widget::interpreter_output, terminal_dock_widget::update_prompt): New slots. (terminal_dock_widget::update_prompt_signal, terminal_dock_widget::interpreter_output_signal): New signals. * event-manager.h, event-manager.cc (Fdesktop): New function. (interpreter_events::start_gui, interpreter_events::close_gui, interpreter_events::update_prompt): New virtual functions. (interpreter_events::confirm_shutdown): Return true. (event_manager::start_gui, event_manager::close_gui, event_manager::update_prompt): New functions. * interpreter.h, interpreter.cc (interpreter::initialize): If using new terminal widget, only display startup message if not initially starting GUI. (class cli_input_reader): New class. (interpreter::experimental_terminal_widget, interpreter::get_line_and_eval): New functions. (interpreter::execute): If using new terminal widget, start GUI or command line reader and then enter server loop. * pt-eval.cc (tree_evaluator::server_loop): Reset parser at top of loop. also catch exit exception.
author John W. Eaton <jwe@octave.org>
date Thu, 25 Mar 2021 23:06:40 -0400
parents 34922160bda9
children 0b429d1a4974
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29147
diff changeset
3 // Copyright (C) 2011-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
27 # include "config.h"
15286
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15274
diff changeset
28 #endif
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15274
diff changeset
29
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
30 #include <utility>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
31
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
32 #include <QAction>
15257
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15204
diff changeset
33 #include <QApplication>
27648
2952471e29a7 eliminate global access to resource_manager in qterminal widget
John W. Eaton <jwe@octave.org>
parents: 27631
diff changeset
34 #include <QClipboard>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
35 #include <QDateTime>
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
36 #include <QDebug>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
37 #include <QDesktopServices>
16391
a695ee2dc17e * main-window.cc: Include <QDesktopWidget>
John W. Eaton <jwe@octave.org>
parents: 16386
diff changeset
38 #include <QDesktopWidget>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
39 #include <QFileDialog>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
40 #include <QIcon>
23385
41639665aa34 improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents: 23380
diff changeset
41 #include <QInputDialog>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
42 #include <QKeySequence>
15257
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15204
diff changeset
43 #include <QLabel>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
44 #include <QMenu>
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
45 #include <QMenuBar>
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
46 #include <QMessageBox>
14670
7fbea449737d Restructured menus, added toolbar and current directory line edit.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14669
diff changeset
47 #include <QStyle>
25956
2201f82db233 Add missing QStyleFactory header (Bug #54881)
John Donoghue
parents: 25944
diff changeset
48 #include <QStyleFactory>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
49 #include <QStyleFactory>
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
50 #include <QTextBrowser>
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
51 #include <QTextCodec>
17764
811b5a562680 Format release notes as preformatted text in the GUI (bug #40367)
Mike Miller <mtmiller@ieee.org>
parents: 17744
diff changeset
52 #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
53 #include <QThread>
21439
912b8828193b * main-window.cc: include QTimer header file
Mike Miller <mtmiller@octave.org>
parents: 21428
diff changeset
54 #include <QTimer>
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
55 #include <QToolBar>
16502
45ae1038ee89 allow renaming of variables in workspace viewer
John W. Eaton <jwe@octave.org>
parents: 16499
diff changeset
56
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
57 #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
58 # 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
59 #endif
27664
bd7decacf32e avoid unnecessary includes of gui-preference header files
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27653
diff changeset
60 #include "gui-preferences-cs.h"
27665
a1271c5b621a replace preference literals by symbolic constants for dock widgets
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27664
diff changeset
61 #include "gui-preferences-dw.h"
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27556
diff changeset
62 #include "gui-preferences-ed.h"
27671
61883a1a80a1 don't include gui-preferences-global.h in gui-preferences.h
John W. Eaton <jwe@octave.org>
parents: 27669
diff changeset
63 #include "gui-preferences-global.h"
27412
da1f59fe04b3 try to use consitent ordering for include files in libgui sources
John W. Eaton <jwe@octave.org>
parents: 27409
diff changeset
64 #include "gui-preferences-mw.h"
27613
deb8877f2c34 use symbolic constants for preferences key and default values in news reader
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
65 #include "gui-preferences-nr.h"
27818
fa0582694fda replace literal strings by symbolic constants for shortcut preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27805
diff changeset
66 #include "gui-preferences-sc.h"
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27602
diff changeset
67 #include "gui-settings.h"
27196
d993642352d0 rename octave_interpreter object in GUI
John W. Eaton <jwe@octave.org>
parents: 27194
diff changeset
68 #include "interpreter-qobject.h"
14707
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
69 #include "main-window.h"
27193
01e73e1664ff move news reader widget to separate file
John W. Eaton <jwe@octave.org>
parents: 27118
diff changeset
70 #include "news-reader.h"
27197
b8c0d5ad024f refactor and rename some qt application objects
John W. Eaton <jwe@octave.org>
parents: 27196
diff changeset
71 #include "octave-qobject.h"
14707
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
72 #include "settings-dialog.h"
18611
086093fbdc1a first implementation of a shortcut manager (bug #41217)
Torsten <ttl@justmail.de>
parents: 18575
diff changeset
73 #include "shortcut-manager.h"
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
74 #include "welcome-wizard.h"
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
75
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
76 #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
77 #include "cmd-edit.h"
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
78 #include "oct-env.h"
17939
16cf38c39915 display community news in simple window; check timestamp and serial number
John W. Eaton <jwe@octave.org>
parents: 17936
diff changeset
79 #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
80
19893
67cb2f421255 restore include statement removed in changeset c7c50030e76c
John W. Eaton <jwe@octave.org>
parents: 19882
diff changeset
81 #include "builtin-defun-decls.h"
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
82 #include "defaults.h"
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
83 #include "defun.h"
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23497
diff changeset
84 #include "interpreter-private.h"
23773
5ff24576b783 defer installing qt graphics toolkit until interpreter is ready
John W. Eaton <jwe@octave.org>
parents: 23721
diff changeset
85 #include "interpreter.h"
27396
930c0fbc003b move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents: 27393
diff changeset
86 #include "load-path.h"
23479
06bf3a0b08bf maint: Use "" instead of <> for our own include files.
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
87 #include "oct-map.h"
22089
c2c668b3051b use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
88 #include "octave.h"
25408
ce725103ebf1 Fallback to open.m for opening files in the gui file browser (bug #50543)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25407
diff changeset
89 #include "parse.h"
26117
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 26115
diff changeset
90 #include "syminfo.h"
24362
3fc24b792a24 avoid including symtab.h, symscope.h, or symrec.h unnecessarily
John W. Eaton <jwe@octave.org>
parents: 24361
diff changeset
91 #include "symscope.h"
23479
06bf3a0b08bf maint: Use "" instead of <> for our own include files.
John W. Eaton <jwe@octave.org>
parents: 23457
diff changeset
92 #include "utils.h"
15404
f52a62a6db3a eliminate copy and paste copyright info in GUI about info box
John W. Eaton <jwe@octave.org>
parents: 15402
diff changeset
93 #include "version.h"
23380
c319e6d737f2 Backed out changeset 7332287221a9
Torsten <mttl@mailbox.org>
parents: 23379
diff changeset
94
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
95 namespace octave
23119
3107d3717cc2 refactor and simplify interpreter startup in GUI
John W. Eaton <jwe@octave.org>
parents: 23092
diff changeset
96 {
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
97 static file_editor_interface *
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
98 create_default_editor (QWidget *p, base_qobject& oct_qobj)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
99 {
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
100 #if defined (HAVE_QSCINTILLA)
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
101 return new file_editor (p, oct_qobj);
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
102 #else
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
103 octave_unused_parameter (p);
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
104 octave_unused_parameter (oct_qobj);
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
105
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
106 return 0;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27042
diff changeset
107 #endif
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
108 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
109
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
110 main_window::main_window (base_qobject& oct_qobj)
27620
45bb5bbaf291 don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27613
diff changeset
111 : QMainWindow (), m_octave_qobj (oct_qobj),
26227
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
112 m_workspace_model (nullptr),
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
113 m_status_bar (nullptr), m_command_window (nullptr),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
114 m_history_window (nullptr), m_file_browser_window (nullptr),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
115 m_doc_browser_window (nullptr), m_editor_window (nullptr),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
116 m_workspace_window (nullptr), m_variable_editor_window (nullptr),
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
117 m_external_editor (new external_editor_interface (this, m_octave_qobj)),
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
118 m_active_editor (m_external_editor), m_settings_dlg (nullptr),
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
119 m_find_files_dlg (nullptr), m_set_path_dlg (nullptr),
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
120 m_release_notes_window (nullptr), m_community_news_window (nullptr),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
121 m_clipboard (QApplication::clipboard ()),
29084
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
122 m_prevent_readline_conflicts (true),
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
123 m_prevent_readline_conflicts_menu (false),
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
124 m_suppress_dbg_location (true),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
125 m_closing (false), m_file_encoding (QString ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
126 {
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
127 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
128
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
129 if (rmgr.is_first_run ())
25938
6fec0e305268 Backed out changeset 2ab0a9b66388
John W. Eaton <jwe@octave.org>
parents: 25937
diff changeset
130 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
131 // Before wizard.
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
132 m_octave_qobj.config_translators ();
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
133
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
134 welcome_wizard welcomeWizard (m_octave_qobj);
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
135
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
136 if (welcomeWizard.exec () == QDialog::Rejected)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
137 exit (1);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
138
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
139 // Install settings file.
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
140 rmgr.reload_settings ();
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
141 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
142 else
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
143 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
144 // Get settings file.
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
145 rmgr.reload_settings ();
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
146
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
147 // After settings.
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
148 m_octave_qobj.config_translators ();
25938
6fec0e305268 Backed out changeset 2ab0a9b66388
John W. Eaton <jwe@octave.org>
parents: 25937
diff changeset
149 }
6fec0e305268 Backed out changeset 2ab0a9b66388
John W. Eaton <jwe@octave.org>
parents: 25937
diff changeset
150
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
151 rmgr.update_network_settings ();
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
152
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
153 // We provide specific terminal capabilities, so ensure that
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
154 // TERM is always set appropriately.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
155
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
156 #if defined (OCTAVE_USE_WINDOWS_API)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
157 sys::env::putenv ("TERM", "cygwin");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
158 #else
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
159 sys::env::putenv ("TERM", "xterm");
25046
a4c687fec320 gui: set Qt Application and Desktop metadata for desktop integration (bug #53102)
Mike Miller <mtmiller@octave.org>
parents: 25042
diff changeset
160 #endif
a4c687fec320 gui: set Qt Application and Desktop metadata for desktop integration (bug #53102)
Mike Miller <mtmiller@octave.org>
parents: 25042
diff changeset
161
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
162 // FIXME: can we do this job when creating the shortcut manager?
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
163 // A quick look shows that it may require some coordination with the
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
164 // resource manager. Startup is complicated, but maybe we can make
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
165 // it simpler?
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
166 shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager ();
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
167 scmgr.init_data ();
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
168
28795
901a92f45ff0 provide access to worksapce model via base_object
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28788
diff changeset
169 m_workspace_model = m_octave_qobj.get_workspace_model ();
901a92f45ff0 provide access to worksapce model via base_object
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28788
diff changeset
170
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
171 construct_central_widget ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
172
29133
0d8e5f890a9b where possible, allow Qt widgets to delete their children
John W. Eaton <jwe@octave.org>
parents: 29096
diff changeset
173 m_status_bar = new QStatusBar (this);
29061
8a425e771aa7 use a led like indicator for the prfiler state
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29057
diff changeset
174 m_profiler_status_indicator = new led_indicator ();
8a425e771aa7 use a led like indicator for the prfiler state
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29057
diff changeset
175 QLabel *text = new QLabel (tr ("Profiler"));
8a425e771aa7 use a led like indicator for the prfiler state
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29057
diff changeset
176 m_status_bar->addPermanentWidget (text);
29040
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
177 m_status_bar->addPermanentWidget (m_profiler_status_indicator);
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
178
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
179 m_command_window = new terminal_dock_widget (this, m_octave_qobj);
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
180 m_history_window = new history_dock_widget (this, m_octave_qobj);
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
181 m_file_browser_window = new files_dock_widget (this, m_octave_qobj);
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
182 m_doc_browser_window = new documentation_dock_widget (this, m_octave_qobj);
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
183 m_editor_window = create_default_editor (this, m_octave_qobj);
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
184 m_variable_editor_window = new variable_editor (this, m_octave_qobj);
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
185 m_workspace_window = new workspace_view (this, m_octave_qobj);
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
186
27860
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
187 m_previous_dock = m_command_window;
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
188
27929
265b386f8b20 maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents: 27923
diff changeset
189 // Set active editor depending on editor window. If the latter is
27267
d75c7b4f7645 fix using external editor when built without qscintilla (regression from ceb508ea92ee)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27263
diff changeset
190 // not initialized (qscintilla not present), use the external editor.
d75c7b4f7645 fix using external editor when built without qscintilla (regression from ceb508ea92ee)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27263
diff changeset
191 if (m_editor_window)
29085
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
192 {
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
193 m_editor_menubar = m_editor_window->menubar ();
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
194 m_active_editor = m_editor_window;
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
195 }
27267
d75c7b4f7645 fix using external editor when built without qscintilla (regression from ceb508ea92ee)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27263
diff changeset
196 else
29085
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
197 {
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
198 m_editor_menubar = nullptr;
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
199 m_active_editor = m_external_editor;
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
200 }
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
201
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
202 #if defined (HAVE_QGUIAPPLICATION_SETDESKTOPFILENAME)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
203 QGuiApplication::setDesktopFileName ("org.octave.Octave.desktop");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
204 #endif
25938
6fec0e305268 Backed out changeset 2ab0a9b66388
John W. Eaton <jwe@octave.org>
parents: 25937
diff changeset
205
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
206 QApplication *qapp = m_octave_qobj.qapplication ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
207
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
208 m_default_style = qapp->style ()->objectName ();
26227
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
209
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
210 gui_settings *settings = rmgr.get_settings ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
211
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
212 bool connect_to_web = true;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
213 QDateTime last_checked;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
214 int serial = 0;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
215 m_active_dock = nullptr;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
216
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
217 if (settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
218 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
219 connect_to_web
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27671
diff changeset
220 = settings->value (nr_allow_connection).toBool ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
221
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
222 last_checked
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27671
diff changeset
223 = settings->value (nr_last_time).toDateTime ();
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27671
diff changeset
224
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27671
diff changeset
225 serial = settings->value (nr_last_news).toInt ();
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27671
diff changeset
226 m_default_encoding = settings->value (ed_default_enc).toString ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
227 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
228
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
229 QDateTime current = QDateTime::currentDateTime ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
230 QDateTime one_day_ago = current.addDays (-1);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
231
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
232 if (connect_to_web
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
233 && (! last_checked.isValid () || one_day_ago > last_checked))
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
234 load_and_display_community_news (serial);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
235
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
236 construct_octave_qt_link ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
237
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
238 // We have to set up all our windows, before we finally launch
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
239 // octave.
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
240
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
241 construct ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
242
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
243 read_settings ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
244
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
245 init_terminal_size ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
246
29199
0b18887bc997 simplify initialization of gui dock widgets
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29148
diff changeset
247 emit init_window_menu ();
0b18887bc997 simplify initialization of gui dock widgets
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29148
diff changeset
248
0b18887bc997 simplify initialization of gui dock widgets
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29148
diff changeset
249 #if defined (HAVE_QSCINTILLA)
0b18887bc997 simplify initialization of gui dock widgets
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29148
diff changeset
250 m_editor_window->enable_menu_shortcuts (false);
0b18887bc997 simplify initialization of gui dock widgets
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29148
diff changeset
251 #endif
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
252
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
253 focus_command_window ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
254 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
255
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
256 main_window::~main_window (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
257 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
258 delete m_release_notes_window;
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
259 delete m_community_news_window;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
260 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
261
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
262 bool main_window::command_window_has_focus (void) const
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
263 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
264 return m_command_window->has_focus ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
265 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
266
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
267 void main_window::focus_command_window (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
268 {
27281
0915fec3d3a9 prevent gui from catching focus when its desktop workspace becomes active
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27277
diff changeset
269 m_command_window->activate ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
270 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
271
27669
271b5cd640d7 Add functions to show GUI windows (bug #57213)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27665
diff changeset
272 void main_window::focus_window (const QString& win_name)
271b5cd640d7 Add functions to show GUI windows (bug #57213)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27665
diff changeset
273 {
271b5cd640d7 Add functions to show GUI windows (bug #57213)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27665
diff changeset
274 if (win_name == "command")
271b5cd640d7 Add functions to show GUI windows (bug #57213)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27665
diff changeset
275 m_command_window->activate ();
271b5cd640d7 Add functions to show GUI windows (bug #57213)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27665
diff changeset
276 else if (win_name == "history")
271b5cd640d7 Add functions to show GUI windows (bug #57213)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27665
diff changeset
277 m_history_window->activate ();
271b5cd640d7 Add functions to show GUI windows (bug #57213)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27665
diff changeset
278 else if (win_name == "workspace")
271b5cd640d7 Add functions to show GUI windows (bug #57213)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27665
diff changeset
279 m_workspace_window->activate ();
271b5cd640d7 Add functions to show GUI windows (bug #57213)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27665
diff changeset
280 else if (win_name == "filebrowser")
271b5cd640d7 Add functions to show GUI windows (bug #57213)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27665
diff changeset
281 m_file_browser_window->activate ();
271b5cd640d7 Add functions to show GUI windows (bug #57213)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27665
diff changeset
282 }
271b5cd640d7 Add functions to show GUI windows (bug #57213)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27665
diff changeset
283
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
284 bool main_window::confirm_shutdown (void)
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
285 {
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
286 bool closenow = true;
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
287
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
288 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
289 gui_settings *settings = rmgr.get_settings ();
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
290
27805
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27702
diff changeset
291 if (settings->value (global_prompt_to_exit.key,
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27702
diff changeset
292 global_prompt_to_exit.def).toBool ())
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
293 {
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
294 int ans = QMessageBox::question (this, tr ("Octave"),
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
295 tr ("Are you sure you want to exit Octave?"),
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
296 (QMessageBox::Ok
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
297 | QMessageBox::Cancel),
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
298 QMessageBox::Ok);
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
299
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
300 if (ans != QMessageBox::Ok)
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
301 closenow = false;
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
302 }
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
303
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
304 #if defined (HAVE_QSCINTILLA)
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
305 if (closenow)
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
306 closenow = m_editor_window->check_closing ();
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
307 #endif
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
308
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
309 return closenow;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
310 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
311
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
312 // catch focus changes and determine the active dock widget
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
313 void main_window::focus_changed (QWidget *, QWidget *new_widget)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
314 {
29085
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
315 // If there is no new widget or the new widget is a menu bar
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
316 // (when pressing <alt>), we can return immediately and reset the
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
317 // focus to the previous widget
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
318 if (! new_widget
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
319 || (new_widget == menuBar ())
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
320 || (new_widget == m_editor_menubar))
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
321 {
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
322 if (m_active_dock)
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
323 m_active_dock->setFocus ();
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
324
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
325 return;
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
326 }
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
327
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
328 octave_dock_widget *dock = nullptr;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
329 QWidget *w_new = new_widget; // get a copy of new focus widget
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
330 QWidget *start = w_new; // Save it as start of our search
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
331 int count = 0; // fallback to prevent endless loop
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
332
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
333 QList<octave_dock_widget *> w_list = dock_widget_list ();
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
334
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
335 while (w_new && w_new != m_main_tool_bar && count < 100)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
336 {
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
337 // Go through all dock widgets and check whether the current widget
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27860
diff changeset
338 // with focus is a child of one of them.
27676
ea7d36e9f197 use standard C++ range-based for loops instead of Qt foreach macro
John W. Eaton <jwe@octave.org>
parents: 27672
diff changeset
339 for (auto w : w_list)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
340 {
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
341 if (w->isAncestorOf (w_new))
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
342 dock = w;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
343 }
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
344
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
345 if (dock)
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
346 break;
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
347
27956
2310164737b3 fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents: 27041
diff changeset
348 // If not yet found (in case w_new is not a child of its dock widget),
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
349 // test next widget in the focus chain
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
350 w_new = qobject_cast<QWidget *> (w_new->previousInFocusChain ());
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
351
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
352 // Measures preventing an endless loop
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
353 if (w_new == start)
24772
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
354 break; // We have arrived where we began ==> exit loop
860860e2e69e fix focus change between dock widgets of gui
Torsten <mttl@mailbox.org>
parents: 24729
diff changeset
355 count++; // Limited number of trials
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
356 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
357
29084
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
358 // editor and terminal needs extra handling
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
359 octave_dock_widget *edit_dock_widget
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
360 = static_cast<octave_dock_widget *> (m_editor_window);
29084
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
361 octave_dock_widget *cmd_dock_widget
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
362 = static_cast<octave_dock_widget *> (m_command_window);
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
363
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
364 // if new dock has focus, emit signal and store active focus
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
365 // except editor changes to a dialog (dock=0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
366 if ((dock || m_active_dock != edit_dock_widget) && (dock != m_active_dock))
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
367 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
368 // signal to all dock widgets for updating the style
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
369 emit active_dock_changed (m_active_dock, dock);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
370
26555
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
371 if (dock)
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
372 {
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
373 QList<QDockWidget *> tabbed = tabifiedDockWidgets (dock);
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
374 if (tabbed.contains (m_active_dock))
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
375 dock->set_predecessor_widget (m_active_dock);
84e0e0b6493e * main-window.cc (focus_changed): prevent accessing null pointer (bug #55440)
Torsten <mttl@mailbox.org>
parents: 26376
diff changeset
376 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
377
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
378 // Check whether editor loses or gains focus
29084
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
379 int editor = 0;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
380 if (edit_dock_widget == dock)
29084
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
381 {
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
382 emit editor_focus_changed (true);
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
383 editor = 1;
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
384 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
385 else if (edit_dock_widget == m_active_dock)
29084
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
386 {
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
387 emit editor_focus_changed (false);
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
388 editor = -1;
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
389 }
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
390
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
391 // Check whether terminal loses or gains focus
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
392 int cmd_involved = 0;
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
393 if (cmd_dock_widget == dock)
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
394 cmd_involved = 1;
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
395 else if (cmd_dock_widget == m_active_dock)
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
396 cmd_involved = -1;
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
397
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
398 // If we have to take care of Alt+? accelerators of the main
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
399 // window, take result of test for terminal widget above
29084
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
400 int command = 0;
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
401 if (m_prevent_readline_conflicts_menu)
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
402 command = cmd_involved;
29084
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
403
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
404 // If editor or command gets/looses focus, disable/enable
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
405 // main menu accelerators (Alt + ?)
29084
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
406 if (editor || command)
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
407 {
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
408 int sum = editor + command;
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
409 if (sum > 0)
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
410 disable_menu_shortcuts (true);
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
411 else if (sum < 0)
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
412 disable_menu_shortcuts (false);
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
413 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
414
27860
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
415 if (m_active_dock)
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
416 m_previous_dock = m_active_dock;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
417 m_active_dock = dock;
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
418
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
419 // En-/disable global shortcuts (preventing conflicts with
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
420 // readline. Do it here because it relies on m_active_dock
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
421 if (cmd_involved)
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
422 configure_shortcuts ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
423 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
424 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
425
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
426 void main_window::request_reload_settings (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
427 {
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
428 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
429 gui_settings *settings = rmgr.get_settings ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
430
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
431 if (settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
432 emit settings_changed (settings);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
433 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
434
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
435 void main_window::report_status_message (const QString& statusMessage)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
436 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
437 m_status_bar->showMessage (statusMessage, 1000);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
438 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
439
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
440 void main_window::handle_save_workspace_request (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
441 {
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
442 // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved.
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
443 int opts = 0; // No options by default.
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
444 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
445 gui_settings *settings = rmgr.get_settings ();
28497
2813ac10ca1e force non-native file dialogs on Mac ignoring current user pref (bug #52840)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28351
diff changeset
446 if (! settings->value (global_use_native_dialogs).toBool ())
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
447 opts = QFileDialog::DontUseNativeDialog;
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
448
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
449 QString file
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
450 = QFileDialog::getSaveFileName (this, tr ("Save Workspace As"), ".",
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
451 nullptr, nullptr, QFileDialog::Option (opts));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
452
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
453 if (! file.isEmpty ())
25723
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
454 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
455 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
456 ([=] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
457 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
458 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
459
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
460 Fsave (interp, ovl (file.toStdString ()));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
461 });
25723
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
462 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
463 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
464
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
465 void main_window::handle_load_workspace_request (const QString& file_arg)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
466 {
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
467 // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved.
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
468 int opts = 0; // No options by default.
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
469 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
470 gui_settings *settings = rmgr.get_settings ();
28497
2813ac10ca1e force non-native file dialogs on Mac ignoring current user pref (bug #52840)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28351
diff changeset
471 if (! settings->value (global_use_native_dialogs).toBool ())
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
472 opts = QFileDialog::DontUseNativeDialog;
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
473
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
474 QString file = file_arg;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
475
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
476 if (file.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
477 file = QFileDialog::getOpenFileName (this, tr ("Load Workspace"), ".",
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
478 nullptr, nullptr, QFileDialog::Option (opts));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
479
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
480 if (! file.isEmpty ())
25723
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
481 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
482 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
483 ([=] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
484 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
485 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
486
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
487 Fload (interp, ovl (file.toStdString ()));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
488
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
489 tree_evaluator& tw = interp.get_evaluator ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
490
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
491 event_manager& xevmgr = interp.get_event_manager ();
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
492
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
493 xevmgr.set_workspace (true, tw.get_symbol_info ());
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
494 });
25723
22544083fe2c use common callback for workspace actions initiated by gui
Torsten <mttl@mailbox.org>
parents: 25703
diff changeset
495 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
496 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
497
25408
ce725103ebf1 Fallback to open.m for opening files in the gui file browser (bug #50543)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25407
diff changeset
498 void main_window::handle_open_any_request (const QString& file_arg)
ce725103ebf1 Fallback to open.m for opening files in the gui file browser (bug #50543)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25407
diff changeset
499 {
ce725103ebf1 Fallback to open.m for opening files in the gui file browser (bug #50543)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25407
diff changeset
500 if (! file_arg.isEmpty ())
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
501 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
502 std::string file = file_arg.toStdString ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
503
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
504 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
505 ([=] (interpreter& interp)
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
506 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
507 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
508
27405
646efbb5f407 avoid including builtin-defun-decls.h unless needed
John W. Eaton <jwe@octave.org>
parents: 27396
diff changeset
509 interp.feval ("open", ovl (file));
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
510
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
511 // Update the workspace since open.m may have loaded new
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
512 // variables.
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
513 tree_evaluator& tw = interp.get_evaluator ();
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
514
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
515 event_manager& xevmgr = interp.get_event_manager ();
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
516
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
517 xevmgr.set_workspace (true, tw.get_symbol_info ());
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
518 });
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
519 }
25408
ce725103ebf1 Fallback to open.m for opening files in the gui file browser (bug #50543)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25407
diff changeset
520 }
ce725103ebf1 Fallback to open.m for opening files in the gui file browser (bug #50543)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25407
diff changeset
521
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
522 void main_window::handle_clear_workspace_request (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
523 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
524 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
525 ([] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
526 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
527 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
528
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
529 Fclear (interp);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
530 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
531 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
532
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
533 void main_window::handle_clear_command_window_request (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
534 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
535 emit interpreter_event
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
536 ([] (void)
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
537 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
538 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
539
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
540 command_editor::kill_full_line ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
541 command_editor::clear_screen ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
542 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
543 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
544
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
545 void main_window::handle_clear_history_request (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
546 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
547 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
548 ([] (interpreter& interp)
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
549 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
550 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
551
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
552 history_system& history_sys = interp.get_history_system ();
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
553
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
554 history_sys.do_history (ovl ("-c"));
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
555 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
556 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
557
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
558 void main_window::handle_undo_request (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
559 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
560 if (command_window_has_focus ())
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
561 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
562 emit interpreter_event
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
563 ([] (void)
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
564 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
565 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
566
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
567 command_editor::undo ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
568 command_editor::redisplay ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
569 });
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
570 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
571 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
572 emit undo_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
573 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
574
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
575 void main_window::handle_rename_variable_request (const QString& old_name_arg,
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
576 const QString& new_name_arg)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
577
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
578 {
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
579 std::string old_name = old_name_arg.toStdString ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
580 std::string new_name = new_name_arg.toStdString ();
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
581
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
582 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
583 ([=] (interpreter& interp)
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
584 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
585 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
586
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
587 symbol_scope scope = interp.get_current_scope ();
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
588
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
589 if (scope)
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
590 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
591 scope.rename (old_name, new_name);
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
592
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
593 tree_evaluator& tw = interp.get_evaluator ();
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
594
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
595 event_manager& xevmgr = interp.get_event_manager ();
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
596
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
597 xevmgr.set_workspace (true, tw.get_symbol_info ());
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
598 }
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
599
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
600 // FIXME: if this action fails, do we need a way to display that info
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
601 // in the GUI?
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
602 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
603 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
604
27308
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
605 void main_window::modify_path (const octave_value_list& dir_list,
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
606 bool rm, bool subdirs)
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
607 {
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
608 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
609 ([=] (interpreter& interp)
27308
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
610 {
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
611 // INTERPRETER THREAD
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
612
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
613 octave_value_list paths = ovl ();
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
614
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
615 if (subdirs)
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
616 {
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
617 // Loop over all directories in order to get all subdirs
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
618 for (octave_idx_type i = 0; i < dir_list.length (); i++)
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
619 paths.append (Fgenpath (dir_list(i)));
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
620 }
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
621 else
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
622 paths = dir_list;
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
623
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
624 if (rm)
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
625 Frmpath (interp, paths);
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
626 else
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
627 Faddpath (interp, paths);
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
628 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
629 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
630
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
631 void main_window::edit_mfile (const QString& name, int line)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
632 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
633 handle_edit_mfile_request (name, QString (), QString (), line);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
634 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
635
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
636 void main_window::file_remove_proxy (const QString& o, const QString& n)
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
637 {
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
638 interpreter_qobject *interp_qobj = m_octave_qobj.interpreter_qobj ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
639
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
640 qt_interpreter_events *qt_link = interp_qobj->qt_link ();
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
641
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
642 // Wait for worker to suspend
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
643 qt_link->lock ();
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
644
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
645 // Close the file if opened
27039
32d9f57d7245 fix missing unlock of mutex when gui editor is not present (bug #56097)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
646 #if defined (HAVE_QSCINTILLA)
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
647 m_editor_window->handle_file_remove (o, n);
27041
6caf75200854 build: Silence unused parameter warning created in cset 43f6f02dd91c (bug #56097).
Rik <rik@octave.org>
parents: 27039
diff changeset
648 #else
6caf75200854 build: Silence unused parameter warning created in cset 43f6f02dd91c (bug #56097).
Rik <rik@octave.org>
parents: 27039
diff changeset
649 octave_unused_parameter (o);
6caf75200854 build: Silence unused parameter warning created in cset 43f6f02dd91c (bug #56097).
Rik <rik@octave.org>
parents: 27039
diff changeset
650 octave_unused_parameter (n);
27039
32d9f57d7245 fix missing unlock of mutex when gui editor is not present (bug #56097)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
651 #endif
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
652
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
653 // We are done: Unlock and wake the worker thread
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
654 qt_link->unlock ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
655 qt_link->wake_all ();
25742
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
656 }
d3c6de326bae close/reload editor tab when file is (re)moved in gui terminal (bug #43922)
Torsten <mttl@mailbox.org>
parents: 25723
diff changeset
657
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
658 void main_window::open_online_documentation_page (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
659 {
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
660 QDesktopServices::openUrl
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
661 (QUrl ("https://octave.org/doc/interpreter/index.html"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
662 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
663
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
664 void main_window::display_release_notes (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
665 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
666 if (! m_release_notes_window)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
667 {
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
668 std::string news_file = config::oct_etc_dir () + "/NEWS";
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
669
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
670 QString news;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
671
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
672 QFile *file = new QFile (QString::fromStdString (news_file));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
673 if (file->open (QFile::ReadOnly))
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
674 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
675 QTextStream *stream = new QTextStream (file);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
676 news = stream->readAll ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
677 if (! news.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
678 {
25251
0bc58956aa40 Escape '<', '>' in NEWS file before it is displayed as HTML in Release Notes window (bug #53642).
Rik <rik@octave.org>
parents: 25103
diff changeset
679 // Convert '<', '>' which would be interpreted as HTML
0bc58956aa40 Escape '<', '>' in NEWS file before it is displayed as HTML in Release Notes window (bug #53642).
Rik <rik@octave.org>
parents: 25103
diff changeset
680 news.replace ("<", "&lt;");
0bc58956aa40 Escape '<', '>' in NEWS file before it is displayed as HTML in Release Notes window (bug #53642).
Rik <rik@octave.org>
parents: 25103
diff changeset
681 news.replace (">", "&gt;");
0bc58956aa40 Escape '<', '>' in NEWS file before it is displayed as HTML in Release Notes window (bug #53642).
Rik <rik@octave.org>
parents: 25103
diff changeset
682 // Add HTML tags for pre-formatted text
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
683 news.prepend ("<pre>");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
684 news.append ("</pre>");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
685 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
686 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
687 news = (tr ("The release notes file '%1' is empty.")
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
688 . arg (QString::fromStdString (news_file)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
689 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
690 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
691 news = (tr ("The release notes file '%1' cannot be read.")
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
692 . arg (QString::fromStdString (news_file)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
693
29133
0d8e5f890a9b where possible, allow Qt widgets to delete their children
John W. Eaton <jwe@octave.org>
parents: 29096
diff changeset
694 // We want the window manager to give the release notes window
0d8e5f890a9b where possible, allow Qt widgets to delete their children
John W. Eaton <jwe@octave.org>
parents: 29096
diff changeset
695 // a title bar, so don't its parent to main_window. Do remember
0d8e5f890a9b where possible, allow Qt widgets to delete their children
John W. Eaton <jwe@octave.org>
parents: 29096
diff changeset
696 // to delete in the main_window destructor.
0d8e5f890a9b where possible, allow Qt widgets to delete their children
John W. Eaton <jwe@octave.org>
parents: 29096
diff changeset
697
0d8e5f890a9b where possible, allow Qt widgets to delete their children
John W. Eaton <jwe@octave.org>
parents: 29096
diff changeset
698 m_release_notes_window = new QWidget ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
699
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
700 QTextBrowser *browser = new QTextBrowser (m_release_notes_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
701 browser->setText (news);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
702
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
703 QVBoxLayout *vlayout = new QVBoxLayout;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
704 vlayout->addWidget (browser);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
705
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
706 m_release_notes_window->setLayout (vlayout);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
707 m_release_notes_window->setWindowTitle (tr ("Octave Release Notes"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
708
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
709 browser->document ()->adjustSize ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
710
29144
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
711 int win_x, win_y;
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
712 get_screen_geometry (&win_x, &win_y);
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
713
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
714 m_release_notes_window->resize (win_x*2/5, win_y*2/3);
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
715 m_release_notes_window->move (20, 20); // move to the top left corner
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
716 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
717
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
718 if (! m_release_notes_window->isVisible ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
719 m_release_notes_window->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
720 else if (m_release_notes_window->isMinimized ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
721 m_release_notes_window->showNormal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
722
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
723 m_release_notes_window->setWindowIcon (QIcon (m_release_notes_icon));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
724
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
725 m_release_notes_window->raise ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
726 m_release_notes_window->activateWindow ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
727 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
728
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
729 void main_window::load_and_display_community_news (int serial)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
730 {
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
731 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
732 gui_settings *settings = rmgr.get_settings ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
733
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
734 bool connect_to_web
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
735 = (settings
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27671
diff changeset
736 ? settings->value (nr_allow_connection).toBool ()
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
737 : true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
738
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
739 QString base_url = "https://octave.org";
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
740 QString page = "community-news.html";
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
741
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
742 QThread *worker_thread = new QThread;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
743
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
744 news_reader *reader = new news_reader (m_octave_qobj, base_url, page,
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
745 serial, connect_to_web);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
746
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
747 reader->moveToThread (worker_thread);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
748
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
749 connect (reader, SIGNAL (display_news_signal (const QString&)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
750 this, SLOT (display_community_news (const QString&)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
751
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
752 connect (worker_thread, SIGNAL (started (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
753 reader, SLOT (process (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
754
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
755 connect (reader, SIGNAL (finished (void)), worker_thread, SLOT (quit (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
756
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
757 connect (reader, SIGNAL (finished (void)), reader, SLOT (deleteLater (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
758
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
759 connect (worker_thread, SIGNAL (finished (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
760 worker_thread, SLOT (deleteLater (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
761
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
762 worker_thread->start ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
763 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
764
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
765 void main_window::display_community_news (const QString& news)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
766 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
767 if (! m_community_news_window)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
768 {
29133
0d8e5f890a9b where possible, allow Qt widgets to delete their children
John W. Eaton <jwe@octave.org>
parents: 29096
diff changeset
769 // We want the window manager to give the community news window
0d8e5f890a9b where possible, allow Qt widgets to delete their children
John W. Eaton <jwe@octave.org>
parents: 29096
diff changeset
770 // a title bar, so don't its parent to main_window. Do remember
0d8e5f890a9b where possible, allow Qt widgets to delete their children
John W. Eaton <jwe@octave.org>
parents: 29096
diff changeset
771 // to delete in the main_window destructor.
0d8e5f890a9b where possible, allow Qt widgets to delete their children
John W. Eaton <jwe@octave.org>
parents: 29096
diff changeset
772
0d8e5f890a9b where possible, allow Qt widgets to delete their children
John W. Eaton <jwe@octave.org>
parents: 29096
diff changeset
773 m_community_news_window = new QWidget ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
774
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
775 QTextBrowser *browser = new QTextBrowser (m_community_news_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
776
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
777 browser->setHtml (news);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
778 browser->setObjectName ("OctaveNews");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
779 browser->setOpenExternalLinks (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
780
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
781 QVBoxLayout *vlayout = new QVBoxLayout;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
782
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
783 vlayout->addWidget (browser);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
784
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
785 m_community_news_window->setLayout (vlayout);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
786 m_community_news_window->setWindowTitle (tr ("Octave Community News"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
787
29144
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
788 int win_x, win_y;
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
789 get_screen_geometry (&win_x, &win_y);
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
790
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
791 m_community_news_window->resize (win_x/2, win_y/2);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
792 m_community_news_window->move ((win_x - m_community_news_window->width ())/2,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
793 (win_y - m_community_news_window->height ())/2);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
794 }
25805
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
795 else
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
796 {
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
797 // Window already exists, just update the browser contents
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
798 QTextBrowser *browser
25819
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
799
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
800 = m_community_news_window->findChild<QTextBrowser *>("OctaveNews"
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
801 , Qt::FindDirectChildrenOnly
182e891789f5 fix libgui build failure with Qt 4.8
Mike Miller <mtmiller@octave.org>
parents: 25805
diff changeset
802 );
25805
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
803 if (browser)
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
804 browser->setHtml (news);
ae2c9f1427f0 update news window contents when community news are requeted a second time
Torsten <mttl@mailbox.org>
parents: 25742
diff changeset
805 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
806
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
807 if (! m_community_news_window->isVisible ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
808 m_community_news_window->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
809 else if (m_community_news_window->isMinimized ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
810 m_community_news_window->showNormal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
811
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
812 // same icon as release notes
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
813 m_community_news_window->setWindowIcon (QIcon (m_release_notes_icon));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
814
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
815 m_community_news_window->raise ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
816 m_community_news_window->activateWindow ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
817 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
818
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
819 void main_window::open_bug_tracker_page (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
820 {
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
821 QDesktopServices::openUrl (QUrl ("https://octave.org/bugs.html"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
822 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
823
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
824 void main_window::open_octave_packages_page (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
825 {
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
826 QDesktopServices::openUrl (QUrl ("https://octave.org/packages.html"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
827 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
828
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
829 void main_window::open_contribute_page (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
830 {
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
831 QDesktopServices::openUrl (QUrl ("https://octave.org/contribute.html"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
832 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
833
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
834 void main_window::open_donate_page (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
835 {
25024
3c817af70eed maint: use https for all Octave project URLs
Mike Miller <mtmiller@octave.org>
parents: 24792
diff changeset
836 QDesktopServices::openUrl (QUrl ("https://octave.org/donate.html"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
837 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
838
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
839 void main_window::process_settings_dialog_request (const QString& desired_tab)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
840 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
841 if (m_settings_dlg) // m_settings_dlg is a guarded pointer!
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
842 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
843 // here the dialog is still open and called once again
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
844 if (! desired_tab.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
845 m_settings_dlg->show_tab (desired_tab);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
846 return;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
847 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
848
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
849 m_settings_dlg = new settings_dialog (this, m_octave_qobj, desired_tab);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
850
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
851 connect (m_settings_dlg, SIGNAL (apply_new_settings (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
852 this, SLOT (request_reload_settings (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
853
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
854 m_settings_dlg->setModal (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
855 m_settings_dlg->setAttribute (Qt::WA_DeleteOnClose);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
856 m_settings_dlg->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
857 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
858
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
859 void main_window::show_about_octave (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
860 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
861 std::string message
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
862 = octave_name_version_copyright_copying_warranty_and_bugs (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
863
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
864 QMessageBox::about (this, tr ("About Octave"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
865 QString::fromStdString (message));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
866 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
867
29000
8a05763823d1 avoid possible infinite loop when default encoding is changed (bug #59331)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28837
diff changeset
868 void main_window::notice_settings (const gui_settings *settings,
8a05763823d1 avoid possible infinite loop when default encoding is changed (bug #59331)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28837
diff changeset
869 bool update_by_worker)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
870 {
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27602
diff changeset
871 if (! settings)
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27602
diff changeset
872 return;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
873
26227
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
874 // Get desired style from preferences or take the default one if
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
875 // the desired one is not found
27935
f1844e33f621 maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents: 27929
diff changeset
876 QString preferred_style = settings->value (global_style).toString ();
26227
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
877
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
878 if (preferred_style == global_style.def.toString ())
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
879 preferred_style = m_default_style;
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
880
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
881 QStyle *new_style = QStyleFactory::create (preferred_style);
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
882 if (new_style)
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
883 {
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
884 QApplication *qapp = m_octave_qobj.qapplication ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
885
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
886 qapp->setStyle (new_style);
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
887 }
26227
2355f66cf91d allow to select the gui style in the preferences dialog
Torsten <mttl@mailbox.org>
parents: 26117
diff changeset
888
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
889 // the widget's icons (when floating)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
890 QString icon_set
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27671
diff changeset
891 = settings->value (dw_icon_set).toString ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
892
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
893 int count = 0;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
894 int icon_set_found = 0; // default
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
895
27665
a1271c5b621a replace preference literals by symbolic constants for dock widgets
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27664
diff changeset
896 while (! dw_icon_set_names[count].name.isEmpty ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
897 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
898 // while not end of data
27665
a1271c5b621a replace preference literals by symbolic constants for dock widgets
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27664
diff changeset
899 if (dw_icon_set_names[count].name == icon_set)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
900 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
901 // data of desired icon set found
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
902 icon_set_found = count;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
903 break;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
904 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
905 count++;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
906 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
907
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
908 QString icon;
27676
ea7d36e9f197 use standard C++ range-based for loops instead of Qt foreach macro
John W. Eaton <jwe@octave.org>
parents: 27672
diff changeset
909 for (auto *widget : dock_widget_list ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
910 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
911 QString name = widget->objectName ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
912 if (! name.isEmpty ())
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
913 {
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27860
diff changeset
914 // if child has a name
27665
a1271c5b621a replace preference literals by symbolic constants for dock widgets
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27664
diff changeset
915 icon = dw_icon_set_names[icon_set_found].path; // prefix | octave-logo
a1271c5b621a replace preference literals by symbolic constants for dock widgets
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27664
diff changeset
916 if (dw_icon_set_names[icon_set_found].name != "NONE")
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
917 icon += name + ".png"; // add widget name and ext.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
918 widget->setWindowIcon (QIcon (icon));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
919 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
920 }
27665
a1271c5b621a replace preference literals by symbolic constants for dock widgets
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27664
diff changeset
921 if (dw_icon_set_names[icon_set_found].name != "NONE")
a1271c5b621a replace preference literals by symbolic constants for dock widgets
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27664
diff changeset
922 m_release_notes_icon = dw_icon_set_names[icon_set_found].path
25042
ba5af45bbfc4 documentation widget based on qt help engine (bug #53006)
Torsten <mttl@mailbox.org>
parents: 25024
diff changeset
923 + "ReleaseWidget.png";
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
924 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
925 m_release_notes_icon = ":/actions/icons/logo.png";
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
926
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27671
diff changeset
927 int size_idx = settings->value (global_icon_size).toInt ();
26058
ecd86b8b8979 use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents: 25994
diff changeset
928 size_idx = (size_idx > 0) - (size_idx < 0) + 1; // Make valid index from 0 to 2
ecd86b8b8979 use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents: 25994
diff changeset
929
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
930 QStyle *st = style ();
26058
ecd86b8b8979 use constants for icon size preferences instead of hard coded numbers
Torsten <mttl@mailbox.org>
parents: 25994
diff changeset
931 int icon_size = st->pixelMetric (global_icon_sizes[size_idx]);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
932 m_main_tool_bar->setIconSize (QSize (icon_size,icon_size));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
933
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
934 if (settings->value (global_status_bar).toBool ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
935 m_status_bar->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
936 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
937 m_status_bar->hide ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
938
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
939 m_prevent_readline_conflicts
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
940 = settings->value (sc_prevent_rl_conflicts).toBool ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
941
29084
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
942 m_prevent_readline_conflicts_menu
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
943 = settings->value (sc_prevent_rl_conflicts_menu).toBool ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
944
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
945 m_suppress_dbg_location
27849
28d7ec92bae6 replace prefs literals by symbolic constant in main window
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27818
diff changeset
946 = ! settings->value (cs_dbg_location).toBool ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
947
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
948 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
949 rmgr.update_network_settings ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
950
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
951 emit active_dock_changed (nullptr, m_active_dock); // update dock widget styles
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
952
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
953 configure_shortcuts ();
29084
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
954
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
955 bool do_disable_main_menu_shortcuts
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
956 = (m_active_dock == m_editor_window)
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
957 || (m_prevent_readline_conflicts_menu
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
958 && (m_active_dock == m_command_window));
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
959
2a70a068c4ab add option for using alt-modifer in command windows readline (bug #59478)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29068
diff changeset
960 disable_menu_shortcuts (do_disable_main_menu_shortcuts);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
961
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
962 // Check whether some octave internal preferences have to be updated
25702
bd30c6f8cfb7 update internal __mfile_encoding__ when gui default encoding changes (bug #54310)
Torsten <mttl@mailbox.org>
parents: 25700
diff changeset
963 QString new_default_encoding
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27671
diff changeset
964 = settings->value (ed_default_enc).toString ();
29000
8a05763823d1 avoid possible infinite loop when default encoding is changed (bug #59331)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28837
diff changeset
965 // Do not update internal pref only if a) this update was not initiated
8a05763823d1 avoid possible infinite loop when default encoding is changed (bug #59331)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28837
diff changeset
966 // by the worker and b) the pref has really changes
8a05763823d1 avoid possible infinite loop when default encoding is changed (bug #59331)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28837
diff changeset
967 if (! update_by_worker && (new_default_encoding != m_default_encoding))
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
968 update_default_encoding (new_default_encoding);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
969
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
970 // Set cursor blinking depending on the settings
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
971 // Cursor blinking: consider old terminal related setting if not yet set
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
972 // TODO: This pref. can be deprecated / removed if Qt adds support for
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
973 // getting the cursor blink preferences from all OS environments
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
974 bool cursor_blinking;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
975
27583
315c35e6037c use symbolic constants for command widget preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
976 if (settings->contains (global_cursor_blinking.key))
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27671
diff changeset
977 cursor_blinking = settings->value (global_cursor_blinking).toBool ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
978 else
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27671
diff changeset
979 cursor_blinking = settings->value (cs_cursor_blinking).toBool ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
980
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
981 if (cursor_blinking)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
982 QApplication::setCursorFlashTime (1000); // 1000 ms flash time
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
983 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
984 QApplication::setCursorFlashTime (0); // no flashing
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
985
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
986 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
987
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
988 void main_window::prepare_to_exit (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
989 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
990 // Find files dialog is constructed dynamically, not at time of main_window
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
991 // construction. Connecting it to qApp aboutToQuit signal would have
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27602
diff changeset
992 // caused it to run after gui_settings is deleted.
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
993 if (m_find_files_dlg)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
994 m_find_files_dlg->save_settings ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
995
27312
b9a436b0400e save and restore last geometry of load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27311
diff changeset
996 if (m_set_path_dlg)
b9a436b0400e save and restore last geometry of load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27311
diff changeset
997 m_set_path_dlg->save_settings ();
b9a436b0400e save and restore last geometry of load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27311
diff changeset
998
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
999 write_settings ();
29085
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
1000
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
1001 // No more active dock, otherwise, focus_changed would try to set
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
1002 // the focus to a dock widget that might not exist anymore
3b29d72645a9 fix alt-key stealing focus from current dock widget in gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29084
diff changeset
1003 m_active_dock = nullptr;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1004 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1005
27860
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
1006 void main_window::go_to_previous_widget (void)
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
1007 {
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
1008 m_previous_dock->activate ();
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
1009 }
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
1010
27409
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
1011 void main_window::update_octave_directory (const QString& dir)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1012 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1013 // Remove existing entry, if any, then add new directory at top and
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1014 // mark it as the current directory. Finally, update the file list
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1015 // widget.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1016
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1017 int index = m_current_directory_combo_box->findText (dir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1018
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1019 if (index >= 0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1020 m_current_directory_combo_box->removeItem (index);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1021
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1022 m_current_directory_combo_box->insertItem (0, dir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1023 m_current_directory_combo_box->setCurrentIndex (0);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1024 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1025
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1026 void main_window::browse_for_directory (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1027 {
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
1028 // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved.
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
1029 int opts = QFileDialog::ShowDirsOnly;
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1030 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1031 gui_settings *settings = rmgr.get_settings ();
28497
2813ac10ca1e force non-native file dialogs on Mac ignoring current user pref (bug #52840)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28351
diff changeset
1032 if (! settings->value (global_use_native_dialogs).toBool ())
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
1033 opts = QFileDialog::DontUseNativeDialog;
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
1034
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1035 QString dir
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1036 = QFileDialog::getExistingDirectory (this, tr ("Browse directories"), nullptr,
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
1037 QFileDialog::Option (opts));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1038
15626
1cc10ce368ea enable entering a new directory in the current directory combobox
Torsten <ttl@justmail.de>
parents: 15607
diff changeset
1039 set_current_working_directory (dir);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1040
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1041 // FIXME: on Windows systems, the command window freezes after the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1042 // previous actions. Forcing the focus appears to unstick it.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1043
24019
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
1044 focus_command_window ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1045 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1046
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1047 void main_window::set_current_working_directory (const QString& dir)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1048 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1049 // Change to dir if it is an existing directory.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1050
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1051 QString xdir = (dir.isEmpty () ? "." : dir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1052
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1053 QFileInfo fileInfo (xdir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1054
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1055 if (fileInfo.exists () && fileInfo.isDir ())
25703
7b4e99fbe9d4 include builtin functions without interpreter argument being into octave_cmd
Torsten <mttl@mailbox.org>
parents: 25702
diff changeset
1056 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1057 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
1058 ([=] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1059 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1060 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1061
27408
9b19eec60931 move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents: 27405
diff changeset
1062 interp.chdir (xdir.toStdString ());
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1063 });
25703
7b4e99fbe9d4 include builtin functions without interpreter argument being into octave_cmd
Torsten <mttl@mailbox.org>
parents: 25702
diff changeset
1064 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1065 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1066
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1067 void main_window::change_directory_up (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1068 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1069 set_current_working_directory ("..");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1070 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1071
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1072 // Slot that is called if return is pressed in the line edit of the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1073 // combobox to change to a new directory or a directory that is already
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1074 // in the drop down list.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1075
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1076 void main_window::accept_directory_line_edit (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1077 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1078 // Get new directory name, and change to it if it is new. Otherwise,
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27860
diff changeset
1079 // the combo box will trigger the "activated" signal to change to the
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1080 // directory.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1081
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1082 QString dir = m_current_directory_combo_box->currentText ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1083
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1084 int index = m_current_directory_combo_box->findText (dir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1085
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1086 if (index < 0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1087 set_current_working_directory (dir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1088 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1089
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1090 void main_window::execute_command_in_terminal (const QString& command)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1091 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1092 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
1093 ([=] (void)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1094 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1095 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1096
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1097 std::string pending_input = command_editor::get_current_line ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1098
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1099 command_editor::set_initial_input (pending_input);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1100 command_editor::replace_line (command.toStdString ());
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1101 command_editor::redisplay ();
27339
64289bf338da use separate variable for interrupting command editor event loop (bug #56738)
John W. Eaton <jwe@octave.org>
parents: 27335
diff changeset
1102 command_editor::interrupt_event_loop ();
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1103 command_editor::accept_line ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1104 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1105
27556
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27478
diff changeset
1106 focus_console_after_command ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1107 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1108
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1109 void main_window::run_file_in_terminal (const QFileInfo& info)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1110 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1111 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
1112 ([=] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1113 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1114 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1115
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1116 QString function_name = info.fileName ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1117 function_name.chop (info.suffix ().length () + 1);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1118 std::string file_path = info.absoluteFilePath ().toStdString ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1119
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1120 std::string pending_input = command_editor::get_current_line ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1121
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1122 if (valid_identifier (function_name.toStdString ()))
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1123 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1124 // Valid identifier: call as function with possibility to
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1125 // debug.
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1126
27396
930c0fbc003b move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents: 27393
diff changeset
1127 load_path& lp = interp.get_load_path ();
930c0fbc003b move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents: 27393
diff changeset
1128
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1129 std::string path = info.absolutePath ().toStdString ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1130
27396
930c0fbc003b move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents: 27393
diff changeset
1131 if (lp.contains_file_in_dir (file_path, path))
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1132 command_editor::replace_line (function_name.toStdString ());
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1133 }
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1134 else
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1135 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1136 // No valid identifier: use equivalent of Fsource (), no
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1137 // debug possible.
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1138
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1139 interp.source_file (file_path);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1140
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1141 command_editor::replace_line ("");
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1142 }
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1143
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1144 command_editor::set_initial_input (pending_input);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1145 command_editor::redisplay ();
27339
64289bf338da use separate variable for interrupting command editor event loop (bug #56738)
John W. Eaton <jwe@octave.org>
parents: 27335
diff changeset
1146 command_editor::interrupt_event_loop ();
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1147 command_editor::accept_line ();
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1148 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1149
27556
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27478
diff changeset
1150 focus_console_after_command ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1151 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1152
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1153 void main_window::handle_new_figure_request (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1154 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1155 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1156 ([] (interpreter& interp)
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1157 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1158 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1159
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1160 Fbuiltin (interp, ovl ("figure"));
27335
50216d7a2f6b eliminate static wrapper functions in gh_manager class
John W. Eaton <jwe@octave.org>
parents: 27312
diff changeset
1161 Fdrawnow (interp);
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1162 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1163 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1164
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1165 void main_window::handle_enter_debugger (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1166 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1167 setWindowTitle ("Octave (Debugging)");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1168
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1169 m_debug_continue->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1170 m_debug_step_into->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1171 m_debug_step_over->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1172 m_debug_step_out->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1173 m_debug_quit->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1174 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1175
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1176 void main_window::handle_exit_debugger (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1177 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1178 setWindowTitle ("Octave");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1179
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1180 m_debug_continue->setEnabled (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1181 m_debug_step_into->setEnabled (false);
29439
fe06fafb4cac fix en-/disabling some editor actions depending on file type (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29359
diff changeset
1182 m_debug_step_over->setEnabled (m_editor_has_tabs && m_editor_is_octave_file);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1183 m_debug_step_out->setEnabled (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1184 m_debug_quit->setEnabled (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1185 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1186
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1187 void main_window::debug_continue (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1188 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1189 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
1190 ([=] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1191 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1192 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1193
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1194 F__db_next_breakpoint_quiet__ (interp, ovl (m_suppress_dbg_location));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1195 Fdbcont (interp);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1196
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1197 command_editor::interrupt (true);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1198 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1199 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1200
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1201 void main_window::debug_step_into (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1202 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1203 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
1204 ([=] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1205 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1206 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1207
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1208 F__db_next_breakpoint_quiet__ (interp, ovl (m_suppress_dbg_location));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1209 Fdbstep (interp, ovl ("in"));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1210
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1211 command_editor::interrupt (true);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1212 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1213 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1214
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1215 void main_window::debug_step_over (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1216 {
26873
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1217 if (m_debug_quit->isEnabled ())
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1218 {
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1219 // We are in debug mode, just call dbstep.
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1220
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1221 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
1222 ([=] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1223 {
27393
efe72866b483 mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents: 27391
diff changeset
1224 // INTERPRETER THREAD
efe72866b483 mark all interpreter_event lambda functions with special comment
John W. Eaton <jwe@octave.org>
parents: 27391
diff changeset
1225
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1226 F__db_next_breakpoint_quiet__ (interp,
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1227 ovl (m_suppress_dbg_location));
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1228 Fdbstep (interp);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1229
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1230 command_editor::interrupt (true);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1231 });
26873
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1232 }
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1233 else
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1234 {
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1235 // Not in debug mode: "step into" the current editor file
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1236 emit step_into_file_signal ();
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
1237 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1238 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1239
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1240 void main_window::debug_step_out (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1241 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1242 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
1243 ([=] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1244 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1245 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1246
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1247 F__db_next_breakpoint_quiet__ (interp, ovl (m_suppress_dbg_location));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1248 Fdbstep (interp, ovl ("out"));
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1249
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1250 command_editor::interrupt (true);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1251 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1252 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1253
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1254 void main_window::debug_quit (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1255 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1256 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1257 ([] (interpreter& interp)
27255
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1258 {
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1259 // INTERPRETER THREAD
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1260
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1261 Fdbquit (interp);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1262
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1263 command_editor::interrupt (true);
420611c61298 eliminate octave_cmd classes
John W. Eaton <jwe@octave.org>
parents: 27243
diff changeset
1264 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1265 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1266
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1267 //
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1268 // Functions related to file editing
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1269 //
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1270 // These are moved from editor to here for also using them when octave
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1271 // is built without qscintilla
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1272 //
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1273 void main_window::request_open_file (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1274 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1275 // Open file isn't a file_editor_tab or editor function since the file
27929
265b386f8b20 maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents: 27923
diff changeset
1276 // might be opened in an external editor. Hence, functionality is here.
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1277
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1278 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1279 gui_settings *settings = rmgr.get_settings ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1280 bool is_internal = m_editor_window
27805
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27702
diff changeset
1281 && ! settings->value (global_use_custom_editor.key,
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27702
diff changeset
1282 global_use_custom_editor.def).toBool ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1283
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1284 // Create a NonModal message.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1285 QWidget *p = this;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1286 if (is_internal)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1287 p = m_editor_window;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1288 QFileDialog *fileDialog = new QFileDialog (p);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1289 fileDialog->setNameFilter (tr ("Octave Files (*.m);;All Files (*)"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1290
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1291 fileDialog->setAcceptMode (QFileDialog::AcceptOpen);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1292 fileDialog->setViewMode (QFileDialog::Detail);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1293 fileDialog->setFileMode (QFileDialog::ExistingFiles);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1294 fileDialog->setDirectory (m_current_directory_combo_box->itemText (0));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1295
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
1296 // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved.
28497
2813ac10ca1e force non-native file dialogs on Mac ignoring current user pref (bug #52840)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28351
diff changeset
1297 if (! settings->value (global_use_native_dialogs).toBool ())
26096
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
1298 fileDialog->setOption(QFileDialog::DontUseNativeDialog);
1002b49ce7b3 Make use of native file dialogs configurable (bug #54607).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26067
diff changeset
1299
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1300 connect (fileDialog, SIGNAL (filesSelected (const QStringList&)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1301 this, SLOT (request_open_files (const QStringList&)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1302
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1303 fileDialog->setWindowModality (Qt::NonModal);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1304 fileDialog->setAttribute (Qt::WA_DeleteOnClose);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1305 fileDialog->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1306 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1307
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1308 // Create a new script
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1309 void main_window::request_new_script (const QString& commands)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1310 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1311 emit new_file_signal (commands);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1312 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1313
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1314 // Create a new function and open it
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1315 void main_window::request_new_function (bool)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1316 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1317 bool ok;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1318 // Get the name of the new function: Parent of the input dialog is the
27929
265b386f8b20 maint: Use two spaces between sentences in code comments.
Rik <rik@octave.org>
parents: 27923
diff changeset
1319 // editor window or the main window. The latter is chosen, if a custom
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1320 // editor is used or qscintilla is not available
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1321 QWidget *p = m_editor_window;
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1322 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1323 gui_settings *settings = rmgr.get_settings ();
27805
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27702
diff changeset
1324 if (! p || settings->value (global_use_custom_editor.key,
dccc551aa83b replace literal strings by symbolic constants for global preferences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27702
diff changeset
1325 global_use_custom_editor.def).toBool ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1326 p = this;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1327 QString new_name = QInputDialog::getText (p, tr ("New Function"),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1328 tr ("New function name:\n"), QLineEdit::Normal, "", &ok);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1329
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1330 if (ok && new_name.length () > 0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1331 {
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27860
diff changeset
1332 // append suffix if it does not already exist
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1333 if (new_name.rightRef (2) != ".m")
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1334 new_name.append (".m");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1335 // check whether new files are created without prompt
27849
28d7ec92bae6 replace prefs literals by symbolic constant in main window
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27818
diff changeset
1336 if (! settings->value (ed_create_new_file).toBool ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1337 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1338 // no, so enable this settings and wait for end of new file loading
27849
28d7ec92bae6 replace prefs literals by symbolic constant in main window
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27818
diff changeset
1339 settings->setValue (ed_create_new_file.key, true);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1340 connect (m_editor_window, SIGNAL (file_loaded_signal (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1341 this, SLOT (restore_create_file_setting (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1342 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1343 // start the edit command
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1344 execute_command_in_terminal ("edit " + new_name);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1345 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1346 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1347
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1348 void main_window::handle_edit_mfile_request (const QString& fname,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1349 const QString& ffile,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1350 const QString& curr_dir,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1351 int line)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1352 {
27377
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1353 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
1354 ([=] (interpreter& interp)
27377
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1355 {
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1356 // INTERPRETER THREAD
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1357
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27860
diff changeset
1358 // Split possible subfunctions
27377
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1359 QStringList fcn_list = fname.split ('>');
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1360 QString fcn_name = fcn_list.at (0) + ".m";
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1361
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1362 // FIXME: could use symbol_exist directly, but we may also want
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1363 // to fix that to be a member function in the interpreter
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1364 // class?
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1365
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1366 // Is it a regular function within the search path? (Call Fexist)
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1367 octave_value_list fct = Fexist (interp, ovl (fname.toStdString ()),0);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1368 int type = fct (0).int_value ();
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1369
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1370 QString message = QString ();
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1371 QString filename = QString ();
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1372
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1373 switch (type)
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1374 {
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1375 case 3:
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1376 case 5:
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1377 case 103:
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1378 message = tr ("%1 is a built-in, compiled or inline\n"
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1379 "function and can not be edited.");
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1380 break;
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1381
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1382 case 2:
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1383 // FIXME: could use a load_path function directly.
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1384 octave_value_list file_path
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1385 = Ffile_in_loadpath (interp, ovl (fcn_name.toStdString ()), 0);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1386 if (file_path.length () > 0)
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1387 filename = QString::fromStdString (file_path (0).string_value ());
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1388 break;
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1389 }
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1390
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1391 if (filename.isEmpty () && message.isEmpty ())
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1392 {
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1393 // No error so far, but function still not known
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1394 // -> try directory of edited file
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1395 // get directory
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1396 QDir dir;
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1397 if (ffile.isEmpty ())
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1398 {
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1399 if (curr_dir.isEmpty ())
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1400 dir = QDir (m_current_directory_combo_box->itemText (0));
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1401 else
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1402 dir = QDir (curr_dir);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1403 }
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1404 else
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1405 dir = QDir (QFileInfo (ffile).canonicalPath ());
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1406
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1407 QFileInfo file = QFileInfo (dir, fcn_name);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1408 if (file.exists ())
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1409 filename = file.canonicalFilePath (); // local file exists
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1410 else
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1411 {
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1412 // local file does not exist -> try private directory
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1413 file = QFileInfo (ffile);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1414 file = QFileInfo (QDir (file.canonicalPath () + "/private"),
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1415 fcn_name);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1416 if (file.exists ())
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1417 filename = file.canonicalFilePath (); // private function exists
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1418 else
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1419 message = tr ("Can not find function %1"); // no file found
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1420
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1421 }
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1422 }
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1423
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1424 if (! message.isEmpty ())
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1425 {
27653
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
1426 emit warning_function_not_found_signal (message.arg (fname));
27377
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1427 return;
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1428 }
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1429
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1430 if (! filename.endsWith (".m"))
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1431 filename.append (".m");
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1432
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1433 // default encoding
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1434 emit open_file_signal (filename, QString (), line);
5ca84fb30205 use event manager to handle two more interpreter actions in GUI
John W. Eaton <jwe@octave.org>
parents: 27375
diff changeset
1435 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1436 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1437
27653
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
1438 void main_window::warning_function_not_found (const QString& message)
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
1439 {
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
1440 QMessageBox *msgBox = new QMessageBox (QMessageBox::Critical,
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
1441 tr ("Octave Editor"),
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
1442 message, QMessageBox::Ok, this);
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
1443 msgBox->setWindowModality (Qt::NonModal);
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
1444 msgBox->setAttribute (Qt::WA_DeleteOnClose);
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
1445 msgBox->show ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1446 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1447
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1448 void main_window::handle_insert_debugger_pointer_request (const QString& file,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1449 int line)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1450 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1451 bool cmd_focus = command_window_has_focus ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1452
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1453 emit insert_debugger_pointer_signal (file, line);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1454
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1455 if (cmd_focus)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1456 focus_command_window ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1457 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1458
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1459 void main_window::handle_delete_debugger_pointer_request (const QString& file,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1460 int line)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1461 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1462 bool cmd_focus = command_window_has_focus ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1463
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1464 emit delete_debugger_pointer_signal (file, line);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1465
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1466 if (cmd_focus)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1467 focus_command_window ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1468 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1469
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1470 void main_window::handle_update_breakpoint_marker_request (bool insert,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1471 const QString& file,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1472 int line,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1473 const QString& cond)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1474 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1475 bool cmd_focus = command_window_has_focus ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1476
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1477 emit update_breakpoint_marker_signal (insert, file, line, cond);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1478
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1479 if (cmd_focus)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1480 focus_command_window ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1481 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1482
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1483 void main_window::read_settings (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1484 {
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1485 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1486 gui_settings *settings = rmgr.get_settings ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1487
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1488 if (! settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1489 {
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27602
diff changeset
1490 qDebug ("Error: gui_settings pointer from resource manager is NULL.");
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1491 return;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1492 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1493
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1494 set_window_layout (settings);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1495
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1496 // restore the list of the last directories
27849
28d7ec92bae6 replace prefs literals by symbolic constant in main window
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27818
diff changeset
1497 QStringList curr_dirs = settings->value (mw_dir_list).toStringList ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1498 for (int i=0; i < curr_dirs.size (); i++)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1499 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1500 m_current_directory_combo_box->addItem (curr_dirs.at (i));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1501 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1502 emit settings_changed (settings);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1503 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1504
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1505 void main_window::init_terminal_size (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1506 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1507 emit init_terminal_size_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1508 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1509
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27602
diff changeset
1510 void main_window::set_window_layout (gui_settings *settings)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1511 {
29450
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
1512 // For resetting from some inconsistent state, first reset layout
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
1513 // without saving or showing it
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
1514 do_reset_windows (true, false);
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
1515
26299
c95884eed1cf make restoring gui more robust to changes of desktop size (bug #53207)
Torsten <mttl@mailbox.org>
parents: 26277
diff changeset
1516 // Restore main window state and geometry from settings file or, in case
29147
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1517 // of an error (no pref values yet), from the default layout.
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1518 if (! restoreGeometry (settings->value (mw_geometry).toByteArray ()))
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1519 {
29147
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1520 do_reset_windows (true);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1521 return;
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1522 }
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1523
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1524 if (isMaximized())
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1525 {
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1526 setGeometry( QApplication::desktop ()->availableGeometry (this));
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1527 }
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1528
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1529 if (! restoreState (settings->value (mw_state).toByteArray ()))
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1530 {
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1531 do_reset_windows (true);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1532 return;
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1533 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1534
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1535 // Restore the geometry of all dock-widgets
27676
ea7d36e9f197 use standard C++ range-based for loops instead of Qt foreach macro
John W. Eaton <jwe@octave.org>
parents: 27672
diff changeset
1536 for (auto *widget : dock_widget_list ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1537 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1538 QString name = widget->objectName ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1539
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1540 if (! name.isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1541 {
26307
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1542 bool floating = false;
a21f58c5e573 fix resetting gui window layout
Torsten <mttl@mailbox.org>
parents: 26299
diff changeset
1543 bool visible = true;
29147
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1544
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1545 floating = settings->value
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1546 (dw_is_floating.key.arg (name), dw_is_floating.def).toBool ();
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1547 visible = settings->value
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1548 (dw_is_visible.key.arg (name), dw_is_visible.def).toBool ();
17899
14c427b5c5c1 Restore geometry of floating widgets after restart in windows (bug #40485)
Torsten <ttl@justmail.de>
parents: 17890
diff changeset
1549
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1550 // If floating, make window from widget.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1551 if (floating)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1552 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1553 widget->make_window ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1554
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1555 if (visible)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1556 {
29147
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1557 if (settings->value (dw_is_minimized.key.arg (name),
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
1558 dw_is_minimized.def).toBool ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1559 widget->showMinimized ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1560 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1561 widget->setVisible (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1562 }
29459
4ae7e80fb7c5 prevent floating widgets from reopening after restart (bug #60279)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29450
diff changeset
1563 else
4ae7e80fb7c5 prevent floating widgets from reopening after restart (bug #60279)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29450
diff changeset
1564 widget->setVisible (false);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1565 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1566 else // not floating
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1567 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1568 if (! widget->parent ()) // should not be floating but is
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1569 widget->make_widget (false); // no docking, just reparent
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1570
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1571 widget->make_widget ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1572 widget->setVisible (visible); // not floating -> show
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1573 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1574 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1575 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1576
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1577 show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1578 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1579
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1580 void main_window::write_settings (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1581 {
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1582 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1583 gui_settings *settings = rmgr.get_settings ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1584 if (! settings)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1585 {
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27602
diff changeset
1586 qDebug ("Error: gui_settings pointer from resource manager is NULL.");
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1587 return;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1588 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1589
27562
d7876110e854 use symbolic preference keys if available
John W. Eaton <jwe@octave.org>
parents: 27560
diff changeset
1590 settings->setValue (mw_geometry.key, saveGeometry ());
d7876110e854 use symbolic preference keys if available
John W. Eaton <jwe@octave.org>
parents: 27560
diff changeset
1591 settings->setValue (mw_state.key, saveState ());
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27860
diff changeset
1592 // write the list of recently used directories
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1593 QStringList curr_dirs;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1594 for (int i=0; i<m_current_directory_combo_box->count (); i++)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1595 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1596 curr_dirs.append (m_current_directory_combo_box->itemText (i));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1597 }
27849
28d7ec92bae6 replace prefs literals by symbolic constant in main window
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27818
diff changeset
1598 settings->setValue (mw_dir_list.key, curr_dirs);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1599 settings->sync ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1600 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1601
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1602 void main_window::copyClipboard (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1603 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1604 if (m_current_directory_combo_box->hasFocus ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1605 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1606 QLineEdit *edit = m_current_directory_combo_box->lineEdit ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1607 if (edit && edit->hasSelectedText ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1608 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1609 QClipboard *clipboard = QApplication::clipboard ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1610 clipboard->setText (edit->selectedText ());
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1611 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1612 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1613 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1614 emit copyClipboard_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1615 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1616
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1617 void main_window::pasteClipboard (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1618 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1619 if (m_current_directory_combo_box->hasFocus ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1620 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1621 QLineEdit *edit = m_current_directory_combo_box->lineEdit ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1622 QClipboard *clipboard = QApplication::clipboard ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1623 QString str = clipboard->text ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1624 if (edit && str.length () > 0)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1625 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1626 edit->insert (str);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1627 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1628 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1629 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1630 emit pasteClipboard_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1631 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1632
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1633 void main_window::selectAll (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1634 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1635 if (m_current_directory_combo_box->hasFocus ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1636 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1637 QLineEdit *edit = m_current_directory_combo_box->lineEdit ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1638 if (edit)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1639 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1640 edit->selectAll ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1641 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1642 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1643 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1644 emit selectAll_signal ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1645 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1646
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1647 void main_window::handle_show_doc (const QString& file)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1648 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1649 m_doc_browser_window->setVisible (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1650 emit show_doc_signal (file);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1651 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1652
25060
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1653 void main_window::handle_register_doc (const QString& file)
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1654 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1655 emit register_doc_signal (file);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1656 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1657
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1658 void main_window::handle_unregister_doc (const QString& file)
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1659 {
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1660 emit unregister_doc_signal (file);
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1661 }
1cd3aeda7598 Allow registering compressed help at run time (bug #53006).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 25054
diff changeset
1662
29057
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1663 void main_window::handle_gui_status_update (const QString& feature,
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1664 const QString& status)
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1665 {
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1666 // Put actions that are required for updating a gui features here
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1667
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1668 // Profiler on/off
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1669 if (! feature.compare ("profiler"))
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1670 {
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1671 if (! status.compare ("on", Qt::CaseInsensitive))
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1672 handle_profiler_status_update (true);
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1673 else if (! status.compare ("off", Qt::CaseInsensitive))
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1674 handle_profiler_status_update (false);
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1675 }
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1676 }
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1677
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1678 void main_window::handle_octave_ready (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1679 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1680 // actions after the startup files are executed
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1681 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1682 gui_settings *settings = rmgr.get_settings ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1683
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1684 QDir startup_dir = QDir (); // current octave dir after startup
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1685
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1686 if (settings)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1687 {
29447
f526f28f1aa4 fix crash when gui tries to restore missing previous octave dir (bug #60255)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29358
diff changeset
1688 if (settings->value (global_restore_ov_dir).toBool ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1689 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1690 // restore last dir from previous session
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1691 QStringList curr_dirs
27849
28d7ec92bae6 replace prefs literals by symbolic constant in main window
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27818
diff changeset
1692 = settings->value (mw_dir_list).toStringList ();
29447
f526f28f1aa4 fix crash when gui tries to restore missing previous octave dir (bug #60255)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29358
diff changeset
1693 if (curr_dirs.length () > 0)
f526f28f1aa4 fix crash when gui tries to restore missing previous octave dir (bug #60255)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29358
diff changeset
1694 startup_dir = QDir (curr_dirs.at (0)); // last dir prev. session
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1695 }
29447
f526f28f1aa4 fix crash when gui tries to restore missing previous octave dir (bug #60255)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29358
diff changeset
1696 else if (! settings->value (global_ov_startup_dir).toString ().isEmpty ())
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1697 {
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1698 // do not restore but there is a startup dir configured
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1699 startup_dir
29447
f526f28f1aa4 fix crash when gui tries to restore missing previous octave dir (bug #60255)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29358
diff changeset
1700 = QDir (settings->value (global_ov_startup_dir).toString ());
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1701 }
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
1702
27935
f1844e33f621 maint: Use Octave coding conventions in libgui/ directory.
Rik <rik@octave.org>
parents: 27929
diff changeset
1703 update_default_encoding (settings->value (ed_default_enc).toString ());
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1704 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1705
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1706 if (! startup_dir.exists ())
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1707 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1708 // the configured startup dir does not exist, take actual one
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1709 startup_dir = QDir ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1710 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1711
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1712 set_current_working_directory (startup_dir.absolutePath ());
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1713
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1714 if (m_editor_window)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1715 {
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
1716 #if defined (HAVE_QSCINTILLA)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1717 // Octave ready, determine whether to create an empty script.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1718 // This can not be done when the editor is created because all functions
27956
2310164737b3 fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents: 27041
diff changeset
1719 // must be known for the lexer's auto completion information
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1720 m_editor_window->empty_script (true, false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1721 m_editor_window->restore_session (settings);
18833
6504a1932637 auto completion offers builtins and file functions for octave (bug #41371)
Torsten <ttl@justmail.de>
parents: 18823
diff changeset
1722 #endif
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1723 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1724
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1725 if (m_octave_qobj.experimental_terminal_widget ())
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1726 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1727 // Set initial prompt.
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1728
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1729 emit interpreter_event
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1730 ([] (interpreter& interp)
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1731 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1732 // INTERPRETER_THREAD
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1733
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1734 event_manager& evmgr = interp.get_event_manager ();
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1735 input_system& input_sys = interp.get_input_system ();
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1736
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1737 input_sys.PS1 (">> ");
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1738 std::string prompt = input_sys.PS1 ();
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1739
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1740 evmgr.update_prompt (command_editor::decode_prompt_string (prompt));
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1741 });
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1742 }
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1743
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
1744 focus_command_window (); // make sure that the command window has focus
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1745 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1746
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1747 void main_window::handle_set_path_dialog_request (void)
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1748 {
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1749 if (m_set_path_dlg) // m_set_path_dlg is a guarded pointer!
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1750 return;
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1751
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1752 m_set_path_dlg = new set_path_dialog (this, m_octave_qobj);
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1753
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1754 m_set_path_dlg->setModal (false);
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1755 m_set_path_dlg->setAttribute (Qt::WA_DeleteOnClose);
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1756 m_set_path_dlg->show ();
27306
82ace1225a9c update path dialog if path is changed from withtin the file browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27302
diff changeset
1757
27391
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1758 // Any interpreter_event signal from a set_path_dialog object is
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1759 // handled the same as for the main_window object.
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1760
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1761 connect (m_set_path_dlg, SIGNAL (interpreter_event (const fcn_callback&)),
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1762 this, SIGNAL (interpreter_event (const fcn_callback&)));
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1763
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1764 connect (m_set_path_dlg, SIGNAL (interpreter_event (const meth_callback&)),
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1765 this, SIGNAL (interpreter_event (const meth_callback&)));
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1766
27308
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
1767 connect (m_set_path_dlg,
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
1768 SIGNAL (modify_path_signal (const octave_value_list&, bool, bool)),
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
1769 this, SLOT (modify_path (const octave_value_list&, bool, bool)));
401a7cda7c9e add possibility for adding dir with subdirectories to load path dialog
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27306
diff changeset
1770
27311
0040b7668518 update load path dialog when path is modified via console
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27308
diff changeset
1771 interpreter_qobject *interp_qobj = m_octave_qobj.interpreter_qobj ();
27391
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1772
27311
0040b7668518 update load path dialog when path is modified via console
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27308
diff changeset
1773 qt_interpreter_events *qt_link = interp_qobj->qt_link ();
27391
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1774
27311
0040b7668518 update load path dialog when path is modified via console
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27308
diff changeset
1775 connect (qt_link, SIGNAL (update_path_dialog_signal (void)),
27306
82ace1225a9c update path dialog if path is changed from withtin the file browser
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27302
diff changeset
1776 m_set_path_dlg, SLOT (update_model (void)));
27391
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1777
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1778 // Now that all the signal connections are in place for the dialog
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1779 // we can set the initial value of the path in the model.
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1780
a329a41cf341 use interpreter_event signals in set_path_dialog object
John W. Eaton <jwe@octave.org>
parents: 27377
diff changeset
1781 m_set_path_dlg->update_model ();
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1782 }
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
1783
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1784 void main_window::find_files (const QString& start_dir)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1785 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1786
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1787 if (! m_find_files_dlg)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1788 {
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1789 m_find_files_dlg = new find_files_dialog (this, m_octave_qobj);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1790
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1791 connect (m_find_files_dlg, SIGNAL (finished (int)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1792 this, SLOT (find_files_finished (int)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1793
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1794 connect (m_find_files_dlg, SIGNAL (dir_selected (const QString &)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1795 m_file_browser_window,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1796 SLOT (set_current_directory (const QString&)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1797
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1798 connect (m_find_files_dlg, SIGNAL (file_selected (const QString &)),
29200
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
1799 this, SIGNAL (open_file_signal (const QString &)));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1800
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1801 m_find_files_dlg->setWindowModality (Qt::NonModal);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1802 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1803
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1804 if (! m_find_files_dlg->isVisible ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1805 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1806 m_find_files_dlg->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1807 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1808
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1809 m_find_files_dlg->set_search_dir (start_dir);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1810
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1811 m_find_files_dlg->activateWindow ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1812
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1813 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1814
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1815 void main_window::set_screen_size (int ht, int wd)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1816 {
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1817 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
1818 ([=] (void)
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1819 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1820 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1821
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1822 command_editor::set_screen_size (ht, wd);
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1823 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1824 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1825
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1826 void main_window::clipboard_has_changed (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1827 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1828 if (m_clipboard->text ().isEmpty ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1829 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1830 m_paste_action->setEnabled (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1831 m_clear_clipboard_action->setEnabled (false);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1832 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1833 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1834 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1835 m_paste_action->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1836 m_clear_clipboard_action->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1837 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1838 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1839
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1840 void main_window::clear_clipboard (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1841 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1842 m_clipboard->clear (QClipboard::Clipboard);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1843 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1844
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1845 void main_window::disable_menu_shortcuts (bool disable)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1846 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1847 QHash<QMenu*, QStringList>::const_iterator i = m_hash_menu_text.constBegin ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1848
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1849 while (i != m_hash_menu_text.constEnd ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1850 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1851 i.key ()->setTitle (i.value ().at (disable));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1852 ++i;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1853 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1854 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1855
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1856 void main_window::restore_create_file_setting (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1857 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1858 // restore the new files creation setting
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1859 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
1860 gui_settings *settings = rmgr.get_settings ();
27849
28d7ec92bae6 replace prefs literals by symbolic constant in main window
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27818
diff changeset
1861 settings->setValue (ed_create_new_file.key, false);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1862 disconnect (m_editor_window, SIGNAL (file_loaded_signal (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1863 this, SLOT (restore_create_file_setting (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1864 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1865
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1866 void main_window::set_file_encoding (const QString& new_encoding)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1867 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1868 m_file_encoding = new_encoding;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1869 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1870
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1871 // The following slot is called after files have been selected in the
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27860
diff changeset
1872 // open file dialog, possibly with a new selected encoding stored in
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1873 // m_file_encoding
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1874 void main_window::request_open_files (const QStringList& open_file_names)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1875 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1876 for (int i = 0; i < open_file_names.count (); i++)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1877 emit open_file_signal (open_file_names.at (i), m_file_encoding, -1);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1878 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1879
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1880 void main_window::edit_variable (const QString &expr, const octave_value& val)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1881 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1882 m_variable_editor_window->edit_variable (expr, val);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1883
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1884 if (! m_variable_editor_window->isVisible ())
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1885 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1886 m_variable_editor_window->show ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1887 m_variable_editor_window->raise ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1888 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1889
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1890 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1891
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1892 void main_window::refresh_variable_editor (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1893 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1894 m_variable_editor_window->refresh ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1895 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1896
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1897 void main_window::handle_variable_editor_update (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1898 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1899 // Called when the variable editor emits the updated signal. The size
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1900 // of a variable may have changed, so we refresh the workspace in the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1901 // interpreter. That will eventually cause the workspace view in the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1902 // GUI to be updated.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1903
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1904 emit interpreter_event
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
1905 ([] (interpreter& interp)
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1906 {
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1907 // INTERPRETER THREAD
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1908
27261
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
1909 tree_evaluator& tw = interp.get_evaluator ();
dccdc3b001a2 eliminate static functions from octave_link class
John W. Eaton <jwe@octave.org>
parents: 27260
diff changeset
1910
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
1911 event_manager& xevmgr = interp.get_event_manager ();
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
1912
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
1913 xevmgr.set_workspace (true, tw.get_symbol_info (), false);
27243
c6807f5cc48b replace some explicit callback functions with lambda expressions
John W. Eaton <jwe@octave.org>
parents: 27220
diff changeset
1914 });
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1915 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1916
29040
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1917 void main_window::profiler_session (void)
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1918 {
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1919 emit interpreter_event
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1920 ([=] (interpreter& interp)
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1921 {
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1922 // INTERPRETER THREAD
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1923
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1924 Ffeval (interp, ovl ("profile","on"));
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1925 });
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1926 }
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1927
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1928 void main_window::profiler_session_resume (void)
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1929 {
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1930 emit interpreter_event
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1931 ([=] (interpreter& interp)
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1932 {
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1933 // INTERPRETER THREAD
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1934
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1935 Ffeval (interp, ovl ("profile","resume"));
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1936 });
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1937 }
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1938
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1939 void main_window::profiler_stop (void)
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1940 {
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1941 emit interpreter_event
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1942 ([=] (interpreter& interp)
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1943 {
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1944 // INTERPRETER THREAD
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1945
29057
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
1946 Ffeval (interp, ovl ("profile","off"));
29040
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1947 });
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1948 }
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1949
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1950 void main_window::handle_profiler_status_update (bool active)
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1951 {
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1952 m_profiler_start->setEnabled (! active);
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1953 m_profiler_resume->setEnabled (! active);
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1954 m_profiler_stop->setEnabled (active);
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1955
29061
8a425e771aa7 use a led like indicator for the prfiler state
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29057
diff changeset
1956 led_indicator::led_state state = led_indicator::LED_STATE_INACTIVE;
29040
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1957 if (active)
29061
8a425e771aa7 use a led like indicator for the prfiler state
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29057
diff changeset
1958 state = led_indicator::LED_STATE_ACTIVE;
8a425e771aa7 use a led like indicator for the prfiler state
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29057
diff changeset
1959 m_profiler_status_indicator->set_state (state);
29040
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1960 }
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1961
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1962 void main_window::profiler_show (void)
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1963 {
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1964 // Do not use a separate interpreter event as in the other
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1965 // profiler slots since the output of the command "profshow"
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1966 // would obscure the prompt and we do not need to emimt a signal
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1967 // for action that is required in the gui after rhe command
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1968 execute_command_in_terminal ("profshow");
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1969 }
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
1970
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1971 void main_window::closeEvent (QCloseEvent *e)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1972 {
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1973 if (confirm_shutdown ())
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1974 {
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1975 // FIXME: Instead of ignoring the event and posting an
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1976 // interpreter event, should we just accept the event and
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1977 // shutdown and clean up the interprter as part of closing the
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1978 // GUI? Going that route might make it easier to close the GUI
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1979 // without having to stop the interpreter, for example, if the
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1980 // GUI is started from the interpreter command line.
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1981
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1982 e->ignore ();
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1983
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1984 if (m_octave_qobj.experimental_terminal_widget ())
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1985 emit close_gui_signal ();
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1986 else
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1987 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1988 emit interpreter_event
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1989 ([] (interpreter& interp)
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1990 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1991 // INTERPRETER THREAD
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1992
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1993 interp.quit (0, false, false);
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1994 });
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
1995 }
27588
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1996 }
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1997 else
f0e3f3e28a8e move qt_interpreter_events object from interpreter_qobject to octave_qobject
John W. Eaton <jwe@octave.org>
parents: 27583
diff changeset
1998 e->ignore ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
1999 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2000
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2001 void main_window::construct_central_widget (void)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2002 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2003 // Create and set the central widget. QMainWindow takes ownership of
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2004 // the widget (pointer) so there is no need to delete the object upon
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2005 // destroying this main_window.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2006
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2007 QWidget *dummyWidget = new QWidget ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2008 dummyWidget->setObjectName ("CentralDummyWidget");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2009 dummyWidget->resize (10, 10);
29147
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2010 dummyWidget->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2011 dummyWidget->hide ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2012 setCentralWidget (dummyWidget);
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2013 }
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2014
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2015 // Main subroutine of the constructor
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2016
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2017 void main_window::construct (void)
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2018 {
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2019 setWindowIcon (QIcon (":/actions/icons/logo.png"));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2020
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2021 m_workspace_window->setModel (m_workspace_model);
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2022
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2023 connect (m_workspace_model, SIGNAL (model_changed (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2024 m_workspace_window, SLOT (handle_model_changed (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2025
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2026 interpreter_qobject *interp_qobj = m_octave_qobj.interpreter_qobj ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2027
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
2028 qt_interpreter_events *qt_link = interp_qobj->qt_link ();
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2029
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2030 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2031 SIGNAL (edit_variable_signal (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2032 const octave_value&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2033 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2034 SLOT (edit_variable (const QString&, const octave_value&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2035
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2036 connect (qt_link, SIGNAL (refresh_variable_editor_signal (void)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2037 this, SLOT (refresh_variable_editor (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2038
27220
9a4a9fcc186b connect workspace view rename variable signal to main window slot
John W. Eaton <jwe@octave.org>
parents: 27219
diff changeset
2039 connect (m_workspace_window,
9a4a9fcc186b connect workspace view rename variable signal to main window slot
John W. Eaton <jwe@octave.org>
parents: 27219
diff changeset
2040 SIGNAL (rename_variable_signal (const QString&, const QString&)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2041 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2042 SLOT (handle_rename_variable_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2043 const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2044
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2045 connect (m_variable_editor_window, SIGNAL (updated (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2046 this, SLOT (handle_variable_editor_update (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2047
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2048 construct_menu_bar ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2049
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2050 construct_tool_bar ();
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2051
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27602
diff changeset
2052 // Order is important. Deleting gui_settings must be last.
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2053 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2054 m_command_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2055
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2056 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2057 m_history_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2058
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2059 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2060 m_file_browser_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2061
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2062 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2063 m_doc_browser_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2064
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2065 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2066 m_workspace_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2067
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2068 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2069 m_editor_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2070
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2071 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2072 m_variable_editor_window, SLOT (save_settings (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2073
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2074 connect (qApp, SIGNAL (aboutToQuit (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2075 this, SLOT (prepare_to_exit (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2076
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2077 connect (qApp, SIGNAL (focusChanged (QWidget*, QWidget*)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2078 this, SLOT (focus_changed (QWidget*, QWidget*)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2079
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27602
diff changeset
2080 connect (this, SIGNAL (settings_changed (const gui_settings *)),
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents: 27602
diff changeset
2081 this, SLOT (notice_settings (const gui_settings *)));
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2082
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2083 connect (this, SIGNAL (editor_focus_changed (bool)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2084 m_editor_window, SLOT (enable_menu_shortcuts (bool)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2085
26873
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2086 connect (this, SIGNAL (step_into_file_signal (void)),
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2087 m_editor_window, SLOT (request_step_into_file (void)));
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2088
29439
fe06fafb4cac fix en-/disabling some editor actions depending on file type (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29359
diff changeset
2089 connect (m_editor_window, SIGNAL (editor_tabs_changed_signal (bool, bool)),
fe06fafb4cac fix en-/disabling some editor actions depending on file type (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29359
diff changeset
2090 this, SLOT (editor_tabs_changed (bool, bool)));
26873
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2091
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2092 connect (m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2093 SIGNAL (request_open_file_external (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2094 m_external_editor,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2095 SLOT (call_custom_editor (const QString&, int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2096
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2097 connect (m_external_editor,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2098 SIGNAL (request_settings_dialog (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2099 this, SLOT (process_settings_dialog_request (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2100
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2101 connect (m_file_browser_window, SIGNAL (load_file_signal (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2102 this, SLOT (handle_load_workspace_request (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2103
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2104 connect (m_file_browser_window, SIGNAL (open_any_signal (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2105 this, SLOT (handle_open_any_request (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2106
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2107 connect (m_file_browser_window, SIGNAL (find_files_signal (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2108 this, SLOT (find_files (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2109
27653
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
2110 // Connections for signals from the interpreter thread where the slot
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
2111 // should be executed by the gui thread
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
2112
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
2113 connect (this, SIGNAL (warning_function_not_found_signal (const QString&)),
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
2114 this, SLOT (warning_function_not_found (const QString&)));
3564d3999960 fix message box when trying to open a non-existant function in the editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27648
diff changeset
2115
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2116 setWindowTitle ("Octave");
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2117
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2118 setStatusBar (m_status_bar);
24019
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
2119
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
2120 #if defined (HAVE_QSCINTILLA)
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2121 connect (this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2122 SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2123 m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2124 SLOT (handle_insert_debugger_pointer_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2125 int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2126
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2127 connect (this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2128 SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2129 m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2130 SLOT (handle_delete_debugger_pointer_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2131 int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2132
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2133 connect (this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2134 SIGNAL (update_breakpoint_marker_signal (bool, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2135 int, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2136 m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2137 SLOT (handle_update_breakpoint_marker_request (bool,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2138 const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2139 int,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2140 const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2141
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2142 // Signals for removing/renaming files/dirs in the file browser
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2143 connect (m_file_browser_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2144 SIGNAL (file_remove_signal (const QString&, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2145 m_editor_window,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2146 SLOT (handle_file_remove (const QString&, const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2147
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2148 connect (m_file_browser_window, SIGNAL (file_renamed_signal (bool)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2149 m_editor_window, SLOT (handle_file_renamed (bool)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2150
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27860
diff changeset
2151 // Signals for removing/renaming files/dirs in the terminal window
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2152 connect (qt_link, SIGNAL (file_renamed_signal (bool)),
27039
32d9f57d7245 fix missing unlock of mutex when gui editor is not present (bug #56097)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2153 m_editor_window, SLOT (handle_file_renamed (bool)));
28798
82ccc4e69ba3 show value in editor when hovering over variable in debug mode (bug #56990)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28795
diff changeset
2154
82ccc4e69ba3 show value in editor when hovering over variable in debug mode (bug #56990)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28795
diff changeset
2155 // Signals for entering/exiting debug mode
82ccc4e69ba3 show value in editor when hovering over variable in debug mode (bug #56990)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28795
diff changeset
2156 connect (qt_link, SIGNAL (enter_debugger_signal (void)),
82ccc4e69ba3 show value in editor when hovering over variable in debug mode (bug #56990)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28795
diff changeset
2157 m_editor_window, SLOT (handle_enter_debug_mode (void)));
82ccc4e69ba3 show value in editor when hovering over variable in debug mode (bug #56990)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28795
diff changeset
2158
82ccc4e69ba3 show value in editor when hovering over variable in debug mode (bug #56990)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28795
diff changeset
2159 connect (qt_link, SIGNAL (exit_debugger_signal (void)),
82ccc4e69ba3 show value in editor when hovering over variable in debug mode (bug #56990)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28795
diff changeset
2160 m_editor_window, SLOT (handle_exit_debug_mode (void)));
27039
32d9f57d7245 fix missing unlock of mutex when gui editor is not present (bug #56097)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2161 #endif
32d9f57d7245 fix missing unlock of mutex when gui editor is not present (bug #56097)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2162
32d9f57d7245 fix missing unlock of mutex when gui editor is not present (bug #56097)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2163 // Signals for removing/renaming files/dirs in the temrinal window
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2164 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2165 SIGNAL (file_remove_signal (const QString&, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2166 this, SLOT (file_remove_proxy (const QString&, const QString&)));
24019
fc4ba8b1ff87 style fixes for GUI main window
John W. Eaton <jwe@octave.org>
parents: 24016
diff changeset
2167
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2168 connect (this, SIGNAL (interpreter_event (const fcn_callback&)),
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2169 &m_octave_qobj, SLOT (interpreter_event (const fcn_callback&)));
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2170
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2171 connect (this, SIGNAL (interpreter_event (const meth_callback&)),
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2172 &m_octave_qobj, SLOT (interpreter_event (const meth_callback&)));
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2173
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2174 configure_shortcuts ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2175 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2176
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2177 void main_window::construct_octave_qt_link (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2178 {
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2179 interpreter_qobject *interp_qobj = m_octave_qobj.interpreter_qobj ();
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2180
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27261
diff changeset
2181 qt_interpreter_events *qt_link = interp_qobj->qt_link ();
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2182
29000
8a05763823d1 avoid possible infinite loop when default encoding is changed (bug #59331)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28837
diff changeset
2183 connect (qt_link, SIGNAL (settings_changed (const gui_settings *, bool)),
8a05763823d1 avoid possible infinite loop when default encoding is changed (bug #59331)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28837
diff changeset
2184 this, SLOT (notice_settings (const gui_settings *, bool)));
27601
7a748f7545c9 improve thread safety of qt_interpreter_events::gui_preference
John W. Eaton <jwe@octave.org>
parents: 27588
diff changeset
2185
27602
ba317c535adb define new __event_manager_apply_preferences__ function
John W. Eaton <jwe@octave.org>
parents: 27601
diff changeset
2186 connect (qt_link, SIGNAL (apply_new_settings (void)),
ba317c535adb define new __event_manager_apply_preferences__ function
John W. Eaton <jwe@octave.org>
parents: 27601
diff changeset
2187 this, SLOT (request_reload_settings (void)));
ba317c535adb define new __event_manager_apply_preferences__ function
John W. Eaton <jwe@octave.org>
parents: 27601
diff changeset
2188
29503
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
2189 if (m_octave_qobj.experimental_terminal_widget ())
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
2190 {
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
2191 connect (qt_link, SIGNAL (interpreter_output_signal (const QString&)),
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
2192 m_command_window,
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
2193 SLOT (interpreter_output (const QString&)));
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
2194
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
2195 connect (qt_link, SIGNAL (update_prompt_signal (const QString&)),
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
2196 m_command_window, SLOT (update_prompt (const QString&)));
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
2197 }
3bfec185c9e2 experimental command window widget with server loop
John W. Eaton <jwe@octave.org>
parents: 29474
diff changeset
2198
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2199 connect (qt_link,
26117
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 26115
diff changeset
2200 SIGNAL (set_workspace_signal (bool, bool, const symbol_info_list&)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2201 m_workspace_model,
26117
a6df420457ac use symbol_info_list instead of symbol_scope to pass workspace info to gui
John W. Eaton <jwe@octave.org>
parents: 26115
diff changeset
2202 SLOT (set_workspace (bool, bool, const symbol_info_list&)));
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2203
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2204 connect (qt_link, SIGNAL (clear_workspace_signal (void)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2205 m_workspace_model, SLOT (clear_workspace (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2206
27409
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
2207 connect (qt_link, SIGNAL (directory_changed_signal (QString)),
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
2208 this, SLOT (update_octave_directory (QString)));
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
2209
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
2210 connect (qt_link, SIGNAL (directory_changed_signal (QString)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2211 m_file_browser_window, SLOT (update_octave_directory (QString)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2212
27409
a0d49e55acae rename change_directory to directory_changed in event manager
John W. Eaton <jwe@octave.org>
parents: 27408
diff changeset
2213 connect (qt_link, SIGNAL (directory_changed_signal (QString)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2214 m_editor_window, SLOT (update_octave_directory (QString)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2215
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2216 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2217 SIGNAL (execute_command_in_terminal_signal (QString)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2218 this, SLOT (execute_command_in_terminal (QString)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2219
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2220 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2221 SIGNAL (set_history_signal (const QStringList&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2222 m_history_window, SLOT (set_history (const QStringList&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2223
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2224 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2225 SIGNAL (append_history_signal (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2226 m_history_window, SLOT (append_history (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2227
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2228 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2229 SIGNAL (clear_history_signal (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2230 m_history_window, SLOT (clear_history (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2231
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2232 connect (qt_link, SIGNAL (enter_debugger_signal (void)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2233 this, SLOT (handle_enter_debugger (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2234
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2235 connect (qt_link, SIGNAL (exit_debugger_signal (void)),
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2236 this, SLOT (handle_exit_debugger (void)));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2237
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2238 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2239 SIGNAL (show_preferences_signal (void)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2240 this, SLOT (process_settings_dialog_request (void)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2241
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2242 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2243 SIGNAL (edit_file_signal (const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2244 m_active_editor,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2245 SLOT (handle_edit_file_request (const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2246
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2247 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2248 SIGNAL (insert_debugger_pointer_signal (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2249 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2250 SLOT (handle_insert_debugger_pointer_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2251 int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2252
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2253 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2254 SIGNAL (delete_debugger_pointer_signal (const QString&, int)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2255 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2256 SLOT (handle_delete_debugger_pointer_request (const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2257 int)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2258
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2259 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2260 SIGNAL (update_breakpoint_marker_signal (bool, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2261 int, const QString&)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2262 this,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2263 SLOT (handle_update_breakpoint_marker_request (bool, const QString&,
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2264 int, const QString&)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2265
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2266 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2267 SIGNAL (show_doc_signal (const QString &)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2268 this, SLOT (handle_show_doc (const QString &)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2269
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2270 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2271 SIGNAL (register_doc_signal (const QString &)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2272 this, SLOT (handle_register_doc (const QString &)));
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2273
27218
a044202208af more refactoring of GUI classes that manage the interpreter
John W. Eaton <jwe@octave.org>
parents: 27209
diff changeset
2274 connect (qt_link,
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2275 SIGNAL (unregister_doc_signal (const QString &)),
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2276 this, SLOT (handle_unregister_doc (const QString &)));
28788
aba2c4eadb83 add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28568
diff changeset
2277
29057
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
2278 connect (qt_link, SIGNAL (gui_status_update_signal (const QString &,
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
2279 const QString &)),
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
2280 this, SLOT (handle_gui_status_update (const QString &,
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
2281 const QString &)));
450920c987b8 update profiler status in gui from interpreter
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29040
diff changeset
2282
28788
aba2c4eadb83 add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28568
diff changeset
2283 connect (qt_link, SIGNAL (update_gui_lexer_signal (bool)),
aba2c4eadb83 add functions of loaded packages to auto-completion list (bug #56207)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 28568
diff changeset
2284 this, SIGNAL (update_gui_lexer_signal (bool)));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2285 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2286
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2287 QAction* main_window::add_action (QMenu *menu, const QIcon& icon,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2288 const QString& text, const char *member,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2289 const QWidget *receiver)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2290 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2291 QAction *a;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2292
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2293 if (receiver)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2294 a = menu->addAction (icon, text, receiver, member);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2295 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2296 a = menu->addAction (icon, text, this, member);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2297
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2298 addAction (a); // important for shortcut context
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2299 a->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2300 return a;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2301 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2302
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2303 QMenu* main_window::m_add_menu (QMenuBar *p, QString name)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2304 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2305 QMenu *menu = p->addMenu (name);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2306
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2307 QString base_name = name; // get a copy
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2308 // replace intended '&' ("&&") by a temp. string
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2309 base_name.replace ("&&", "___octave_amp_replacement___");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2310 // remove single '&' (shortcut)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2311 base_name.remove ("&");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2312 // restore intended '&'
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2313 base_name.replace ("___octave_amp_replacement___", "&&");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2314
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2315 // remember names with and without shortcut
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2316 m_hash_menu_text[menu] = QStringList () << name << base_name;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2317
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2318 return menu;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2319 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2320
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2321 void main_window::construct_menu_bar (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2322 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2323 QMenuBar *menu_bar = menuBar ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2324
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2325 construct_file_menu (menu_bar);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2326
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2327 construct_edit_menu (menu_bar);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2328
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2329 construct_debug_menu (menu_bar);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2330
29068
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29061
diff changeset
2331 construct_tools_menu (menu_bar);
29040
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
2332
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2333 construct_window_menu (menu_bar);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2334
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2335 construct_help_menu (menu_bar);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2336
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2337 construct_news_menu (menu_bar);
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
2338
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2339 #if defined (HAVE_QSCINTILLA)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2340 // call the editor to add actions which should also be available in the
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2341 // editor's menu and tool bar
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2342 QList<QAction*> shared_actions;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2343 shared_actions << m_new_script_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2344 << m_new_function_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2345 << m_open_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2346 << m_find_files_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2347 << m_undo_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2348 << m_copy_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2349 << m_paste_action
29200
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2350 << m_select_all_action;
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2351 m_editor_window->insert_global_actions (shared_actions);
20986
00835323fb44 prevent shortcut ambiguity between main and editor window
Torsten <ttl@justmail.de>
parents: 20955
diff changeset
2352 #endif
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2353 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2354
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2355 void main_window::construct_file_menu (QMenuBar *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2356 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2357 QMenu *file_menu = m_add_menu (p, tr ("&File"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2358
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2359 construct_new_menu (file_menu);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2360
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2361 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
29200
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2362
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2363 m_open_action = add_action (
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2364 file_menu, rmgr.icon ("document-open"), tr ("Open..."),
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2365 SLOT (request_open_file (void)), this);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2366 m_open_action->setToolTip (tr ("Open an existing file in editor"));
16970
78116b88dbf5 enable readline key bindings in terminal widget of gui (bug #36986)
Torsten <ttl@justmail.de>
parents: 16956
diff changeset
2367
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2368 #if defined (HAVE_QSCINTILLA)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2369 file_menu->addMenu (m_editor_window->get_mru_menu ());
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2370 #endif
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2371
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2372 file_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2373
29200
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2374 m_load_workspace_action = add_action (
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2375 file_menu, QIcon (), tr ("Load Workspace..."),
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2376 SLOT (handle_load_workspace_request (void)), this);
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2377
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2378 m_save_workspace_action = add_action (
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2379 file_menu, QIcon (), tr ("Save Workspace As..."),
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2380 SLOT (handle_save_workspace_request (void)), this);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2381
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2382 file_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2383
29200
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2384 m_exit_action = add_action (
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2385 file_menu, QIcon (), tr ("Exit"),
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2386 SLOT (close (void)), this);
27118
99adef2c6e10 Enable "Quit" menu item on Mac application menu (bug #56155)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 27102
diff changeset
2387 m_exit_action->setMenuRole (QAction::QuitRole);
29200
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2388
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2389 // Connect signal related to opening or creating editor files
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2390 connect (this, SIGNAL (new_file_signal (const QString&)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2391 m_active_editor, SLOT (request_new_file (const QString&)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2392
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2393 connect (this, SIGNAL (open_file_signal (const QString&)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2394 m_active_editor, SLOT (request_open_file (const QString&)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2395
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2396 connect (this,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2397 SIGNAL (open_file_signal (const QString&, const QString&, int)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2398 m_active_editor,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2399 SLOT (request_open_file (const QString&, const QString&, int)));
29200
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2400 }
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2401
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2402 void main_window::construct_new_menu (QMenu *p)
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2403 {
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2404 QMenu *new_menu = p->addMenu (tr ("New"));
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2405
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2406 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2407
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2408 m_new_script_action = add_action (
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2409 new_menu, rmgr.icon ("document-new"), tr ("New Script"),
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2410 SLOT (request_new_script (void)), this);
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2411
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2412 m_new_function_action = add_action (
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2413 new_menu, QIcon (), tr ("New Function..."),
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2414 SLOT (request_new_function (void)), this);
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2415
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2416 m_new_figure_action = add_action (
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2417 new_menu, QIcon (), tr ("New Figure"),
6e0952fa5a4f removing obsolete code for some main window menus
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29199
diff changeset
2418 SLOT (handle_new_figure_request (void)), this);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2419 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2420
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2421 void main_window::construct_edit_menu (QMenuBar *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2422 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2423 QMenu *edit_menu = m_add_menu (p, tr ("&Edit"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2424
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2425 QKeySequence ctrl_shift = Qt::ControlModifier + Qt::ShiftModifier;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2426
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2427 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2428 m_undo_action
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2429 = edit_menu->addAction (rmgr.icon ("edit-undo"), tr ("Undo"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2430 m_undo_action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2431
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2432 edit_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2433
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2434 m_copy_action
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2435 = edit_menu->addAction (rmgr.icon ("edit-copy"), tr ("Copy"), this,
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2436 SLOT (copyClipboard (void)));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2437 m_copy_action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2438
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2439 m_paste_action
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2440 = edit_menu->addAction (rmgr.icon ("edit-paste"), tr ("Paste"), this,
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2441 SLOT (pasteClipboard (void)));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2442 m_paste_action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2443
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2444 m_select_all_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2445 = edit_menu->addAction (tr ("Select All"), this, SLOT (selectAll (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2446 m_select_all_action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2447
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2448 m_clear_clipboard_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2449 = edit_menu->addAction (tr ("Clear Clipboard"), this,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2450 SLOT (clear_clipboard (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2451
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2452 edit_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2453
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2454 m_find_files_action
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2455 = edit_menu->addAction (rmgr.icon ("edit-find"), tr ("Find Files..."));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2456
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2457 edit_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2458
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2459 m_clear_command_window_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2460 = edit_menu->addAction (tr ("Clear Command Window"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2461
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2462 m_clear_command_history_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2463 = edit_menu->addAction (tr ("Clear Command History"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2464
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2465 m_clear_workspace_action
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2466 = edit_menu->addAction (tr ("Clear Workspace"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2467
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2468 edit_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2469
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2470 m_set_path_action
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2471 = edit_menu->addAction (tr ("Set Path"));
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2472
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2473 m_preferences_action
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2474 = edit_menu->addAction (rmgr.icon ("preferences-system"),
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2475 tr ("Preferences..."));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2476
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2477 connect (m_find_files_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2478 this, SLOT (find_files (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2479
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2480 connect (m_clear_command_window_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2481 this, SLOT (handle_clear_command_window_request (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2482
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2483 connect (m_clear_command_history_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2484 this, SLOT (handle_clear_history_request (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2485
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2486 connect (m_clear_workspace_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2487 this, SLOT (handle_clear_workspace_request (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2488
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2489 connect (m_clipboard, SIGNAL (dataChanged (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2490 this, SLOT (clipboard_has_changed (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2491 clipboard_has_changed ();
24625
be37df6e1fb4 always enable paste action in windows (bug #52361)
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
2492 #if defined (Q_OS_WIN32)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2493 // Always enable paste action (unreliable clipboard signals in windows)
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27860
diff changeset
2494 // FIXME: This has to be removed, when the clipboard signals in windows
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2495 // are working again
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2496 m_paste_action->setEnabled (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2497 m_clear_clipboard_action->setEnabled (true);
24625
be37df6e1fb4 always enable paste action in windows (bug #52361)
Torsten <mttl@mailbox.org>
parents: 24534
diff changeset
2498 #endif
20039
3538c2824dd8 GUI: Move preferences to edit menu (Bug #44725)
John Donoghue
parents: 19985
diff changeset
2499
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2500 connect (m_preferences_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2501 this, SLOT (process_settings_dialog_request (void)));
27298
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2502
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2503 connect (m_set_path_action, SIGNAL (triggered (void)),
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2504 this, SLOT (handle_set_path_dialog_request (void)));
1805f8586179 new gui dialog for modifying octaves load path (bug #43549)
JunWang <jstzwj@aliyun.com>
parents: 27287
diff changeset
2505
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2506 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2507
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2508 QAction * main_window::construct_debug_menu_item (const char *icon,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2509 const QString& item,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2510 const char *member)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2511 {
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2512 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2513 QAction *action = add_action (m_debug_menu, rmgr.icon (QString (icon)),
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2514 item, member);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2515
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2516 action->setEnabled (false);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2517
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2518 #if defined (HAVE_QSCINTILLA)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2519 m_editor_window->debug_menu ()->addAction (action);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2520 m_editor_window->toolbar ()->addAction (action);
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2521 #endif
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2522
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2523 return action;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2524 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2525
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2526 void main_window::construct_debug_menu (QMenuBar *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2527 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2528 m_debug_menu = m_add_menu (p, tr ("De&bug"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2529
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2530 m_debug_step_over
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2531 = construct_debug_menu_item ("db-step", tr ("Step"),
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2532 SLOT (debug_step_over (void)));
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2533
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2534 m_debug_step_into
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2535 = construct_debug_menu_item ("db-step-in", tr ("Step In"),
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2536 SLOT (debug_step_into (void)));
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2537
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2538 m_debug_step_out
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2539 = construct_debug_menu_item ("db-step-out", tr ("Step Out"),
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2540 SLOT (debug_step_out (void)));
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2541
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2542 m_debug_continue
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2543 = construct_debug_menu_item ("db-cont", tr ("Continue"),
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2544 SLOT (debug_continue (void)));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2545
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2546 m_debug_menu->addSeparator ();
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21670
diff changeset
2547 #if defined (HAVE_QSCINTILLA)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2548 m_editor_window->debug_menu ()->addSeparator ();
16454
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2549 #endif
246d25c8761b split main_window::construct for clarity
John W. Eaton <jwe@octave.org>
parents: 16453
diff changeset
2550
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2551 m_debug_quit
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2552 = construct_debug_menu_item ("db-stop", tr ("Quit Debug Mode"),
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2553 SLOT (debug_quit (void)));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2554 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2555
29068
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29061
diff changeset
2556 void main_window::construct_tools_menu (QMenuBar *p)
29040
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
2557 {
29068
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29061
diff changeset
2558 QMenu *tools_menu = m_add_menu (p, tr ("&Tools"));
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29061
diff changeset
2559
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29061
diff changeset
2560 m_profiler_start = add_action (tools_menu, QIcon (),
29040
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
2561 tr ("Start &Profiler Session"), SLOT (profiler_session ()));
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
2562
29068
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29061
diff changeset
2563 m_profiler_resume = add_action (tools_menu, QIcon (),
29040
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
2564 tr ("&Resume Profiler Session"), SLOT (profiler_session_resume ()));
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
2565
29068
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29061
diff changeset
2566 m_profiler_stop = add_action (tools_menu, QIcon (),
29040
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
2567 tr ("&Stop Profiler"), SLOT (profiler_stop ()));
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
2568 m_profiler_stop->setEnabled (false);
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
2569
29068
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29061
diff changeset
2570 m_profiler_show = add_action (tools_menu, QIcon (),
29040
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
2571 tr ("&Show Profile Data"), SLOT (profiler_show ()));
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
2572 }
05b8ad7b67e8 gui menu for handling the profile (based on patch #8300 by Hassan Radi)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29001
diff changeset
2573
29439
fe06fafb4cac fix en-/disabling some editor actions depending on file type (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29359
diff changeset
2574 void main_window::editor_tabs_changed (bool have_tabs, bool is_octave)
26873
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2575 {
27893
465ac679e976 Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents: 27860
diff changeset
2576 // Set state of actions which depend on the existence of editor tabs
26873
9ec36417c262 debug step starts script if not already running in debug mode (bug #44728)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 26643
diff changeset
2577 m_editor_has_tabs = have_tabs;
29439
fe06fafb4cac fix en-/disabling some editor actions depending on file type (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29359
diff changeset
2578 m_editor_is_octave_file = is_octave;
fe06fafb4cac fix en-/disabling some editor actions depending on file type (bug #60214)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29359
diff changeset
2579 m_debug_step_over->setEnabled (have_tabs && is_octave);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2580 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2581
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2582 QAction * main_window::construct_window_menu_item (QMenu *p,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2583 const QString& item,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2584 bool checkable,
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2585 QWidget *widget)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2586 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2587 QAction *action = p->addAction (QIcon (), item);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2588
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2589 addAction (action); // important for shortcut context
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2590 action->setCheckable (checkable);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2591 action->setShortcutContext (Qt::ApplicationShortcut);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2592
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2593 if (widget) // might be zero for m_editor_window
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2594 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2595 if (checkable)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2596 {
27956
2310164737b3 fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents: 27041
diff changeset
2597 // action for visibility of dock widget
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2598 connect (action, SIGNAL (toggled (bool)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2599 widget, SLOT (setVisible (bool)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2600
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2601 connect (widget, SIGNAL (active_changed (bool)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2602 action, SLOT (setChecked (bool)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2603 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2604 else
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2605 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2606 // action for focus of dock widget
27281
0915fec3d3a9 prevent gui from catching focus when its desktop workspace becomes active
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27277
diff changeset
2607 connect (action, SIGNAL (triggered (void)), widget, SLOT (activate (void)));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2608 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2609 }
27258
922c47ff5218 disable editor actions in window menu when editor is not available (bug #56114)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27255
diff changeset
2610 else
922c47ff5218 disable editor actions in window menu when editor is not available (bug #56114)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27255
diff changeset
2611 {
922c47ff5218 disable editor actions in window menu when editor is not available (bug #56114)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27255
diff changeset
2612 action->setEnabled (false);
922c47ff5218 disable editor actions in window menu when editor is not available (bug #56114)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27255
diff changeset
2613 }
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2614
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2615 return action;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2616 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2617
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2618 void main_window::construct_window_menu (QMenuBar *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2619 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2620 QMenu *window_menu = m_add_menu (p, tr ("&Window"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2621
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2622 m_show_command_window_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2623 (window_menu, tr ("Show Command Window"), true, m_command_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2624
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2625 m_show_history_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2626 (window_menu, tr ("Show Command History"), true, m_history_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2627
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2628 m_show_file_browser_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2629 (window_menu, tr ("Show File Browser"), true, m_file_browser_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2630
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2631 m_show_workspace_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2632 (window_menu, tr ("Show Workspace"), true, m_workspace_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2633
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2634 m_show_editor_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2635 (window_menu, tr ("Show Editor"), true, m_editor_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2636
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2637 m_show_documentation_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2638 (window_menu, tr ("Show Documentation"), true, m_doc_browser_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2639
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2640 m_show_variable_editor_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2641 (window_menu, tr ("Show Variable Editor"), true, m_variable_editor_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2642
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2643 window_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2644
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2645 m_command_window_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2646 (window_menu, tr ("Command Window"), false, m_command_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2647
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2648 m_history_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2649 (window_menu, tr ("Command History"), false, m_history_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2650
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2651 m_file_browser_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2652 (window_menu, tr ("File Browser"), false, m_file_browser_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2653
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2654 m_workspace_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2655 (window_menu, tr ("Workspace"), false, m_workspace_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2656
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2657 m_editor_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2658 (window_menu, tr ("Editor"), false, m_editor_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2659
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2660 m_documentation_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2661 (window_menu, tr ("Documentation"), false, m_doc_browser_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2662
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2663 m_variable_editor_action = construct_window_menu_item
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2664 (window_menu, tr ("Variable Editor"), false, m_variable_editor_window);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2665
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2666 window_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2667
27860
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
2668 m_previous_dock_action = add_action (window_menu, QIcon (),
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
2669 tr ("Previous Widget"), SLOT (go_to_previous_widget (void)));
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
2670
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
2671 window_menu->addSeparator ();
cbd4d97100b3 add action and shortcut for switching to previews widget (bug #57447)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27849
diff changeset
2672
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2673 m_reset_windows_action = add_action (window_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2674 tr ("Reset Default Window Layout"), SLOT (reset_windows (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2675 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2676
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2677 void main_window::construct_help_menu (QMenuBar *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2678 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2679 QMenu *help_menu = m_add_menu (p, tr ("&Help"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2680
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2681 construct_documentation_menu (help_menu);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2682
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2683 help_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2684
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2685 m_report_bug_action = add_action (help_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2686 tr ("Report Bug"), SLOT (open_bug_tracker_page ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2687
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2688 m_octave_packages_action = add_action (help_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2689 tr ("Octave Packages"), SLOT (open_octave_packages_page ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2690
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2691 m_contribute_action = add_action (help_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2692 tr ("Contribute"), SLOT (open_contribute_page ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2693
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2694 m_developer_action = add_action (help_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2695 tr ("Donate to Octave"), SLOT (open_donate_page ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2696
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2697 help_menu->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2698
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2699 m_about_octave_action = add_action (help_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2700 tr ("About Octave"), SLOT (show_about_octave ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2701 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2702
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2703 void main_window::construct_documentation_menu (QMenu *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2704 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2705 QMenu *doc_menu = p->addMenu (tr ("Documentation"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2706
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2707 m_ondisk_doc_action = add_action (doc_menu, QIcon (),
27281
0915fec3d3a9 prevent gui from catching focus when its desktop workspace becomes active
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27277
diff changeset
2708 tr ("On Disk"), SLOT (activate ()), m_doc_browser_window);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2709
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2710 m_online_doc_action = add_action (doc_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2711 tr ("Online"), SLOT (open_online_documentation_page ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2712 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2713
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2714 void main_window::construct_news_menu (QMenuBar *p)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2715 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2716 QMenu *news_menu = m_add_menu (p, tr ("&News"));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2717
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2718 m_release_notes_action = add_action (news_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2719 tr ("Release Notes"), SLOT (display_release_notes ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2720
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2721 m_current_news_action = add_action (news_menu, QIcon (),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2722 tr ("Community News"), SLOT (load_and_display_community_news ()));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2723 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2724
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2725 void main_window::construct_tool_bar (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2726 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2727 m_main_tool_bar = addToolBar (tr ("Toolbar"));
27457
70d9746e9011 smaller toolbars in editor and main window (bug #53902)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27412
diff changeset
2728 m_main_tool_bar->setStyleSheet (m_main_tool_bar->styleSheet ()
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27556
diff changeset
2729 + global_toolbar_style);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2730
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2731 m_main_tool_bar->setObjectName ("MainToolBar");
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2732 m_main_tool_bar->addAction (m_new_script_action);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2733 m_main_tool_bar->addAction (m_open_action);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2734
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2735 m_main_tool_bar->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2736
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2737 m_main_tool_bar->addAction (m_copy_action);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2738 m_main_tool_bar->addAction (m_paste_action);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2739 m_main_tool_bar->addAction (m_undo_action);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2740
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2741 m_main_tool_bar->addSeparator ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2742
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2743 m_current_directory_combo_box = new QComboBox (this);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2744 QFontMetrics fm = m_current_directory_combo_box->fontMetrics ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2745 m_current_directory_combo_box->setFixedWidth (48*fm.averageCharWidth ());
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2746 m_current_directory_combo_box->setEditable (true);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2747 m_current_directory_combo_box->setInsertPolicy (QComboBox::NoInsert);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2748 m_current_directory_combo_box->setToolTip (tr ("Enter directory name"));
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2749 m_current_directory_combo_box->setMaxVisibleItems (current_directory_max_visible);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2750 m_current_directory_combo_box->setMaxCount (current_directory_max_count);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2751 QSizePolicy sizePol (QSizePolicy::Preferred, QSizePolicy::Preferred);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2752 m_current_directory_combo_box->setSizePolicy (sizePol);
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2753
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2754 // addWidget takes ownership of the objects so there is no
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2755 // need to delete these upon destroying this main_window.
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2756 m_main_tool_bar->addWidget (new QLabel (tr ("Current Directory: ")));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2757 m_main_tool_bar->addWidget (m_current_directory_combo_box);
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2758 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2759 QAction *current_dir_up
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2760 = m_main_tool_bar->addAction (rmgr.icon ("go-up"),
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2761 tr ("One directory up"));
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2762 QAction *current_dir_search
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2763 = m_main_tool_bar->addAction (rmgr.icon ("folder"),
27276
7455523fdf01 style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents: 27271
diff changeset
2764 tr ("Browse directories"));
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2765
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2766 connect (m_current_directory_combo_box, SIGNAL (activated (QString)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2767 this, SLOT (set_current_working_directory (QString)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2768
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2769 connect (m_current_directory_combo_box->lineEdit (), SIGNAL (returnPressed (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2770 this, SLOT (accept_directory_line_edit (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2771
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2772 connect (current_dir_search, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2773 this, SLOT (browse_for_directory (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2774
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2775 connect (current_dir_up, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2776 this, SLOT (change_directory_up (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2777
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2778 connect (m_undo_action, SIGNAL (triggered (void)),
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2779 this, SLOT (handle_undo_request (void)));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2780 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2781
27556
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27478
diff changeset
2782 void main_window::focus_console_after_command (void)
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2783 {
27629
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2784 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
8b6e928e0705 in GUI objects, store reference to base_qobject instead of resource_manager
John W. Eaton <jwe@octave.org>
parents: 27620
diff changeset
2785 gui_settings *settings = rmgr.get_settings ();
27849
28d7ec92bae6 replace prefs literals by symbolic constant in main window
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27818
diff changeset
2786 if (settings->value (cs_focus_cmd).toBool ())
27556
410622ac120f improve run selection from editor (bug #42705)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27478
diff changeset
2787 focus_command_window ();
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2788 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2789
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2790 void main_window::configure_shortcuts (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2791 {
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2792 bool enable
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2793 = ! ((m_active_dock == m_command_window) && m_prevent_readline_conflicts);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2794
27630
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
2795 shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager ();
262cdd0f7619 don't use singleton pattern for shortcut manager in GUI
John W. Eaton <jwe@octave.org>
parents: 27629
diff changeset
2796
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2797 // file menu
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2798 scmgr.set_shortcut (m_open_action, sc_main_file_open_file, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2799 scmgr.set_shortcut (m_new_script_action, sc_main_file_new_file, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2800 scmgr.set_shortcut (m_new_function_action, sc_main_file_new_function, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2801 scmgr.set_shortcut (m_new_figure_action, sc_main_file_new_figure, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2802 scmgr.set_shortcut (m_load_workspace_action, sc_main_file_load_workspace, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2803 scmgr.set_shortcut (m_save_workspace_action, sc_main_file_save_workspace, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2804 scmgr.set_shortcut (m_exit_action, sc_main_file_exit, enable);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2805
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2806 // edit menu
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2807 scmgr.set_shortcut (m_copy_action, sc_main_edit_copy, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2808 scmgr.set_shortcut (m_paste_action, sc_main_edit_paste, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2809 scmgr.set_shortcut (m_undo_action, sc_main_edit_undo, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2810 scmgr.set_shortcut (m_select_all_action, sc_main_edit_select_all, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2811 scmgr.set_shortcut (m_clear_clipboard_action, sc_main_edit_clear_clipboard, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2812 scmgr.set_shortcut (m_find_files_action, sc_main_edit_find_in_files, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2813 scmgr.set_shortcut (m_clear_command_history_action, sc_main_edit_clear_history, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2814 scmgr.set_shortcut (m_clear_command_window_action, sc_main_edit_clear_command_window, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2815 scmgr.set_shortcut (m_clear_workspace_action, sc_main_edit_clear_workspace, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2816 scmgr.set_shortcut (m_set_path_action, sc_main_edit_set_path, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2817 scmgr.set_shortcut (m_preferences_action, sc_main_edit_preferences, enable);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2818
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2819 // debug menu
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2820 scmgr.set_shortcut (m_debug_step_over, sc_main_debug_step_over, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2821 scmgr.set_shortcut (m_debug_step_into, sc_main_debug_step_into, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2822 scmgr.set_shortcut (m_debug_step_out, sc_main_debug_step_out, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2823 scmgr.set_shortcut (m_debug_continue, sc_main_debug_continue, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2824 scmgr.set_shortcut (m_debug_quit, sc_main_debug_quit, enable);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2825
29068
d8089b13d4d7 add shortcuts for the new profiler actions in the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29061
diff changeset
2826 // tools menu
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2827 scmgr.set_shortcut (m_profiler_start, sc_main_tools_start_profiler, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2828 scmgr.set_shortcut (m_profiler_resume, sc_main_tools_resume_profiler, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2829 scmgr.set_shortcut (m_profiler_stop, sc_main_tools_start_profiler, enable); // same, toggling
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2830 scmgr.set_shortcut (m_profiler_show, sc_main_tools_show_profiler, enable);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2831
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2832 // window menu
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2833 scmgr.set_shortcut (m_show_command_window_action, sc_main_window_show_command, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2834 scmgr.set_shortcut (m_show_history_action, sc_main_window_show_history, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2835 scmgr.set_shortcut (m_show_workspace_action, sc_main_window_show_workspace, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2836 scmgr.set_shortcut (m_show_file_browser_action, sc_main_window_show_file_browser, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2837 scmgr.set_shortcut (m_show_editor_action, sc_main_window_show_editor, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2838 scmgr.set_shortcut (m_show_documentation_action, sc_main_window_show_doc, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2839 scmgr.set_shortcut (m_show_variable_editor_action, sc_main_window_show_variable_editor, enable);
29474
34922160bda9 do not disable shortcuts for activating other widgets in console widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29460
diff changeset
2840 scmgr.set_shortcut (m_reset_windows_action, sc_main_window_reset, enable);
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2841 scmgr.set_shortcut (m_command_window_action, sc_main_window_command, enable);
29474
34922160bda9 do not disable shortcuts for activating other widgets in console widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29460
diff changeset
2842 // Switching to the other widgets (including the previous one) is always enabled
34922160bda9 do not disable shortcuts for activating other widgets in console widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29460
diff changeset
2843 scmgr.set_shortcut (m_history_action, sc_main_window_history, true);
34922160bda9 do not disable shortcuts for activating other widgets in console widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29460
diff changeset
2844 scmgr.set_shortcut (m_workspace_action, sc_main_window_workspace, true);
34922160bda9 do not disable shortcuts for activating other widgets in console widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29460
diff changeset
2845 scmgr.set_shortcut (m_file_browser_action, sc_main_window_file_browser, true);
34922160bda9 do not disable shortcuts for activating other widgets in console widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29460
diff changeset
2846 scmgr.set_shortcut (m_editor_action, sc_main_window_editor, true);
34922160bda9 do not disable shortcuts for activating other widgets in console widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29460
diff changeset
2847 scmgr.set_shortcut (m_documentation_action, sc_main_window_doc, true);
34922160bda9 do not disable shortcuts for activating other widgets in console widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29460
diff changeset
2848 scmgr.set_shortcut (m_variable_editor_action, sc_main_window_variable_editor, true);
34922160bda9 do not disable shortcuts for activating other widgets in console widget
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29460
diff changeset
2849 scmgr.set_shortcut (m_previous_dock_action, sc_main_window_previous_dock, true);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2850
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2851 // help menu
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2852 scmgr.set_shortcut (m_ondisk_doc_action, sc_main_help_ondisk_doc, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2853 scmgr.set_shortcut (m_online_doc_action, sc_main_help_online_doc, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2854 scmgr.set_shortcut (m_report_bug_action, sc_main_help_report_bug, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2855 scmgr.set_shortcut (m_octave_packages_action, sc_main_help_packages, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2856 scmgr.set_shortcut (m_contribute_action, sc_main_help_contribute, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2857 scmgr.set_shortcut (m_developer_action, sc_main_help_developer, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2858 scmgr.set_shortcut (m_about_octave_action, sc_main_help_about, enable);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2859
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2860 // news menu
29206
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2861 scmgr.set_shortcut (m_release_notes_action, sc_main_news_release_notes, enable);
a0a892829b6d fix handling global shortcuts when preventing conflicts with readline
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29200
diff changeset
2862 scmgr.set_shortcut (m_current_news_action, sc_main_news_community_news, enable);
24715
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2863 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2864
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2865 QList<octave_dock_widget *> main_window::dock_widget_list (void)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2866 {
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2867 QList<octave_dock_widget *> list = QList<octave_dock_widget *> ();
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2868 list.append (static_cast<octave_dock_widget *> (m_command_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2869 list.append (static_cast<octave_dock_widget *> (m_history_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2870 list.append (static_cast<octave_dock_widget *> (m_file_browser_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2871 list.append (static_cast<octave_dock_widget *> (m_doc_browser_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2872 #if defined (HAVE_QSCINTILLA)
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2873 list.append (static_cast<octave_dock_widget *> (m_editor_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2874 #endif
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2875 list.append (static_cast<octave_dock_widget *> (m_workspace_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2876 list.append (static_cast<octave_dock_widget *> (m_variable_editor_window));
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2877 return list;
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2878 }
88bb3f086d9a move GUI main_window and related classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 24645
diff changeset
2879
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2880 void main_window::update_default_encoding (const QString& default_encoding)
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2881 {
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2882 m_default_encoding = default_encoding;
27271
a4416cd6bb4f Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27270
diff changeset
2883 std::string mfile_encoding = m_default_encoding.toStdString ();
a4416cd6bb4f Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27270
diff changeset
2884 if (m_default_encoding.startsWith ("SYSTEM", Qt::CaseInsensitive))
a4416cd6bb4f Append name of actual encoding used if "SYSTEM" is selected.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27270
diff changeset
2885 mfile_encoding = "SYSTEM";
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2886
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2887 emit interpreter_event
28851
1ac5a76ae91d use [=] capture default specification where possible
John W. Eaton <jwe@octave.org>
parents: 28847
diff changeset
2888 ([=] (interpreter& interp)
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2889 {
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2890 // INTERPRETER THREAD
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2891
27302
5f170ea12fa1 use Qt signals to pass interpreter callbacks to octave-qobject
John W. Eaton <jwe@octave.org>
parents: 27298
diff changeset
2892 F__mfile_encoding__ (interp, ovl (mfile_encoding));
27270
47f42ad90b0b Restore mfile_encoding on startup from GUI settings.
Markus Mützel <markus.muetzel@gmx.de>
parents: 27267
diff changeset
2893 });
25944
ceb508ea92ee refactor GUI main_window class
John W. Eaton <jwe@octave.org>
parents: 25940
diff changeset
2894 }
29144
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2895
29147
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2896 // Get size of screen where the main window is located
29144
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2897 void main_window::get_screen_geometry (int *width, int *height)
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2898 {
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2899 QRect screen_geometry
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2900 = QApplication::desktop ()->availableGeometry (this);
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2901
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2902 *width = screen_geometry.width ();
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2903 *height = screen_geometry.height ();
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2904 }
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2905
29147
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2906 void main_window::resize_dock (QDockWidget *dw, int width, int height)
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2907 {
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2908 #if defined (HAVE_QMAINWINDOW_RESIZEDOCKS)
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2909 // resizeDockWidget was added to Qt in Qt 5.6
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2910 if (width >= 0)
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2911 resizeDocks ({dw},{width},Qt::Horizontal);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2912 if (height >= 0)
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2913 resizeDocks ({dw},{height},Qt::Vertical);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2914 #else
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2915 // This replacement of resizeDockWidget is not very reliable.
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2916 // But even if Qt4 is not yet
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2917 QSize s = dw->widget ()->size ();
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2918 if (width >= 0)
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2919 s.setWidth (width);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2920 if (height >= 0)
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2921 s.setHeight (height);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2922 dw->widget ()->resize (s);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2923 dw->adjustSize ();
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2924 #endif
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2925 }
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2926
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2927 // The default main window size relative to the desktop size
29144
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2928 void main_window::set_default_geometry ()
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2929 {
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2930 int win_x, win_y;
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2931 get_screen_geometry (&win_x, &win_y);
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2932
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2933 move (0, 0);
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2934 resize (2*win_x/3, 7*win_y/8);
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2935 }
7220b59c490b clean up constructing main window layout of the gui
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29095
diff changeset
2936
29147
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2937 void main_window::reset_windows (void)
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2938 {
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2939 // Slot for resetting the window layout to the default one
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2940 hide ();
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2941 showNormal (); // Unmaximize
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2942 do_reset_windows (false); // Add all widgets
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2943 // Re-add after giving time: This seems to be a reliable way to
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2944 // reset the main window's layout
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2945 QTimer::singleShot (250, this, SLOT (do_reset_windows (void)));
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2946 }
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2947
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2948 // Create the default layout of the main window. Do not use
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2949 // restoreState () and restoreGeometry () with default values since
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2950 // this might lead to problems when the Qt version changes
29450
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
2951 void main_window::do_reset_windows (bool show, bool save)
29147
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2952 {
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2953 // Set main window default geometry and store its width for
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2954 // later resizing the command window
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2955 set_default_geometry ();
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2956 int win_x = geometry ().width ();
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2957
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2958 // Resize command window, the important one in the default layout
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2959 resize_dock (m_command_window, 7*win_x/8, -1);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2960
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2961 // See Octave bug #53409 and https://bugreports.qt.io/browse/QTBUG-55357
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2962 #if (QT_VERSION < 0x050601) || (QT_VERSION >= 0x050701)
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2963 setDockOptions (QMainWindow::AnimatedDocks
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2964 | QMainWindow::AllowNestedDocks
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2965 | QMainWindow::AllowTabbedDocks);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2966 #else
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2967 setDockNestingEnabled (true);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2968 #endif
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2969
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2970 // Add the dock widgets and show them
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2971 addDockWidget (Qt::LeftDockWidgetArea, m_file_browser_window);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2972 addDockWidget (Qt::LeftDockWidgetArea, m_workspace_window);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2973 addDockWidget (Qt::LeftDockWidgetArea, m_history_window);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2974
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2975 addDockWidget (Qt::RightDockWidgetArea, m_command_window);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2976
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2977 addDockWidget (Qt::RightDockWidgetArea, m_doc_browser_window);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2978 tabifyDockWidget (m_command_window, m_doc_browser_window);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2979
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2980 addDockWidget (Qt::RightDockWidgetArea, m_variable_editor_window);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2981 tabifyDockWidget (m_command_window, m_variable_editor_window);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2982
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2983 #if defined (HAVE_QSCINTILLA)
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2984 addDockWidget (Qt::RightDockWidgetArea, m_editor_window);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2985 tabifyDockWidget (m_command_window, m_editor_window);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2986 #endif
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2987
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2988 // Resize command window, the important one in the default layout
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2989 resize_dock (m_command_window, 2*win_x/3, -1);
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2990
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2991 // Show main wibdow, save state and geometry of main window and
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2992 // all dock widgets
29450
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
2993 if (show)
29147
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2994 {
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2995 // Show all dock widgets
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2996 for (auto *widget : dock_widget_list ())
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2997 widget->show ();
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2998
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
2999 // Show main window and store size and state
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
3000 showNormal ();
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
3001
29450
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
3002 if (save)
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
3003 {
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
3004 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
3005 gui_settings *settings = rmgr.get_settings ();
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
3006
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
3007 settings->setValue (mw_geometry.key, saveGeometry ());
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
3008 settings->setValue (mw_state.key, saveState ());
6448a10a642a fix restoring the horizontal position of docked gui widgets (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29447
diff changeset
3009 }
29147
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
3010
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
3011 focus_command_window ();
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
3012 }
5d7a651bf0bb fix error when restoring previous main window layout (bug #59426)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29144
diff changeset
3013 }
16539
8ea8df0747e9 make undo button and menu item work for command window
John W. Eaton <jwe@octave.org>
parents: 16532
diff changeset
3014 }