Mercurial > hg > octave-nkf
annotate gui/src/FileEditorMdiSubWindow.cpp @ 13558:248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
author | ttl <ttl@justmail.de> |
---|---|
date | Sat, 30 Jul 2011 16:36:25 +0200 |
parents | ad18a8e7fb02 |
children | a89aa9e05e19 |
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" | |
20 #include <QVBoxLayout> | |
21 #include <QApplication> | |
22 #include <QFile> | |
23 #include <QFileDialog> | |
24 #include <QMessageBox> | |
25 #include <QAction> | |
26 #include <QStyle> | |
27 #include <QTextStream> | |
28 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
29 FileEditorMdiSubWindow::FileEditorMdiSubWindow (QWidget * parent):QMdiSubWindow |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
30 (parent) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
31 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
32 construct (); |
13501 | 33 } |
34 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
35 FileEditorMdiSubWindow::~FileEditorMdiSubWindow () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
36 { |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
37 } |
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 void |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
40 FileEditorMdiSubWindow::closeEvent(QCloseEvent *event) |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
41 { |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
42 // 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
|
43 // 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
|
44 if (checkFileModified ("Close File")==QMessageBox::Cancel) |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
45 { |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
46 event->ignore(); |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
47 } |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
48 else |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
49 { |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
50 event->accept(); |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
51 } |
13501 | 52 } |
53 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
54 void |
13557
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
55 FileEditorMdiSubWindow::handleModificationChanged(bool modified) |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
56 { |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
57 if ( modified ) |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
58 { |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
59 QString title(m_fileName); |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
60 setWindowTitle(title.prepend("* ")); |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
61 } |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
62 else |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
63 setWindowTitle (m_fileName); |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
64 } |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
65 |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
66 void |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
67 FileEditorMdiSubWindow::openFile () |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
68 { |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
69 if (checkFileModified ("Open File")==QMessageBox::Cancel) |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
70 { |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
71 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
|
72 } |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
73 QString openFileName = |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
74 QFileDialog::getOpenFileName (this, "Open File", QDir::homePath(), SAVE_FILE_FILTER); |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
75 if (openFileName.isEmpty ()) |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
76 { |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
77 return; |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
78 } |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
79 else |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
80 { |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
81 loadFile(openFileName); |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
82 } |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
83 } |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
84 |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
85 void |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
86 FileEditorMdiSubWindow::loadFile (QString fileName) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
87 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
88 QFile file (fileName); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
89 if (!file.open (QFile::ReadOnly)) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
90 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
91 QMessageBox::warning (this, tr ("File Editor"), |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
92 tr ("Cannot read file %1:\n%2.").arg (fileName). |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
93 arg (file.errorString ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
94 return; |
13501 | 95 } |
96 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
97 QTextStream in (&file); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
98 QApplication::setOverrideCursor (Qt::WaitCursor); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
99 m_editor->setText (in.readAll ()); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
100 QApplication::restoreOverrideCursor (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
101 |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
102 m_fileName = fileName; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
103 setWindowTitle (fileName); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
104 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
|
105 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
|
106 } |
13501 | 107 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
108 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
109 FileEditorMdiSubWindow::newFile () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
110 { |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
111 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
|
112 { |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
113 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
|
114 } |
13529 | 115 m_fileName = UNNAMED_FILE; |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
116 setWindowTitle (m_fileName); |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
117 m_editor->setText (""); |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
118 m_editor->setModified (false); // new file is not modified yet |
13501 | 119 } |
120 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
121 int |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
122 FileEditorMdiSubWindow::checkFileModified (QString msg) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
123 { |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
124 int decision = QMessageBox::Yes; |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
125 if (m_editor->isModified ()) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
126 { |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
127 // 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
|
128 decision = QMessageBox::question (this, |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
129 msg, |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
130 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
|
131 arg (m_fileName), |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
132 QMessageBox::Cancel, |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
133 QMessageBox::No, |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
134 QMessageBox::Yes); |
13501 | 135 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
136 if (decision == QMessageBox::Yes) |
13524
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 saveFile (); |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
139 if (m_editor->isModified ()) |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
140 { |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
141 // 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
|
142 // 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
|
143 // for cancel this operation |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
144 return (QMessageBox::Cancel); |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
145 } |
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
146 } |
13501 | 147 } |
13524
8c143d6d0330
gui-editor: improved behaviour when closing a modified file
ttl (Torsten) <ttl@justmail.de>
parents:
13506
diff
changeset
|
148 return (decision); |
13501 | 149 } |
150 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
151 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
152 FileEditorMdiSubWindow::saveFile () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
153 { |
13529 | 154 saveFile(m_fileName); |
155 } | |
156 | |
157 void | |
158 FileEditorMdiSubWindow::saveFile (QString fileName) | |
159 { | |
160 // it is a new file with the name "<unnamed>" -> call saveFielAs | |
161 if (fileName==UNNAMED_FILE) | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
162 { |
13529 | 163 saveFileAs(); |
164 return; | |
13501 | 165 } |
166 | |
13529 | 167 // check for a valid file name to save the contents |
168 QString saveFileName; | |
169 if (fileName.isEmpty ()) | |
170 { | |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
171 saveFileName = QFileDialog::getSaveFileName (this, "Save File", fileName,SAVE_FILE_FILTER); |
13529 | 172 if (saveFileName.isEmpty ()) |
173 return; | |
174 } | |
175 else | |
176 { | |
177 saveFileName = fileName; | |
178 } | |
179 | |
180 // open the file | |
181 QFile file (saveFileName); | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
182 if (!file.open (QFile::WriteOnly)) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
183 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
184 QMessageBox::warning (this, tr ("File Editor"), |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
185 tr ("Cannot write file %1:\n%2."). |
13529 | 186 arg (saveFileName).arg (file.errorString ())); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
187 return; |
13501 | 188 } |
189 | |
13529 | 190 // save the contents into the file |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
191 QTextStream out (&file); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
192 QApplication::setOverrideCursor (Qt::WaitCursor); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
193 out << m_editor->text (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
194 QApplication::restoreOverrideCursor (); |
13529 | 195 m_fileName = saveFileName; // save file name for later use |
196 setWindowTitle(m_fileName); // set the window title to actual file name | |
197 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
|
198 m_editor->setModified (false); // files is save -> not modified |
13501 | 199 } |
200 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
201 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
202 FileEditorMdiSubWindow::saveFileAs () |
13529 | 203 { |
204 QString saveDir(m_fileName); | |
205 if (saveDir==UNNAMED_FILE) | |
206 saveDir = QDir::homePath(); | |
207 QString saveFileName = QFileDialog::getSaveFileName( | |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
208 this, "Save File As", saveDir,SAVE_FILE_FILTER); |
13529 | 209 if(saveFileName.isEmpty()) |
210 return; | |
211 saveFile(saveFileName); | |
13501 | 212 } |
213 | |
13558
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
214 void |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
215 FileEditorMdiSubWindow::setEditorLexer (LexerOctaveGui* lexer) |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
216 { |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
217 m_editor->setLexer(lexer); |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
218 } |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
219 |
13555
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
220 // 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
|
221 // shown directly at the theme icons |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
222 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
223 FileEditorMdiSubWindow::showToolTipNew () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
224 { |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
225 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
|
226 } |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
227 |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
228 void |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
229 FileEditorMdiSubWindow::showToolTipOpen () |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
230 { |
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
231 m_statusBar->showMessage ("Open a file", 2000); |
13501 | 232 } |
233 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
234 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
235 FileEditorMdiSubWindow::showToolTipSave () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
236 { |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
237 m_statusBar->showMessage ("Save the file", 2000); |
13501 | 238 } |
239 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
240 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
241 FileEditorMdiSubWindow::showToolTipSaveAs () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
242 { |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
243 m_statusBar->showMessage ("Save the file as", 2000); |
13501 | 244 } |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
245 |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
246 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
247 FileEditorMdiSubWindow::showToolTipUndo () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
248 { |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
249 m_statusBar->showMessage ("Revert previous changes", 2000); |
13501 | 250 } |
251 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
252 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
253 FileEditorMdiSubWindow::showToolTipRedo () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
254 { |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
255 m_statusBar->showMessage ("Append previous changes", 2000); |
13501 | 256 } |
257 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
258 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
259 FileEditorMdiSubWindow::registerModified (bool modified) |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
260 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
261 m_modified = modified; |
13501 | 262 } |
263 | |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
264 void |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
265 FileEditorMdiSubWindow::construct () |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
266 { |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
267 QStyle *style = QApplication::style (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
268 setWidget (new QWidget ()); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
269 m_toolBar = new QToolBar (this); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
270 m_statusBar = new QStatusBar (this); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
271 m_editor = new QsciScintilla (this); |
13503
5ab40ef3d241
Merged diff from Torsten.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13501
diff
changeset
|
272 |
13558
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
273 m_editor->setMarginType (1, QsciScintilla::SymbolMargin); |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
274 m_editor->setMarginType (2, QsciScintilla::TextMargin); |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
275 m_editor->setMarginType (3, QsciScintilla::SymbolMargin); |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
276 m_editor->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3); |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
277 m_editor->setMarginLineNumbers (2, true); |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
278 m_editor->setMarginWidth (2, "99999"); |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
279 m_editor->setMarginsForegroundColor (QColor(96,96,96)); |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
280 m_editor->setMarginsBackgroundColor (QColor(224,224,224)); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
281 |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
282 m_editor->setBraceMatching (QsciScintilla::SloppyBraceMatch); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
283 m_editor->setAutoIndent (true); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
284 m_editor->setIndentationWidth (2); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
285 m_editor->setIndentationsUseTabs (false); |
13558
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
286 m_editor->autoCompleteFromAll(); |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
287 m_editor->setAutoCompletionSource(QsciScintilla::AcsAPIs); |
248b897d9f36
editor: custom lexer, syntax highlighting, auto completion
ttl <ttl@justmail.de>
parents:
13557
diff
changeset
|
288 m_editor->setAutoCompletionThreshold (3); |
13503
5ab40ef3d241
Merged diff from Torsten.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13501
diff
changeset
|
289 |
13555
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
290 // Theme icons with QStyle icons as fallback |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
291 m_toolBar->setIconSize(QSize(20,20)); // smaller icons (make configurable in user settings?) |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
292 QAction *closeAction = new QAction ( |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
293 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
|
294 tr("&Close File"), m_toolBar); |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
295 QAction *newAction = new QAction ( |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
296 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
|
297 tr("&New File"), m_toolBar); |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
298 QAction *openAction = new QAction ( |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
299 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
|
300 tr("&Open File"), m_toolBar); |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
301 QAction *saveAction = new QAction ( |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
302 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
|
303 tr("&Save File"), m_toolBar); |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
304 QAction *saveAsAction = new QAction ( |
13555
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
305 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
|
306 tr("Save File &As"), m_toolBar); |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
307 QAction *undoAction = new QAction ( |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
308 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
|
309 tr("&Undo"), m_toolBar); |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
310 QAction *redoAction = new QAction ( |
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
311 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
|
312 tr("&Redo"), m_toolBar); |
13501 | 313 |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
314 // short cuts |
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
315 newAction->setShortcut(QKeySequence::New); |
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
316 openAction->setShortcut(QKeySequence::Open); |
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
317 saveAction->setShortcut(QKeySequence::Save); |
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
318 saveAsAction->setShortcut(QKeySequence::SaveAs); |
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
319 undoAction->setShortcut(QKeySequence::Undo); |
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
320 redoAction->setShortcut(QKeySequence::Redo); |
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
321 |
13550
cd66481d55b0
Added close button to file editor, assorted subwindows after importance.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13530
diff
changeset
|
322 m_toolBar->addAction (closeAction); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
323 m_toolBar->addAction (newAction); |
13530
8c7390b78911
gui-editor: open new editor window via interface menu
ttl <ttl@justmail.de>
parents:
13529
diff
changeset
|
324 m_toolBar->addAction (openAction); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
325 m_toolBar->addAction (saveAction); |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
326 m_toolBar->addAction (saveAsAction); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
327 m_toolBar->addAction (undoAction); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
328 m_toolBar->addAction (redoAction); |
13501 | 329 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
330 QVBoxLayout *layout = new QVBoxLayout (); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
331 layout->addWidget (m_toolBar); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
332 layout->addWidget (m_editor); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
333 layout->addWidget (m_statusBar); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
334 layout->setMargin (2); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
335 widget ()->setLayout (layout); |
13501 | 336 |
13550
cd66481d55b0
Added close button to file editor, assorted subwindows after importance.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13530
diff
changeset
|
337 connect (closeAction, SIGNAL (triggered()), this, SLOT (close())); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
338 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
|
339 connect (openAction, SIGNAL (triggered ()), this, SLOT (openFile ())); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
340 connect (undoAction, SIGNAL (triggered ()), m_editor, SLOT (undo ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
341 connect (redoAction, SIGNAL (triggered ()), m_editor, SLOT (redo ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
342 connect (saveAction, SIGNAL (triggered ()), this, SLOT (saveFile ())); |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
343 connect (saveAsAction, SIGNAL (triggered ()), this, SLOT (saveFileAs ())); |
13501 | 344 |
13555
be425f45f9e3
editor: toolbar icons from current icon theme
ttl <ttl@justmail.de>
parents:
13550
diff
changeset
|
345 // 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
|
346 // shown directly at the theme icons |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
347 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
|
348 connect (openAction, SIGNAL (hovered ()), this, SLOT (showToolTipOpen ())); |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
349 connect (undoAction, SIGNAL (hovered ()), this, SLOT (showToolTipUndo ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
350 connect (redoAction, SIGNAL (hovered ()), this, SLOT (showToolTipRedo ())); |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
351 connect (saveAction, SIGNAL (hovered ()), this, SLOT (showToolTipSave ())); |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
352 connect (saveAsAction, SIGNAL (hovered ()), this,SLOT (showToolTipSaveAs ())); |
13501 | 353 |
13557
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
354 // connect modified signal |
ad18a8e7fb02
editor: change window title if text is modified
ttl <ttl@justmail.de>
parents:
13556
diff
changeset
|
355 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
|
356 |
13506
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
357 m_fileName = ""; |
c70511cf64ee
Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
13504
diff
changeset
|
358 setWindowTitle (m_fileName); |
13556
0d18b0e168ae
editor: shortcuts for toolbar actions, window icon
ttl <ttl@justmail.de>
parents:
13555
diff
changeset
|
359 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
|
360 show (); |
13501 | 361 } |