Mercurial > hg > octave-shane
changeset 14788:85daba52b2d4 gui
Fixed bug with editor complaining that a file has been modified by another application when saving.
* file-editor-tab.cc: Now "unwatching" file before saving.
* file-editor-tab: Renamed slot to update window title.
* file-editor.cc: Renamed slot to update window title.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Thu, 21 Jun 2012 20:18:30 +0200 |
parents | 7e41fcbb23a4 |
children | e3ae0850b105 |
files | gui/src/m-editor/file-editor-tab.cc gui/src/m-editor/file-editor-tab.h gui/src/m-editor/file-editor.cc |
diffstat | 3 files changed, 17 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/src/m-editor/file-editor-tab.cc +++ b/gui/src/m-editor/file-editor-tab.cc @@ -79,14 +79,14 @@ // connect modified signal connect (_edit_area, SIGNAL (modificationChanged (bool)), - this, SLOT (new_title (bool))); + this, SLOT (update_window_title (bool))); connect (_edit_area, SIGNAL (copyAvailable (bool)), this, SLOT (handle_copy_available (bool))); connect (&_file_system_watcher, SIGNAL (fileChanged (QString)), this, SLOT (file_has_changed (QString))); _file_name = ""; - new_title (false); + update_window_title (false); } bool @@ -180,7 +180,7 @@ } void -file_editor_tab::new_title(bool modified) +file_editor_tab::update_window_title(bool modified) { QString title(_file_name); if ( !_long_title ) @@ -371,7 +371,7 @@ update_tracked_file (); - new_title (false); // window title (no modification) + update_window_title (false); // window title (no modification) _edit_area->setModified (false); // loaded file is not modified yet } @@ -384,7 +384,7 @@ } set_file_name (UNNAMED_FILE); - new_title (false); // window title (no modification) + update_window_title (false); // window title (no modification) _edit_area->setText (""); _edit_area->setModified (false); // new file is not modified yet } @@ -403,6 +403,9 @@ return save_file_as(); } + QStringList watched_files = _file_system_watcher.files(); + _file_system_watcher.removePaths(watched_files); + // open the file for writing QFile file (saveFileName); if (!file.open (QFile::WriteOnly)) @@ -410,6 +413,7 @@ QMessageBox::warning (this, tr ("Octave Editor"), tr ("Could not open file %1 for write:\n%2."). arg (saveFileName).arg (file.errorString ())); + _file_system_watcher.addPaths (watched_files); return false; } @@ -418,9 +422,12 @@ QApplication::setOverrideCursor (Qt::WaitCursor); out << _edit_area->text (); QApplication::restoreOverrideCursor (); - set_file_name (saveFileName); // save file name for later use - new_title (false); // set the window title to actual file name (not modified) + _file_name = saveFileName; // save file name for later use + update_window_title (false); // set the window title to actual file name (not modified) _edit_area->setModified (false); // files is save -> not modified + file.close(); + + _file_system_watcher.addPaths (watched_files); return true; } @@ -501,7 +508,7 @@ if (!save_file_as ()) { set_file_name (UNNAMED_FILE); - new_title (true); // window title (no modification) + update_window_title (true); // window title (no modification) set_modified (true); update_tracked_file (); }
--- a/gui/src/m-editor/file-editor-tab.h +++ b/gui/src/m-editor/file-editor-tab.h @@ -32,7 +32,7 @@ bool copy_available (); public slots: - void new_title(bool modified); + void update_window_title(bool modified); void handle_copy_available(bool enableCopy); void handle_margin_clicked (int line, int margin, Qt::KeyboardModifiers state); void comment_selected_text ();
--- a/gui/src/m-editor/file-editor.cc +++ b/gui/src/m-editor/file-editor.cc @@ -353,7 +353,7 @@ _cut_action->setShortcutContext (Qt::WindowShortcut); paste_action->setShortcut (QKeySequence::Paste); paste_action->setShortcutContext (Qt::WindowShortcut); - run_action->setShortcut (Qt::Key_F5); + run_action->setShortcut (Qt::SHIFT + Qt::Key_F5); run_action->setShortcutContext (Qt::WindowShortcut); next_bookmark_action->setShortcut (Qt::Key_F2); next_bookmark_action->setShortcutContext (Qt::WindowShortcut);