summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/MainWindow.h1
-rw-r--r--src/mainwin.cc26
2 files changed, 20 insertions, 7 deletions
diff --git a/src/MainWindow.h b/src/MainWindow.h
index 0745935..0ba3bd9 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -92,6 +92,7 @@ private slots:
void actionOpen();
void actionOpenRecent();
void actionOpenExample();
+ void updateRecentFiles();
void clearRecentFiles();
void updateRecentFileActions();
void actionSave();
diff --git a/src/mainwin.cc b/src/mainwin.cc
index c4925d5..8dc1fea 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -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();
}
}
contact: Jan Huwald // Impressum