@@ -180,7 +180,7 @@ void MainWindow::clearCompleterModelsFields()
180180 completerModelsFields.clear ();
181181}
182182
183- bool MainWindow::fileOpen (const QString& fileName)
183+ bool MainWindow::fileOpen (const QString& fileName, bool dontAddToRecentFiles )
184184{
185185 bool retval = false ;
186186
@@ -199,6 +199,8 @@ bool MainWindow::fileOpen(const QString& fileName)
199199 {
200200 statusEncodingLabel->setText (db.getPragma (" encoding" ));
201201 setCurrentFile (wFile);
202+ if (!dontAddToRecentFiles)
203+ addToRecentFilesMenu (wFile);
202204 retval = true ;
203205 } else {
204206 // Failed opening file; so it might be a project file instead
@@ -224,6 +226,7 @@ void MainWindow::fileNew()
224226 QFile::remove (fileName);
225227 db.create (fileName);
226228 setCurrentFile (fileName);
229+ addToRecentFilesMenu (fileName);
227230 statusEncodingLabel->setText (db.getPragma (" encoding" ));
228231 loadExtensionsFromSettings ();
229232 populateStructure ();
@@ -1014,10 +1017,13 @@ void MainWindow::setCurrentFile(const QString &fileName)
10141017 setWindowFilePath (fileName);
10151018 setWindowTitle ( QApplication::applicationName () +" - " +fileName);
10161019 activateFields (true );
1020+ }
10171021
1022+ void MainWindow::addToRecentFilesMenu (const QString& filename)
1023+ {
10181024 QStringList files = PreferencesDialog::getSettingsValue (" General" , " recentFileList" ).toStringList ();
1019- files.removeAll (fileName );
1020- files.prepend (fileName );
1025+ files.removeAll (filename );
1026+ files.prepend (filename );
10211027 while (files.size () > MaxRecentFiles)
10221028 files.removeLast ();
10231029
@@ -1741,6 +1747,8 @@ bool MainWindow::loadProject(QString filename)
17411747 return false ;
17421748 }
17431749
1750+ addToRecentFilesMenu (filename);
1751+
17441752 while (!xml.atEnd () && !xml.hasError ())
17451753 {
17461754 // Read next token
@@ -1755,7 +1763,7 @@ bool MainWindow::loadProject(QString filename)
17551763 QString dbfilename = xml.attributes ().value (" path" ).toString ();
17561764 if (!QFile::exists (dbfilename))
17571765 dbfilename = QFileInfo (filename).absolutePath () + QDir::separator () + dbfilename;
1758- fileOpen (dbfilename);
1766+ fileOpen (dbfilename, true );
17591767 ui->dbTreeWidget ->collapseAll ();
17601768 } else if (xml.name () == " window" ) {
17611769 // Window settings
0 commit comments