Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2023-07-28 01:09:21 +03:00
parent d960effb99
commit d460986de0
6 changed files with 143 additions and 194 deletions

View File

@ -37,23 +37,21 @@
#include <QFileInfo>
#include <QIcon>
IconType operator--(IconType &t, int)
IconType operator--(IconType& t, int)
{
IconType temp = t;
switch (t)
{
case IconType::Builtin:
t = IconType::ToBeDeleted;
break;
case IconType::Transient:
t = IconType::Builtin;
break;
case IconType::FileBased:
t = IconType::Transient;
break;
default:
{
}
switch (t) {
case IconType::Builtin:
t = IconType::ToBeDeleted;
break;
case IconType::Transient:
t = IconType::Builtin;
break;
case IconType::FileBased:
t = IconType::Transient;
break;
default: {
}
}
return temp;
}
@ -79,8 +77,8 @@ QIcon MMCIcon::icon() const
{
if (m_current_type == IconType::ToBeDeleted)
return QIcon();
auto & icon = m_images[m_current_type].icon;
if(!icon.isNull())
auto& icon = m_images[m_current_type].icon;
if (!icon.isNull())
return icon;
// FIXME: inject this.
return QIcon::fromTheme(m_images[m_current_type].key);
@ -90,10 +88,8 @@ void MMCIcon::remove(IconType rm_type)
{
m_images[rm_type].filename = QString();
m_images[rm_type].icon = QIcon();
for (auto iter = rm_type; iter != IconType::ToBeDeleted; iter--)
{
if (m_images[iter].present())
{
for (auto iter = rm_type; iter != IconType::ToBeDeleted; iter--) {
if (m_images[iter].present()) {
m_current_type = iter;
return;
}
@ -103,8 +99,7 @@ void MMCIcon::remove(IconType rm_type)
void MMCIcon::replace(IconType new_type, QIcon icon, QString path)
{
if (new_type > m_current_type || m_current_type == IconType::ToBeDeleted)
{
if (new_type > m_current_type || m_current_type == IconType::ToBeDeleted) {
m_current_type = new_type;
}
m_images[new_type].icon = icon;
@ -114,8 +109,7 @@ void MMCIcon::replace(IconType new_type, QIcon icon, QString path)
void MMCIcon::replace(IconType new_type, const QString& key)
{
if (new_type > m_current_type || m_current_type == IconType::ToBeDeleted)
{
if (new_type > m_current_type || m_current_type == IconType::ToBeDeleted) {
m_current_type = new_type;
}
m_images[new_type].icon = QIcon();
@ -125,13 +119,12 @@ void MMCIcon::replace(IconType new_type, const QString& key)
QString MMCIcon::getFilePath() const
{
if(m_current_type == IconType::ToBeDeleted){
if (m_current_type == IconType::ToBeDeleted) {
return QString();
}
return m_images[m_current_type].filename;
}
bool MMCIcon::isBuiltIn() const
{
return m_current_type == IconType::Builtin;