Mercurial > octave
annotate libgui/src/external-editor-interface.cc @ 24718:ea1c88bd4430
move more GUI classes inside octave namespace
* color-picker.cc, color-picker.h, dialog.cc, dialog.h,
documentation-dock-widget.cc, documentation-dock-widget.h,
external-editor-interface.cc, external-editor-interface.h,
octave-cmd.cc, octave-cmd.h, octave-qt-link.cc, octave-qt-link.h,
qtinfo/webinfo.cc, qtinfo/webinfo.h, resource-manager.cc,
resource-manager.h, shortcut-manager.cc, shortcut-manager.h,
tab-bar.cc, tab-bar.h, welcome-wizard.cc, welcome-wizard.h: Move class
declarations and definitions inside octave namespace.
* thread-manager.h, thread-manager.cc (octave::thread_manager):
Rename from octave_thread_manager. Change all uses.
(octave::base_thread_manager): Rename from
octave_base_thread_manager. Change all uses.
* color-picker.h: Provide temporary using decl for
octave::color_picker to import it into the global namespace.
* resource-manager.h: Likewise, for octave::resource_manager.
* shortcut-manager.h: Likewise, for octave::shortcut_manager.
* tab-bar.h: Likewise, for octave::tab_bar.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 09 Feb 2018 16:14:26 -0500 |
parents | 5a10409695b7 |
children | 6652d3823428 |
rev | line source |
---|---|
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
1 /* |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
2 |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
3 Copyright (C) 2017 Torsten |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
4 |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
5 This file is part of Octave. |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
6 |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24011
diff
changeset
|
7 Octave is free software: you can redistribute it and/or modify it |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24011
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
10 (at your option) any later version. |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
11 |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
15 GNU General Public License for more details. |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
16 |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
24011
diff
changeset
|
19 <https://www.gnu.org/licenses/>. |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
20 |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
21 */ |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
22 |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
24 # include "config.h" |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
25 #endif |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
26 |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
27 #include <QSettings> |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
28 #include <QMessageBox> |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
29 #include <QProcess> |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
30 |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
31 #include "external-editor-interface.h" |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
32 #include "resource-manager.h" |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
33 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
34 namespace octave |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
35 { |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
36 external_editor_interface::external_editor_interface (QWidget *p) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
37 : QWidget (p) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
38 { } |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
39 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
40 // Calling the external editor |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
41 bool |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
42 external_editor_interface::call_custom_editor (const QString& file, int line) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
43 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
44 if (line > -1) // check for a specific line (debugging) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
45 return true; // yes: do not open a file in external editor |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
46 else |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
47 line = 0; // no: start external editor at beginning of file |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
48 |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
49 QString editor = external_editor (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
50 if (editor.isEmpty ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
51 return true; |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
52 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
53 // replace macros |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
54 editor.replace ("%f", file); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
55 editor.replace ("%l", QString::number (line)); |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
56 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
57 // start the process and check for success |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
58 bool started_ok = QProcess::startDetached (editor); |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
59 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
60 if (started_ok != true) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
61 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
62 QMessageBox *msgBox = new QMessageBox (QMessageBox::Critical, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
63 tr ("Octave Editor"), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
64 tr ("Could not start custom file editor\n%1"). |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
65 arg (editor), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
66 QMessageBox::Ok); |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
67 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
68 msgBox->setWindowModality (Qt::NonModal); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
69 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
70 msgBox->show (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
71 } |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
72 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
73 return started_ok; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
74 } |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
75 |
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
76 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
77 // Slots for the several signals for invoking the editor |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
78 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
79 void external_editor_interface::request_new_file (const QString&) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
80 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
81 call_custom_editor (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
82 } |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
83 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
84 void external_editor_interface::request_open_file (const QString& file_name, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
85 const QString&, int line, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
86 bool, bool, bool, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
87 const QString&) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
88 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
89 call_custom_editor (file_name, line); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
90 } |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
91 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
92 void external_editor_interface::handle_edit_file_request (const QString& file) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
93 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
94 call_custom_editor (file); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
95 } |
23385
41639665aa34
improve opening files from gui when built without qscintilla (bug #39179)
Torsten <mttl@mailbox.org>
parents:
diff
changeset
|
96 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
97 // Get and verify the settings of the external editor program |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
98 QString external_editor_interface::external_editor (void) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
99 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
100 QSettings *settings = resource_manager::get_settings (); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
101 QString editor = settings->value ("customFileEditor").toString (); |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23385
diff
changeset
|
102 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
103 // check the settings (avoid an empty string) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
104 if (editor.trimmed ().isEmpty ()) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
105 { |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
106 QMessageBox *msgBox |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
107 = new QMessageBox (QMessageBox::Warning, |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
108 tr ("Octave Editor"), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
109 tr ("There is no custom editor configured yet.\n" |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
110 "Do you want to open the preferences?"), |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
111 QMessageBox::No | QMessageBox::Yes); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
112 msgBox->setDefaultButton (QMessageBox::Yes); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
113 msgBox->setAttribute (Qt::WA_DeleteOnClose); |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23385
diff
changeset
|
114 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
115 int button = msgBox->exec (); |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23385
diff
changeset
|
116 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
117 if (button == QMessageBox::Yes) |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
118 emit request_settings_dialog ("editor"); |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
119 } |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23385
diff
changeset
|
120 |
24718
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
121 return editor; |
ea1c88bd4430
move more GUI classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24562
diff
changeset
|
122 } |
24011
9107bae20480
style fixes for some GUI source files
John W. Eaton <jwe@octave.org>
parents:
23385
diff
changeset
|
123 } |