fix: dman display nothing

if parameters are empty, remove "%abc" in command

Issue: https://github.com/linuxdeepin/developer-center/issues/8481
This commit is contained in:
wangfei 2024-05-09 16:18:14 +08:00 committed by WangFei
parent 8ffe19ac5a
commit 47dba7e30c

View File

@ -924,6 +924,7 @@ LaunchTask ApplicationService::unescapeExec(const QString &str, const QStringLis
} break;
case 'u': {
if (fields.empty()) {
content.replace(codeStr, "");
break;
}
if (fields.count() > 1) {
@ -951,12 +952,14 @@ LaunchTask ApplicationService::unescapeExec(const QString &str, const QStringLis
auto val = m_entry->value(DesktopFileEntryKey, "Icon");
if (!val) {
qDebug() << R"(Application Icons can't be found. %i will be ignored.)";
content.replace(codeStr, "");
break;
}
auto iconStr = toIconString(val.value());
if (iconStr.isEmpty()) {
qDebug() << R"(Icons Convert to string failed. %i will be ignored.)";
content.replace(codeStr, "");
break;
}
content.replace(codeStr, QString("--icon") + " " + iconStr);
@ -965,18 +968,21 @@ LaunchTask ApplicationService::unescapeExec(const QString &str, const QStringLis
auto val = m_entry->value(DesktopFileEntryKey, "Name");
if (!val) {
qDebug() << R"(Application Name can't be found. %c will be ignored.)";
content.replace(codeStr, "");
break;
}
const auto &rawValue = val.value();
if (!rawValue.canConvert<QStringMap>()) {
qDebug() << "Name's underlying type mismatch:" << "QStringMap" << rawValue.metaType().name();
content.replace(codeStr, "");
break;
}
auto NameStr = toLocaleString(rawValue.value<QStringMap>(), getUserLocale());
if (NameStr.isEmpty()) {
qDebug() << R"(Name Convert to locale string failed. %c will be ignored.)";
content.replace(codeStr, "");
break;
}
content.replace(codeStr, NameStr);