When deleting temp files, remove from the recent file list. Closes #1540

* If the UI was launched with a filename as a parameter to open the capture, it
  will be added to the recent capture file list. Only later (relatively
  speaking) if we make a capture connection will we realise that it is temporary
  and potentially delete the file. If we do so, remove the capture from the
  recent file list.
This commit is contained in:
baldurk
2019-10-10 12:19:41 +01:00
parent 4a6235d9b7
commit e9dda8343f
9 changed files with 100 additions and 26 deletions
+26 -12
View File
@@ -502,7 +502,23 @@ bool PersistantConfig::Save()
LastFileBrowsePath = RDDialog::DefaultBrowsePath;
return Serialize(m_Filename);
// truncate the lists to a maximum of 9 items, allow more to exist in memory
rdcarray<rdcstr> capFiles = RecentCaptureFiles;
rdcarray<rdcstr> capSettings = RecentCaptureSettings;
// the oldest items are first, so remove from there
while(RecentCaptureFiles.count() >= 10)
RecentCaptureFiles.erase(0);
while(RecentCaptureSettings.count() >= 10)
RecentCaptureSettings.erase(0);
bool ret = Serialize(m_Filename);
// restore lists
RecentCaptureFiles = capFiles;
RecentCaptureSettings = capSettings;
return ret;
}
void PersistantConfig::Close()
@@ -515,7 +531,12 @@ void PersistantConfig::SetupFormatting()
Formatter::setParams(*this);
}
void AddRecentFile(rdcarray<rdcstr> &recentList, const rdcstr &file, int maxItems)
void RemoveRecentFile(rdcarray<rdcstr> &recentList, const rdcstr &file)
{
recentList.removeOne(QDir::cleanPath(file));
}
void AddRecentFile(rdcarray<rdcstr> &recentList, const rdcstr &file)
{
QDir dir(file);
QString path = dir.canonicalPath();
@@ -526,17 +547,10 @@ void AddRecentFile(rdcarray<rdcstr> &recentList, const rdcstr &file, int maxItem
return;
}
if(!recentList.contains(path))
{
recentList.push_back(path);
if(recentList.count() >= maxItems)
recentList.erase(0);
}
else
{
if(recentList.contains(path))
recentList.removeOne(path);
recentList.push_back(path);
}
recentList.push_back(path);
}
void PersistantConfig::SetConfigSetting(const rdcstr &name, const rdcstr &value)