comparison libgui/src/external-editor-interface.cc @ 31648:29d734430e5f stable

maint: Re-indent code after switch to using namespace macros. * BaseControl.cc, BaseControl.h, ButtonControl.cc, ButtonControl.h, ButtonGroup.cc, ButtonGroup.h, Canvas.cc, Canvas.h, CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc, Figure.h, FigureWindow.cc, FigureWindow.h, GLCanvas.cc, GLCanvas.h, GenericEventNotify.h, KeyMap.cc, KeyMap.h, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc, Menu.h, MenuContainer.h, Object.cc, Object.h, ObjectProxy.cc, ObjectProxy.h, Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h, QtHandlesUtils.cc, QtHandlesUtils.h, RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc, SliderControl.h, Table.cc, Table.h, TextControl.cc, TextControl.h, TextEdit.cc, TextEdit.h, ToggleButtonControl.cc, ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, ToolBarButton.h, annotation-dialog.cc, annotation-dialog.h, gl-select.cc, gl-select.h, qopengl-functions.h, qt-graphics-toolkit.cc, qt-graphics-toolkit.h, module.mk, QTerminal.h, color-picker.cc, color-picker.h, command-widget.cc, command-widget.h, community-news.cc, community-news.h, dialog.cc, dialog.h, documentation-bookmarks.cc, documentation-bookmarks.h, documentation-dock-widget.cc, documentation-dock-widget.h, documentation.cc, documentation.h, dw-main-window.cc, dw-main-window.h, external-editor-interface.cc, external-editor-interface.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, find-files-dialog.h, find-files-model.cc, find-files-model.h, graphics-init.cc, graphics-init.h, gui-settings.cc, gui-settings.h, gui-utils.cc, gui-utils.h, history-dock-widget.cc, history-dock-widget.h, interpreter-qobject.cc, interpreter-qobject.h, led-indicator.cc, led-indicator.h, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, find-dialog.h, marker.cc, marker.h, octave-qscintilla.cc, octave-qscintilla.h, octave-txt-lexer.cc, octave-txt-lexer.h, main-window.cc, main-window.h, news-reader.cc, news-reader.h, octave-dock-widget.cc, octave-dock-widget.h, octave-qobject.cc, octave-qobject.h, qt-application.cc, qt-application.h, qt-interpreter-events.cc, qt-interpreter-events.h, qt-utils.h, release-notes.cc, release-notes.h, resource-manager.cc, resource-manager.h, set-path-dialog.cc, set-path-dialog.h, set-path-model.cc, set-path-model.h, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, tab-bar.cc, tab-bar.h, terminal-dock-widget.cc, terminal-dock-widget.h, variable-editor-model.cc, variable-editor-model.h, variable-editor.cc, variable-editor.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc, workspace-model.h, workspace-view.cc, workspace-view.h: Re-indent code after switch to using namespace macros.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Dec 2022 14:53:00 -0500
parents c6d54dd31a7e
children deb553ac2c54 597f3ee61a48
comparison
equal deleted inserted replaced
31646:c6d54dd31a7e 31648:29d734430e5f
35 #include "gui-preferences-global.h" 35 #include "gui-preferences-global.h"
36 #include "octave-qobject.h" 36 #include "octave-qobject.h"
37 37
38 OCTAVE_BEGIN_NAMESPACE(octave) 38 OCTAVE_BEGIN_NAMESPACE(octave)
39 39
40 external_editor_interface::external_editor_interface (QWidget *p, 40 external_editor_interface::external_editor_interface (QWidget *p,
41 base_qobject& oct_qobj) 41 base_qobject& oct_qobj)
42 : QWidget (p), m_octave_qobj (oct_qobj) 42 : QWidget (p), m_octave_qobj (oct_qobj)
43 { } 43 { }
44 44
45 // Calling the external editor 45 // Calling the external editor
46 bool 46 bool
47 external_editor_interface::call_custom_editor (const QString& file, int line) 47 external_editor_interface::call_custom_editor (const QString& file, int line)
48 { 48 {
49 QString editor = external_editor (); 49 QString editor = external_editor ();
50 if (editor.isEmpty ()) 50 if (editor.isEmpty ())
51 return true; 51 return true;
52 52
53 if (line < 0) 53 if (line < 0)
54 line = 0; 54 line = 0;
55 55
56 // replace macros 56 // replace macros
57 editor.replace ("%f", file); 57 editor.replace ("%f", file);
58 editor.replace ("%l", QString::number (line)); 58 editor.replace ("%l", QString::number (line));
59 59
60 QStringList arguments = editor.split (QRegExp("\\s+")); 60 QStringList arguments = editor.split (QRegExp("\\s+"));
61 editor = arguments.takeFirst (); 61 editor = arguments.takeFirst ();
62 62
63 // start the process and check for success 63 // start the process and check for success
64 bool started_ok = QProcess::startDetached (editor, arguments); 64 bool started_ok = QProcess::startDetached (editor, arguments);
65 65
66 if (started_ok != true) 66 if (started_ok != true)
67 { 67 {
68 QMessageBox *msgBox = new QMessageBox (QMessageBox::Critical, 68 QMessageBox *msgBox = new QMessageBox (QMessageBox::Critical,
69 tr ("Octave Editor"), 69 tr ("Octave Editor"),
70 tr ("Could not start custom file editor\n%1"). 70 tr ("Could not start custom file editor\n%1").
71 arg (editor), 71 arg (editor),
72 QMessageBox::Ok); 72 QMessageBox::Ok);
73 73
74 msgBox->setWindowModality (Qt::NonModal); 74 msgBox->setWindowModality (Qt::NonModal);
75 msgBox->setAttribute (Qt::WA_DeleteOnClose); 75 msgBox->setAttribute (Qt::WA_DeleteOnClose);
76 msgBox->show (); 76 msgBox->show ();
77 } 77 }
78 78
79 return started_ok; 79 return started_ok;
80 } 80 }
81 81
82 // Slots for the several signals for invoking the editor 82 // Slots for the several signals for invoking the editor
83 83
84 void external_editor_interface::request_new_file (const QString&) 84 void external_editor_interface::request_new_file (const QString&)
85 { 85 {
86 call_custom_editor (); 86 call_custom_editor ();
87 } 87 }
88 88
89 void external_editor_interface::request_open_file (const QString& file_name, 89 void external_editor_interface::request_open_file (const QString& file_name,
90 const QString&, int line, 90 const QString&, int line,
91 bool, bool, bool, 91 bool, bool, bool,
92 const QString&) 92 const QString&)
93 { 93 {
94 call_custom_editor (file_name, line); 94 call_custom_editor (file_name, line);
95 } 95 }
96 96
97 void external_editor_interface::handle_edit_file_request (const QString& file) 97 void external_editor_interface::handle_edit_file_request (const QString& file)
98 { 98 {
99 call_custom_editor (file); 99 call_custom_editor (file);
100 } 100 }
101 101
102 // Get and verify the settings of the external editor program 102 // Get and verify the settings of the external editor program
103 QString external_editor_interface::external_editor (void) 103 QString external_editor_interface::external_editor (void)
104 { 104 {
105 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); 105 resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
106 gui_settings *settings = rmgr.get_settings (); 106 gui_settings *settings = rmgr.get_settings ();
107 QString editor = settings->value (global_custom_editor.key, 107 QString editor = settings->value (global_custom_editor.key,
108 global_custom_editor.def).toString (); 108 global_custom_editor.def).toString ();
109 109
110 // check the settings (avoid an empty string) 110 // check the settings (avoid an empty string)
111 if (editor.trimmed ().isEmpty ()) 111 if (editor.trimmed ().isEmpty ())
112 { 112 {
113 QMessageBox *msgBox 113 QMessageBox *msgBox
114 = new QMessageBox (QMessageBox::Warning, 114 = new QMessageBox (QMessageBox::Warning,
115 tr ("Octave Editor"), 115 tr ("Octave Editor"),
116 tr ("There is no custom editor configured yet.\n" 116 tr ("There is no custom editor configured yet.\n"
117 "Do you want to open the preferences?"), 117 "Do you want to open the preferences?"),
118 QMessageBox::No | QMessageBox::Yes); 118 QMessageBox::No | QMessageBox::Yes);
119 msgBox->setDefaultButton (QMessageBox::Yes); 119 msgBox->setDefaultButton (QMessageBox::Yes);
120 msgBox->setAttribute (Qt::WA_DeleteOnClose); 120 msgBox->setAttribute (Qt::WA_DeleteOnClose);
121 121
122 int button = msgBox->exec (); 122 int button = msgBox->exec ();
123 123
124 if (button == QMessageBox::Yes) 124 if (button == QMessageBox::Yes)
125 emit request_settings_dialog ("editor"); 125 emit request_settings_dialog ("editor");
126 } 126 }
127 127
128 return editor; 128 return editor;
129 } 129 }
130 130
131 OCTAVE_END_NAMESPACE(octave) 131 OCTAVE_END_NAMESPACE(octave)