Update recent file also on save/saveas

stl_dim
Marius Kintel 2011-09-08 09:52:02 +02:00
parent fc6a27432e
commit b59be3fbc2
2 changed files with 20 additions and 7 deletions

View File

@ -92,6 +92,7 @@ private slots:
void actionOpen();
void actionOpenRecent();
void actionOpenExample();
void updateRecentFiles();
void clearRecentFiles();
void updateRecentFileActions();
void actionSave();

View File

@ -340,6 +340,7 @@ MainWindow::MainWindow(const QString &filename)
} else {
setFileName("");
}
updateRecentFileActions();
connect(editor->document(), SIGNAL(contentsChanged()), this, SLOT(animateUpdateDocChanged()));
#ifdef _QCODE_EDIT_
@ -491,6 +492,7 @@ MainWindow::openFile(const QString &new_filename)
setFileName(new_filename);
load();
updateRecentFiles();
}
void
@ -510,13 +512,6 @@ MainWindow::setFileName(const QString &filename)
QString infoFileName = fileinfo.absoluteFilePath();
if (!infoFileName.isEmpty()) {
this->fileName = infoFileName;
QSettings settings; // already set up properly via main.cpp
QStringList files = settings.value("recentFileList").toStringList();
files.removeAll(this->fileName);
files.prepend(this->fileName);
while (files.size() > maxRecentFiles)
files.removeLast();
settings.setValue("recentFileList", files);
} else {
this->fileName = fileinfo.fileName();
}
@ -525,6 +520,21 @@ MainWindow::setFileName(const QString &filename)
QDir::setCurrent(fileinfo.dir().absolutePath());
}
}
void MainWindow::updateRecentFiles()
{
// Check that the canonical file path exists - only update recent files
// if it does. Should prevent empty list items on initial open etc.
QFileInfo fileinfo(this->fileName);
QString infoFileName = fileinfo.absoluteFilePath();
QSettings settings; // already set up properly via main.cpp
QStringList files = settings.value("recentFileList").toStringList();
files.removeAll(infoFileName);
files.prepend(infoFileName);
while (files.size() > maxRecentFiles) files.removeLast();
settings.setValue("recentFileList", files);
foreach(QWidget *widget, QApplication::topLevelWidgets()) {
MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
if (mainWin) {
@ -533,6 +543,7 @@ MainWindow::setFileName(const QString &filename)
}
}
void MainWindow::updatedFps()
{
bool fps_ok;
@ -988,6 +999,7 @@ void MainWindow::actionSave()
this->editor->setContentModified(false);
}
clearCurrentOutput();
updateRecentFiles();
}
}