feat+refactor: trash instance icons

also refactor IconList::deleteIcon

Signed-off-by: leo78913 <leo3758@riseup.net>
This commit is contained in:
leo78913
2022-12-06 20:25:42 -03:00
parent 8036272e87
commit 8c99edd3c5
3 changed files with 15 additions and 8 deletions

View File

@ -354,15 +354,18 @@ const MMCIcon *IconList::icon(const QString &key) const
bool IconList::deleteIcon(const QString &key)
{
int iconIdx = getIconIndex(key);
if (iconIdx == -1)
if (!iconFileExists(key))
return false;
auto &iconEntry = icons[iconIdx];
if (iconEntry.has(IconType::FileBased))
{
return QFile::remove(iconEntry.m_images[IconType::FileBased].filename);
}
return false;
return QFile::remove(icon(key)->m_images[IconType::FileBased].filename);
}
bool IconList::trashIcon(const QString &key)
{
if (!iconFileExists(key))
return false;
return FS::trash(icon(key)->m_images[IconType::FileBased].filename, nullptr);
}
bool IconList::addThemeIcon(const QString& key)