Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: little black square icon show again #319

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/models/appitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "appitem.h"

#include <QFileInfo>

AppItem::AppItem(const QString &freedesktopId)
: QStandardItem()
{
Expand Down Expand Up @@ -45,9 +47,14 @@
return data(AppItem::IconNameRole).toString();
}

void AppItem::setIconName(const QString &iconName)

Check warning on line 50 in src/models/appitem.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'setIconName' is never used.
{
setData(iconName.isEmpty() ? "application-x-desktop" : iconName, AppItem::IconNameRole);
QString name = iconName;
if (QFileInfo(iconName).isAbsolute()) {
name = QUrl::fromLocalFile(iconName).toString(); // path ==> file://path
}

setData(iconName.isEmpty() ? "application-x-desktop" : name, AppItem::IconNameRole);
}

const QStringList AppItem::categories() const
Expand Down
7 changes: 5 additions & 2 deletions src/models/appsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,17 @@ QVariant AppsModel::data(const QModelIndex &index, int role) const

void AppsModel::updateModelData()
{
// TODO release icon's cache when gtk's icon-theme.cache is updated.
IconUtils::tryUpdateIconCache();
beginResetModel();
qDebug() << "reset model.";

QList<AppItem *> items(allAppInfosShouldBeShown());
cleanUpInvalidApps(items);
QList<AppItem *> duplicatedItems = updateItems(items);
for (AppItem * item : std::as_const(duplicatedItems)) {
delete item;
}

endResetModel();
}

// the caller manage the return values' ownership (i.e. might need to free them)
Expand Down
Loading