Mercurial > hg > octave-nkf
annotate gui/src/FileEditorMdiSubWindow.cpp @ 13654:c67f7d390a1a
editor: comment/uncomment selected text
author | ttl <ttl@justmail.de> |
---|---|
date | Thu, 25 Aug 2011 20:12:31 +0200 |
parents | b93bfa9486ad |
children | 1347d498959c |
rev | line source |
---|---|
13504
13e3d60aff2d
Replaced Quint with OctaveGUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13503
diff
changeset
|
1 /* OctaveGUI - A graphical user interface for Octave |
13501 | 2 * Copyright (C) 2011 Jacob Dawid |
3 * jacob.dawid@googlemail.com | |
4 * | |
5 * This program is free software: you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License as published by | |
7 * the Free Software Foundation, either version 3 of the License, or | |
8 * (at your option) any later version. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 */ | |
18 | |
19 #include "FileEditorMdiSubWindow.h" | |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
20 #include "MainWindow.h" |
13501 | 21 #include <QVBoxLayout> |
22 #include <QApplication> | |
23 #include <QFile> | |
13584 | 24 #include <QFont> |
13501 | 25 #include <QFileDialog> |
26 #include <QMessageBox> | |
27 #include <QStyle> | |
28 #include <QTextStream> | |
29 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
30 FileEditorMdiSubWindow::FileEditorMdiSubWindow (QWidget * parent):QMdiSubWindow |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
31 (parent) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
32 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
33 construct (); |
13501 | 34 } |
35 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
36 FileEditorMdiSubWindow::~FileEditorMdiSubWindow () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
37 { |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
38 } |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
39 |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
40 void |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
41 FileEditorMdiSubWindow::closeEvent(QCloseEvent *event) |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
42 { |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
43 // ignore close event if file is not saved and user cancels closing this window |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
44 // TODO: This does not work if the main window is closed! |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
45 if (checkFileModified ("Close File")==QMessageBox::Cancel) |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
46 { |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
47 event->ignore(); |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
48 } |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
49 else |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
50 { |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
51 event->accept(); |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
52 } |
13501 | 53 } |
54 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
55 void |
13584 | 56 FileEditorMdiSubWindow::handleMarginClicked(int margin, int line, Qt::KeyboardModifiers state) |
57 { | |
13587 | 58 Q_UNUSED (state); |
13584 | 59 if ( margin == 1 ) // marker margin |
60 { | |
61 unsigned int mask = m_editor->markersAtLine (line); | |
62 if (mask && (1 << MARKER_BOOKMARK)) | |
63 m_editor->markerDelete(line,MARKER_BOOKMARK); | |
64 else | |
65 m_editor->markerAdd(line,MARKER_BOOKMARK); | |
66 } | |
67 } | |
68 | |
69 void | |
13557
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
70 FileEditorMdiSubWindow::handleModificationChanged(bool modified) |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
71 { |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
72 if ( modified ) |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
73 { |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
74 QString title(m_fileName); |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
75 setWindowTitle(title.prepend("* ")); |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
76 } |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
77 else |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
78 setWindowTitle (m_fileName); |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
79 } |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
80 |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
81 void |
13584 | 82 FileEditorMdiSubWindow::handleCopyAvailable(bool enableCopy) |
83 { | |
84 m_copyAction->setEnabled(enableCopy); | |
85 m_cutAction->setEnabled(enableCopy); | |
86 } | |
87 | |
88 | |
89 void | |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
90 FileEditorMdiSubWindow::openFile () |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
91 { |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
92 if (checkFileModified ("Open File")==QMessageBox::Cancel) |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
93 { |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
94 return; // existing file not saved and opening another file canceled by user |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
95 } |
13649
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
96 QString openFileName; |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
97 QFileDialog dlg(this); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
98 dlg.setNameFilter(SAVE_FILE_FILTER); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
99 dlg.setAcceptMode(QFileDialog::AcceptOpen); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
100 dlg.setViewMode(QFileDialog::Detail); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
101 if ( dlg.exec() ) |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
102 { |
13649
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
103 openFileName = dlg.selectedFiles().at(0); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
104 if (openFileName.isEmpty ()) |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
105 return; |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
106 loadFile(openFileName); |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
107 } |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
108 } |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
109 |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
110 void |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
111 FileEditorMdiSubWindow::loadFile (QString fileName) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
112 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
113 QFile file (fileName); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
114 if (!file.open (QFile::ReadOnly)) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
115 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
116 QMessageBox::warning (this, tr ("File Editor"), |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
117 tr ("Cannot read file %1:\n%2.").arg (fileName). |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
118 arg (file.errorString ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
119 return; |
13501 | 120 } |
121 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
122 QTextStream in (&file); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
123 QApplication::setOverrideCursor (Qt::WaitCursor); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
124 m_editor->setText (in.readAll ()); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
125 QApplication::restoreOverrideCursor (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
126 |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
127 m_fileName = fileName; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
128 setWindowTitle (fileName); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
129 m_statusBar->showMessage (tr ("File loaded."), 2000); |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
130 m_editor->setModified (false); // loaded file is not modified yet |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
131 } |
13501 | 132 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
133 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
134 FileEditorMdiSubWindow::newFile () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
135 { |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
136 if (checkFileModified ("Open New File")==QMessageBox::Cancel) |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
137 { |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
138 return; // existing file not saved and creating new file canceled by user |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
139 } |
13529 | 140 m_fileName = UNNAMED_FILE; |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
141 setWindowTitle (m_fileName); |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
142 m_editor->setText (""); |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
143 m_editor->setModified (false); // new file is not modified yet |
13501 | 144 } |
145 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
146 int |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
147 FileEditorMdiSubWindow::checkFileModified (QString msg) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
148 { |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
149 int decision = QMessageBox::Yes; |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
150 if (m_editor->isModified ()) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
151 { |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
152 // file is modified but not saved, aks user what to do |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
153 decision = QMessageBox::question (this, |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
154 msg, |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
155 tr ("Do you want to save the current file\n%1 ?"). |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
156 arg (m_fileName), |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
157 QMessageBox::Cancel, |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
158 QMessageBox::No, |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
159 QMessageBox::Yes); |
13501 | 160 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
161 if (decision == QMessageBox::Yes) |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
162 { |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
163 saveFile (); |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
164 if (m_editor->isModified ()) |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
165 { |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
166 // If the user attempted to save the file, but it's still |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
167 // modified, then probably something went wrong, so return cancel |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
168 // for cancel this operation |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
169 return (QMessageBox::Cancel); |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
170 } |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
171 } |
13501 | 172 } |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
173 return (decision); |
13501 | 174 } |
175 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
176 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
177 FileEditorMdiSubWindow::saveFile () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
178 { |
13529 | 179 saveFile(m_fileName); |
180 } | |
181 | |
182 void | |
13649
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
183 FileEditorMdiSubWindow::saveFile (QString saveFileName) |
13529 | 184 { |
185 // it is a new file with the name "<unnamed>" -> call saveFielAs | |
13649
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
186 if (saveFileName==UNNAMED_FILE || saveFileName.isEmpty ()) |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
187 { |
13529 | 188 saveFileAs(); |
189 return; | |
13501 | 190 } |
191 | |
13649
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
192 // open the file for writing |
13529 | 193 QFile file (saveFileName); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
194 if (!file.open (QFile::WriteOnly)) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
195 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
196 QMessageBox::warning (this, tr ("File Editor"), |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
197 tr ("Cannot write file %1:\n%2."). |
13529 | 198 arg (saveFileName).arg (file.errorString ())); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
199 return; |
13501 | 200 } |
201 | |
13529 | 202 // save the contents into the file |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
203 QTextStream out (&file); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
204 QApplication::setOverrideCursor (Qt::WaitCursor); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
205 out << m_editor->text (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
206 QApplication::restoreOverrideCursor (); |
13529 | 207 m_fileName = saveFileName; // save file name for later use |
208 setWindowTitle(m_fileName); // set the window title to actual file name | |
209 m_statusBar->showMessage (tr ("File %1 saved").arg(m_fileName), 2000); | |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
210 m_editor->setModified (false); // files is save -> not modified |
13501 | 211 } |
212 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
213 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
214 FileEditorMdiSubWindow::saveFileAs () |
13529 | 215 { |
13649
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
216 QString saveFileName(m_fileName); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
217 QFileDialog dlg(this); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
218 if (saveFileName==UNNAMED_FILE || saveFileName.isEmpty ()) |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
219 { |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
220 saveFileName = QDir::homePath(); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
221 dlg.setDirectory(saveFileName); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
222 } |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
223 else |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
224 { |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
225 dlg.selectFile(saveFileName); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
226 } |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
227 dlg.setNameFilter(SAVE_FILE_FILTER); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
228 dlg.setDefaultSuffix("m"); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
229 dlg.setAcceptMode(QFileDialog::AcceptSave); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
230 dlg.setViewMode(QFileDialog::Detail); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
231 if ( dlg.exec() ) |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
232 { |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
233 saveFileName = dlg.selectedFiles().at(0); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
234 if (saveFileName.isEmpty ()) |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
235 return; |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
236 saveFile(saveFileName); |
0a19410e88c0
improve save as: auto-add extension .m with check for overwrite
ttl <ttl@justmail.de>
parents:
13648
diff
changeset
|
237 } |
13501 | 238 } |
239 | |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
240 // handle the run command |
13558
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
241 void |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
242 FileEditorMdiSubWindow::runFile () |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
243 { |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
244 if (m_editor->isModified ()) |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
245 saveFile(m_fileName); |
13648
da69cec2459f
Renamed OctaveTerminal to TerminalView.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13642
diff
changeset
|
246 m_terminalEmulation->transmitText (QString ("run \'%1\'\n").arg (m_fileName)); |
da69cec2459f
Renamed OctaveTerminal to TerminalView.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13642
diff
changeset
|
247 //m_terminalEmulation->setFocus (); |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
248 } |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
249 |
13654
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
250 |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
251 // (un)comment selected text |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
252 void |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
253 FileEditorMdiSubWindow::commentSelectedText () |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
254 { |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
255 doCommentSelectedText (true); |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
256 } |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
257 void |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
258 FileEditorMdiSubWindow::uncommentSelectedText () |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
259 { |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
260 doCommentSelectedText (false); |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
261 } |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
262 void |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
263 FileEditorMdiSubWindow::doCommentSelectedText (bool comment) |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
264 { |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
265 if ( m_editor->hasSelectedText() ) |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
266 { |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
267 int lineFrom, lineTo, colFrom, colTo, i; |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
268 m_editor->getSelection (&lineFrom,&colFrom,&lineTo,&colTo); |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
269 if ( colTo == 0 ) // the beginning of last line is not selected |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
270 lineTo--; // stop at line above |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
271 for ( i=lineFrom; i<=lineTo; i++ ) |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
272 { |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
273 if ( comment ) |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
274 m_editor->insertAt("%",i,0); |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
275 else |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
276 { |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
277 QString line(m_editor->text(i)); |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
278 if ( line.startsWith("%") ) |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
279 { |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
280 m_editor->setSelection(i,0,i,1); |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
281 m_editor->removeSelectedText(); |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
282 } |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
283 } |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
284 } |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
285 } |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
286 } |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
287 |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
288 |
13650
b93bfa9486ad
editor: bookmarks now toggled by F7 (bug #34066), menu entry for removing all bookmarks
ttl <ttl@justmail.de>
parents:
13649
diff
changeset
|
289 // remove bookmarks |
b93bfa9486ad
editor: bookmarks now toggled by F7 (bug #34066), menu entry for removing all bookmarks
ttl <ttl@justmail.de>
parents:
13649
diff
changeset
|
290 void |
b93bfa9486ad
editor: bookmarks now toggled by F7 (bug #34066), menu entry for removing all bookmarks
ttl <ttl@justmail.de>
parents:
13649
diff
changeset
|
291 FileEditorMdiSubWindow::removeBookmark () |
b93bfa9486ad
editor: bookmarks now toggled by F7 (bug #34066), menu entry for removing all bookmarks
ttl <ttl@justmail.de>
parents:
13649
diff
changeset
|
292 { |
b93bfa9486ad
editor: bookmarks now toggled by F7 (bug #34066), menu entry for removing all bookmarks
ttl <ttl@justmail.de>
parents:
13649
diff
changeset
|
293 m_editor->markerDeleteAll(MARKER_BOOKMARK); |
b93bfa9486ad
editor: bookmarks now toggled by F7 (bug #34066), menu entry for removing all bookmarks
ttl <ttl@justmail.de>
parents:
13649
diff
changeset
|
294 } |
13584 | 295 // toggle bookmark |
296 void | |
297 FileEditorMdiSubWindow::toggleBookmark () | |
298 { | |
299 int line,cur; | |
300 m_editor->getCursorPosition(&line,&cur); | |
301 if ( m_editor->markersAtLine (line) && (1 << MARKER_BOOKMARK) ) | |
302 m_editor->markerDelete(line,MARKER_BOOKMARK); | |
303 else | |
304 m_editor->markerAdd(line,MARKER_BOOKMARK); | |
305 } | |
306 // goto next bookmark | |
307 void | |
308 FileEditorMdiSubWindow::nextBookmark () | |
309 { | |
310 int line,cur,nextline; | |
311 m_editor->getCursorPosition(&line,&cur); | |
312 if ( m_editor->markersAtLine(line) && (1 << MARKER_BOOKMARK) ) | |
313 line++; // we have a bookmark here, so start search from next line | |
314 nextline = m_editor->markerFindNext(line,(1 << MARKER_BOOKMARK)); | |
315 m_editor->setCursorPosition(nextline,0); | |
316 } | |
317 // goto previous bookmark | |
318 void | |
319 FileEditorMdiSubWindow::prevBookmark () | |
320 { | |
321 int line,cur,prevline; | |
322 m_editor->getCursorPosition(&line,&cur); | |
323 if ( m_editor->markersAtLine(line) && (1 << MARKER_BOOKMARK) ) | |
324 line--; // we have a bookmark here, so start search from prev line | |
325 prevline = m_editor->markerFindPrevious(line,(1 << MARKER_BOOKMARK)); | |
326 m_editor->setCursorPosition(prevline,0); | |
327 } | |
328 | |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
329 // function for setting the already existing lexer from MainWindow |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
330 void |
13648
da69cec2459f
Renamed OctaveTerminal to TerminalView.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13642
diff
changeset
|
331 FileEditorMdiSubWindow::initEditor (TerminalEmulation* terminalEmulation, |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
332 LexerOctaveGui* lexer) |
13558
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
333 { |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
334 m_editor->setLexer(lexer); |
13648
da69cec2459f
Renamed OctaveTerminal to TerminalView.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13642
diff
changeset
|
335 m_terminalEmulation = terminalEmulation; // for sending commands to octave |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
336 // TODO: make a global commandOctave function? |
13558
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
337 } |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
338 |
13555
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
339 // TODO: Do we still need tool tips in the status bar? Tool tips are now |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
340 // shown directly at the theme icons |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
341 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
342 FileEditorMdiSubWindow::showToolTipNew () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
343 { |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
344 m_statusBar->showMessage ("Create a new file", 2000); |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
345 } |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
346 |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
347 void |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
348 FileEditorMdiSubWindow::showToolTipOpen () |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
349 { |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
350 m_statusBar->showMessage ("Open a file", 2000); |
13501 | 351 } |
352 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
353 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
354 FileEditorMdiSubWindow::showToolTipSave () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
355 { |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
356 m_statusBar->showMessage ("Save the file", 2000); |
13501 | 357 } |
358 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
359 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
360 FileEditorMdiSubWindow::showToolTipSaveAs () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
361 { |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
362 m_statusBar->showMessage ("Save the file as", 2000); |
13501 | 363 } |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
364 |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
365 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
366 FileEditorMdiSubWindow::showToolTipUndo () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
367 { |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
368 m_statusBar->showMessage ("Revert previous changes", 2000); |
13501 | 369 } |
370 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
371 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
372 FileEditorMdiSubWindow::showToolTipRedo () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
373 { |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
374 m_statusBar->showMessage ("Append previous changes", 2000); |
13501 | 375 } |
376 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
377 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
378 FileEditorMdiSubWindow::registerModified (bool modified) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
379 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
380 m_modified = modified; |
13501 | 381 } |
382 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
383 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
384 FileEditorMdiSubWindow::construct () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
385 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
386 QStyle *style = QApplication::style (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
387 setWidget (new QWidget ()); |
13566
d22b9973120f
Renamed language files to match convention.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13562
diff
changeset
|
388 |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
389 m_menuBar = new QMenuBar (this); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
390 m_toolBar = new QToolBar (this); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
391 m_statusBar = new QStatusBar (this); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
392 m_editor = new QsciScintilla (this); |
13503
5ab40ef3d241
Merged diff from Torsten.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13501
diff
changeset
|
393 |
13584 | 394 // markers |
13558
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
395 m_editor->setMarginType (1, QsciScintilla::SymbolMargin); |
13584 | 396 m_editor->setMarginSensitivity(1,true); |
397 m_editor->markerDefine(QsciScintilla::RightTriangle,MARKER_BOOKMARK); | |
398 connect(m_editor,SIGNAL(marginClicked(int,int,Qt::KeyboardModifiers)), | |
399 this,SLOT(handleMarginClicked(int,int,Qt::KeyboardModifiers))); | |
400 | |
401 // line numbers | |
402 QFont marginFont("Monospace",9); | |
403 m_editor->setMarginsFont(marginFont); | |
404 QFontMetrics metrics(marginFont); | |
405 m_editor->setMarginsForegroundColor(QColor(96,96,96)); | |
406 m_editor->setMarginsBackgroundColor(QColor(232,232,220)); | |
13558
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
407 m_editor->setMarginType (2, QsciScintilla::TextMargin); |
13584 | 408 m_editor->setMarginWidth(2, metrics.width("99999")); |
409 m_editor->setMarginLineNumbers(2, true); | |
410 | |
411 // code folding | |
13558
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
412 m_editor->setMarginType (3, QsciScintilla::SymbolMargin); |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
413 m_editor->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
414 |
13584 | 415 m_editor->setCaretLineVisible(true); |
416 m_editor->setCaretLineBackgroundColor(QColor(255,255,200)); | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
417 m_editor->setBraceMatching (QsciScintilla::SloppyBraceMatch); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
418 m_editor->setAutoIndent (true); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
419 m_editor->setIndentationWidth (2); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
420 m_editor->setIndentationsUseTabs (false); |
13558
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
421 m_editor->autoCompleteFromAll(); |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
422 m_editor->setAutoCompletionSource(QsciScintilla::AcsAPIs); |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
423 m_editor->setAutoCompletionThreshold (3); |
13631
9ad313bcee2d
Possible fixed Andriys bug with russian symbols.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13587
diff
changeset
|
424 m_editor->setUtf8 (true); |
13503
5ab40ef3d241
Merged diff from Torsten.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13501
diff
changeset
|
425 |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
426 // The Actions |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
427 |
13555
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
428 // Theme icons with QStyle icons as fallback |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
429 QAction *closeAction = new QAction ( |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
430 QIcon::fromTheme("window-close",style->standardIcon (QStyle::SP_DialogCloseButton)), |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
431 tr("&Close File"), m_toolBar); |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
432 QAction *newAction = new QAction ( |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
433 QIcon::fromTheme("document-new",style->standardIcon (QStyle::SP_FileIcon)), |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
434 tr("&New File"), m_toolBar); |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
435 QAction *openAction = new QAction ( |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
436 QIcon::fromTheme("document-open",style->standardIcon (QStyle::SP_DirOpenIcon)), |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
437 tr("&Open File"), m_toolBar); |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
438 QAction *saveAction = new QAction ( |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
439 QIcon::fromTheme("document-save",style->standardIcon (QStyle::SP_DriveHDIcon)), |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
440 tr("&Save File"), m_toolBar); |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
441 QAction *saveAsAction = new QAction ( |
13555
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
442 QIcon::fromTheme("document-save-as",style->standardIcon (QStyle::SP_DriveFDIcon)), |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
443 tr("Save File &As"), m_toolBar); |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
444 QAction *undoAction = new QAction ( |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
445 QIcon::fromTheme("edit-undo",style->standardIcon (QStyle::SP_ArrowLeft)), |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
446 tr("&Undo"), m_toolBar); |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
447 QAction *redoAction = new QAction ( |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
448 QIcon::fromTheme("edit-redo",style->standardIcon (QStyle::SP_ArrowRight)), |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
449 tr("&Redo"), m_toolBar); |
13584 | 450 m_copyAction = new QAction (QIcon::fromTheme("edit-copy"),tr("&Copy"),m_toolBar); |
451 m_cutAction = new QAction (QIcon::fromTheme("edit-cut"),tr("Cu&t"),m_toolBar); | |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
452 QAction *pasteAction = new QAction (QIcon::fromTheme("edit-paste"),tr("&Paste"),m_toolBar); |
13584 | 453 QAction *nextBookmarkAction = new QAction (tr("&Next Bookmark"),m_toolBar); |
454 QAction *prevBookmarkAction = new QAction (tr("Pre&vious Bookmark"),m_toolBar); | |
455 QAction *toggleBookmarkAction = new QAction (tr("Toggle &Bookmark"),m_toolBar); | |
13654
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
456 QAction *removeBookmarkAction = new QAction (tr("&Remove All Bookmarks"),m_toolBar); |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
457 QAction *commentSelectedAction = new QAction (tr("&Comment Selected Text"),m_toolBar); |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
458 QAction *uncommentSelectedAction = new QAction (tr("&Uncomment Selected Text"),m_toolBar); |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
459 QAction *runAction = new QAction ( |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
460 QIcon::fromTheme("media-play",style->standardIcon (QStyle::SP_MediaPlay)), |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
461 tr("&Run File"), m_toolBar); |
13501 | 462 |
13584 | 463 // some actions are disabled from the beginning |
464 m_copyAction->setEnabled(false); | |
465 m_cutAction->setEnabled(false); | |
466 connect(m_editor,SIGNAL(copyAvailable(bool)),this,SLOT(handleCopyAvailable(bool))); | |
467 | |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
468 // short cuts |
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
469 newAction->setShortcut(QKeySequence::New); |
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
470 openAction->setShortcut(QKeySequence::Open); |
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
471 saveAction->setShortcut(QKeySequence::Save); |
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
472 saveAsAction->setShortcut(QKeySequence::SaveAs); |
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
473 undoAction->setShortcut(QKeySequence::Undo); |
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
474 redoAction->setShortcut(QKeySequence::Redo); |
13584 | 475 m_copyAction->setShortcut(QKeySequence::Copy); |
476 m_cutAction->setShortcut(QKeySequence::Cut); | |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
477 pasteAction->setShortcut(QKeySequence::Paste); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
478 runAction->setShortcut(Qt::Key_F5); |
13584 | 479 nextBookmarkAction->setShortcut(Qt::Key_F2); |
480 prevBookmarkAction->setShortcut(Qt::SHIFT + Qt::Key_F2); | |
13650
b93bfa9486ad
editor: bookmarks now toggled by F7 (bug #34066), menu entry for removing all bookmarks
ttl <ttl@justmail.de>
parents:
13649
diff
changeset
|
481 toggleBookmarkAction->setShortcut(Qt::Key_F7); |
13654
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
482 commentSelectedAction->setShortcut(Qt::CTRL + Qt::Key_T); |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
483 uncommentSelectedAction->setShortcut(Qt::CTRL + Qt::Key_U); |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
484 |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
485 // toolbar |
13584 | 486 m_toolBar->setIconSize(QSize(16,16)); // smaller icons (make configurable in user settings?) |
13550
cd66481d55b0
Added close button to file editor, assorted subwindows after importance.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13530
diff
changeset
|
487 m_toolBar->addAction (closeAction); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
488 m_toolBar->addAction (newAction); |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
489 m_toolBar->addAction (openAction); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
490 m_toolBar->addAction (saveAction); |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
491 m_toolBar->addAction (saveAsAction); |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
492 m_toolBar->addSeparator(); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
493 m_toolBar->addAction (undoAction); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
494 m_toolBar->addAction (redoAction); |
13584 | 495 m_toolBar->addAction (m_copyAction); |
496 m_toolBar->addAction (m_cutAction); | |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
497 m_toolBar->addAction (pasteAction); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
498 m_toolBar->addSeparator(); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
499 m_toolBar->addAction (runAction); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
500 |
13566
d22b9973120f
Renamed language files to match convention.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13562
diff
changeset
|
501 // menu bar |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
502 QMenu *fileMenu = new QMenu(tr("&File"),m_menuBar); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
503 fileMenu->addAction(newAction); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
504 fileMenu->addAction(openAction); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
505 fileMenu->addAction(saveAction); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
506 fileMenu->addAction(saveAsAction); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
507 fileMenu->addSeparator(); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
508 fileMenu->addAction (closeAction); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
509 m_menuBar->addMenu(fileMenu); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
510 QMenu *editMenu = new QMenu(tr("&Edit"),m_menuBar); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
511 editMenu->addAction(undoAction); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
512 editMenu->addAction(redoAction); |
13584 | 513 editMenu->addSeparator(); |
514 editMenu->addAction(m_copyAction); | |
515 editMenu->addAction(m_cutAction); | |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
516 editMenu->addAction(pasteAction); |
13584 | 517 editMenu->addSeparator(); |
13654
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
518 editMenu->addAction(commentSelectedAction); |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
519 editMenu->addAction(uncommentSelectedAction); |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
520 editMenu->addSeparator(); |
13584 | 521 editMenu->addAction(toggleBookmarkAction); |
522 editMenu->addAction(nextBookmarkAction); | |
523 editMenu->addAction(prevBookmarkAction); | |
13650
b93bfa9486ad
editor: bookmarks now toggled by F7 (bug #34066), menu entry for removing all bookmarks
ttl <ttl@justmail.de>
parents:
13649
diff
changeset
|
524 editMenu->addAction(removeBookmarkAction); |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
525 m_menuBar->addMenu(editMenu); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
526 QMenu *runMenu = new QMenu(tr("&Run"),m_menuBar); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
527 runMenu->addAction(runAction); |
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
528 m_menuBar->addMenu(runMenu); |
13501 | 529 |
13566
d22b9973120f
Renamed language files to match convention.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13562
diff
changeset
|
530 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
531 QVBoxLayout *layout = new QVBoxLayout (); |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
532 layout->addWidget (m_menuBar); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
533 layout->addWidget (m_toolBar); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
534 layout->addWidget (m_editor); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
535 layout->addWidget (m_statusBar); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
536 layout->setMargin (2); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
537 widget ()->setLayout (layout); |
13501 | 538 |
13550
cd66481d55b0
Added close button to file editor, assorted subwindows after importance.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13530
diff
changeset
|
539 connect (closeAction, SIGNAL (triggered()), this, SLOT (close())); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
540 connect (newAction, SIGNAL (triggered ()), this, SLOT (newFile ())); |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
541 connect (openAction, SIGNAL (triggered ()), this, SLOT (openFile ())); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
542 connect (undoAction, SIGNAL (triggered ()), m_editor, SLOT (undo ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
543 connect (redoAction, SIGNAL (triggered ()), m_editor, SLOT (redo ())); |
13584 | 544 connect (m_copyAction, SIGNAL (triggered ()), m_editor, SLOT (copy ())); |
545 connect (m_cutAction, SIGNAL (triggered ()), m_editor, SLOT (cut ())); | |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
546 connect (pasteAction, SIGNAL (triggered ()), m_editor, SLOT (paste ())); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
547 connect (saveAction, SIGNAL (triggered ()), this, SLOT (saveFile ())); |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
548 connect (saveAsAction, SIGNAL (triggered ()), this, SLOT (saveFileAs ())); |
13562
a89aa9e05e19
editor: menu bar, run editor file in octave
ttl <ttl@justmail.de>
parents:
13558
diff
changeset
|
549 connect (runAction, SIGNAL (triggered ()), this, SLOT (runFile ())); |
13584 | 550 connect (toggleBookmarkAction, SIGNAL (triggered ()), this, SLOT (toggleBookmark ())); |
551 connect (nextBookmarkAction, SIGNAL (triggered ()), this, SLOT (nextBookmark ())); | |
552 connect (prevBookmarkAction, SIGNAL (triggered ()), this, SLOT (prevBookmark ())); | |
13650
b93bfa9486ad
editor: bookmarks now toggled by F7 (bug #34066), menu entry for removing all bookmarks
ttl <ttl@justmail.de>
parents:
13649
diff
changeset
|
553 connect (removeBookmarkAction, SIGNAL (triggered ()), this, SLOT (removeBookmark ())); |
13654
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
554 connect (commentSelectedAction, SIGNAL (triggered ()), this, SLOT (commentSelectedText ())); |
c67f7d390a1a
editor: comment/uncomment selected text
ttl <ttl@justmail.de>
parents:
13650
diff
changeset
|
555 connect (uncommentSelectedAction, SIGNAL (triggered ()), this, SLOT (uncommentSelectedText ())); |
13501 | 556 |
13555
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
557 // TODO: Do we still need tool tips in the status bar? Tool tips are now |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
558 // shown directly at the theme icons |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
559 connect (newAction, SIGNAL (hovered ()), this, SLOT (showToolTipNew ())); |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
560 connect (openAction, SIGNAL (hovered ()), this, SLOT (showToolTipOpen ())); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
561 connect (undoAction, SIGNAL (hovered ()), this, SLOT (showToolTipUndo ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
562 connect (redoAction, SIGNAL (hovered ()), this, SLOT (showToolTipRedo ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
563 connect (saveAction, SIGNAL (hovered ()), this, SLOT (showToolTipSave ())); |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
564 connect (saveAsAction, SIGNAL (hovered ()), this,SLOT (showToolTipSaveAs ())); |
13501 | 565 |
13557
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
566 // connect modified signal |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
567 connect (m_editor, SIGNAL (modificationChanged(bool)), this, SLOT (handleModificationChanged(bool)) ); |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
568 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
569 m_fileName = ""; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
570 setWindowTitle (m_fileName); |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
571 setWindowIcon(QIcon::fromTheme("accessories-text-editor",style->standardIcon (QStyle::SP_FileIcon))); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
572 show (); |
13501 | 573 } |