Skip to content

Commit

Permalink
fix: 系统监视器文件管理器进程图标显示错误
Browse files Browse the repository at this point in the history
系统监视器文件管理器进程图标显示错误

Log: 系统监视器文件管理器进程图标显示错误
Bug: https://pms.uniontech.com/bug-view-257355.html
  • Loading branch information
tanghongyao committed Jun 13, 2024
1 parent 0266add commit b4a235d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
5 changes: 5 additions & 0 deletions deepin-system-monitor-main/process/desktop_entry_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ const DesktopEntry DesktopEntryCache::entryWithDesktopFile(const QString &deskto
return entry;
}

QHash<QString, DesktopEntry> DesktopEntryCache::getCache()
{
return m_cache;
}

void DesktopEntryCache::updateCache()
{
m_cache.clear();
Expand Down
1 change: 1 addition & 0 deletions deepin-system-monitor-main/process/desktop_entry_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class DesktopEntryCache
const DesktopEntry entry(const QString &name) const;
const DesktopEntry entryWithDesktopFile(const QString &desktopFile);
const DesktopEntry entryWithSubName(const QString &subName) const;
QHash<QString, DesktopEntry> getCache();

void updateCache();

Expand Down
22 changes: 20 additions & 2 deletions deepin-system-monitor-main/process/process_icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,21 @@ struct icon_data_t *ProcessIcon::terminalIconData(const QString &procname) const
return iconData;
}

QString ProcessIcon::getFileManagerString()
{
DesktopEntryCache *desktopEntryCache = ProcessDB::instance()->desktopEntryCache();
QList<QString> desktopEntryKeys = desktopEntryCache->getCache().keys();
for (auto it = desktopEntryKeys.begin(); it != desktopEntryKeys.end(); it++) {
if ((*it).contains("dde-file-manager") && desktopEntryCache->getCache().value((*it))->icon.contains("dde-file-manager")) {
return (*it);
}
}
return "";
}

std::shared_ptr<icon_data_t> ProcessIcon::getIcon(Process *proc)
{
std::shared_ptr<icon_data_t> iconDataPtr;

auto processDB = ProcessDB::instance();
WMWindowList *windowList = processDB->windowList();
DesktopEntryCache *desktopEntryCache = processDB->desktopEntryCache();
Expand Down Expand Up @@ -159,7 +170,14 @@ std::shared_ptr<icon_data_t> ProcessIcon::getIcon(Process *proc)
iconData->desktopentry = true;
iconData->type = kIconDataNameType;
iconData->proc_name = proc->name();
iconData->icon_name = entry->icon;
//由于文件管理器和主目录在desktopEntryCache的m_cache中的key都包含"dde-file-manager"
//且value中的结构体里的name都是"dde-file-manager",所以在这里对于文件管理器的图标要多做判断
QString tempString = getFileManagerString();
if (tempString.contains(proc->name())) {
iconData->icon_name = desktopEntryCache->getCache().value(tempString)->icon;
} else {
iconData->icon_name = entry->icon;
}
iconDataPtr.reset(iconData);
windowList->addDesktopEntryApp(proc);
return iconDataPtr;
Expand Down
1 change: 1 addition & 0 deletions deepin-system-monitor-main/process/process_icon.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ProcessIcon
std::shared_ptr<struct icon_data_t> getIcon(Process *proc);
struct icon_data_t *defaultIconData(const QString &procname) const;
struct icon_data_t *terminalIconData(const QString &procname) const;
QString getFileManagerString();

private:
std::shared_ptr<struct icon_data_t> m_data;
Expand Down

0 comments on commit b4a235d

Please sign in to comment.