feat+refactor: trash instance icons
also refactor IconList::deleteIcon Signed-off-by: leo78913 <leo3758@riseup.net>
This commit is contained in:
parent
8036272e87
commit
8c99edd3c5
@ -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)
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
bool addIcon(const QString &key, const QString &name, const QString &path, const IconType type);
|
||||
void saveIcon(const QString &key, const QString &path, const char * format) const;
|
||||
bool deleteIcon(const QString &key);
|
||||
bool trashIcon(const QString &key);
|
||||
bool iconFileExists(const QString &key) const;
|
||||
|
||||
void installIcons(const QStringList &iconFiles);
|
||||
|
@ -112,6 +112,9 @@ void IconPickerDialog::addNewIcon()
|
||||
|
||||
void IconPickerDialog::removeSelectedIcon()
|
||||
{
|
||||
if (APPLICATION->icons()->trashIcon(selectedIconKey))
|
||||
return;
|
||||
|
||||
APPLICATION->icons()->deleteIcon(selectedIconKey);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user