mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Recent files : Set last opened file first, remove file if load fails
This commit is contained in:
parent
cdbc5829ab
commit
fe712222ce
@ -957,14 +957,24 @@ void RiuMainWindow::slotOpenRecentFile()
|
|||||||
if (action)
|
if (action)
|
||||||
{
|
{
|
||||||
QString filename = action->data().toString();
|
QString filename = action->data().toString();
|
||||||
|
bool loadingSucceded = false;
|
||||||
|
|
||||||
if (filename.contains(".rsp", Qt::CaseInsensitive) || filename.contains(".rip", Qt::CaseInsensitive) )
|
if (filename.contains(".rsp", Qt::CaseInsensitive) || filename.contains(".rip", Qt::CaseInsensitive) )
|
||||||
{
|
{
|
||||||
RiaApplication::instance()->loadProject(action->data().toString());
|
loadingSucceded = RiaApplication::instance()->loadProject(action->data().toString());
|
||||||
}
|
}
|
||||||
else if ( filename.contains(".egrid", Qt::CaseInsensitive) || filename.contains(".grid", Qt::CaseInsensitive) )
|
else if ( filename.contains(".egrid", Qt::CaseInsensitive) || filename.contains(".grid", Qt::CaseInsensitive) )
|
||||||
{
|
{
|
||||||
RiaApplication::instance()->openEclipseCaseFromFile(filename);
|
loadingSucceded = RiaApplication::instance()->openEclipseCaseFromFile(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadingSucceded)
|
||||||
|
{
|
||||||
|
addRecentFiles(filename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
removeRecentFiles(filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1009,6 +1019,20 @@ void RiuMainWindow::addRecentFiles(const QString& file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuMainWindow::removeRecentFiles(const QString& file)
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
QStringList files = settings.value("recentFileList").toStringList();
|
||||||
|
files.removeAll(file);
|
||||||
|
|
||||||
|
settings.setValue("recentFileList", files);
|
||||||
|
|
||||||
|
updateRecentFileActions();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -113,6 +113,7 @@ private:
|
|||||||
|
|
||||||
void updateRecentFileActions();
|
void updateRecentFileActions();
|
||||||
void addRecentFiles(const QString& file);
|
void addRecentFiles(const QString& file);
|
||||||
|
void removeRecentFiles(const QString& file);
|
||||||
|
|
||||||
QMdiSubWindow* findMdiSubWindow(RiuViewer* viewer);
|
QMdiSubWindow* findMdiSubWindow(RiuViewer* viewer);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user