Skip to content

Commit

Permalink
fix: The dock cannot record the tray icon dragged to the dock plug-in…
Browse files Browse the repository at this point in the history
… area.

get the process name has error.

Log: fix the dock cannot record the tray icon dragged to the dock plugin area.
issue: linuxdeepin/developer-center#8189
Influence: tray icons display
  • Loading branch information
yixinshark authored and tsic404 committed Apr 25, 2024
1 parent b30e171 commit af9323e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion panels/dock/tray/frame/window/tray/tray_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,23 @@ QString TrayModel::sniItemKey(const QString &servicePath) const
if (isTypeWriting(servicePath))
return "fcitx";

auto getProcessName = [](const QString &fileName) -> QString {
int lastSlashIndex = fileName.lastIndexOf('/');
if (lastSlashIndex == -1) {
return QString();
}

QString midStr = fileName.mid(lastSlashIndex + 1);
int nullIndex = midStr.indexOf('\u0000');
if (nullIndex != -1) {
// 截取到第一个空字符之前的内容
midStr = midStr.left(nullIndex);
}
return midStr;
};

QString fileName = fileNameByServiceName(servicePath);
return QString("sni:%1").arg(fileName.mid(fileName.lastIndexOf("/") + 1));
return QString("sni:%1").arg(getProcessName(fileName));
}

bool TrayModel::sniCanExport(const QString &servicePath) const
Expand Down

0 comments on commit af9323e

Please sign in to comment.