Skip to content
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
20 changes: 14 additions & 6 deletions applets/dde-apps/amappitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,19 @@ void AMAppItem::setOnDesktop(bool on)
AppItem::setOnDesktop(on);
}

QString AMAppItem::getLocaleOrDefaultValue(const QStringMap &value, const QString &targetKey, const QString &fallbackKey)
QString AMAppItem::getLocaleOrDefaultValue(const QStringMap &value, const QString &localeCode, const QString &fallbackKey)
{
auto targetValue = value.value(targetKey);
auto fallbackValue = value.value(fallbackKey);
return !targetValue.isEmpty() ? targetValue : fallbackValue;
if (value.contains(localeCode)) {
return value.value(localeCode);
} else {
QString fallbackValue = value.value(fallbackKey);
if (localeCode.contains('_')) {
QString prefix = localeCode.split('_')[0];
return value.value(prefix, fallbackValue);
} else {
return fallbackValue;
}
}
}

void AMAppItem::onPropertyChanged(const QDBusMessage &msg)
Expand All @@ -133,7 +141,7 @@ void AMAppItem::onPropertyChanged(const QDBusMessage &msg)
AppItem::setAppName(name);
}

auto iconName = getLocaleOrDefaultValue(Application::icons(), DESKTOP_ENTRY_ICON_KEY, "");
auto iconName = Application::icons().value(DESKTOP_ENTRY_ICON_KEY);
AppItem::setAppIconName(iconName);

AppItem::setNoDisPlay(Application::noDisplay());
Expand All @@ -160,7 +168,7 @@ void AMAppItem::updateActions(const QStringList &actions, const PropMap &actionN
auto localeNames = actionName.value(action);
QJsonObject actionObject;
actionObject.insert(QStringLiteral("id"), action);
actionObject.insert(QStringLiteral("name"), getLocaleOrDefaultValue(localeNames, action, DEFAULT_KEY));
actionObject.insert(QStringLiteral("name"), getLocaleOrDefaultValue(localeNames, locale, DEFAULT_KEY));
actionsArray.append(actionObject);
}
if (actions.size() > 0) {
Expand Down
2 changes: 1 addition & 1 deletion applets/dde-apps/amappitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
void setOnDesktop(bool on) override;

private:
QString getLocaleOrDefaultValue(const QStringMap &value, const QString &targetKey, const QString &fallbackKey);
QString getLocaleOrDefaultValue(const QStringMap &value, const QString &localeCode, const QString &fallbackKey);
void updateActions(const QStringList &actions, const PropMap &actionName);

private Q_SLOTS:

Check warning on line 28 in applets/dde-apps/amappitem.h

View workflow job for this annotation

GitHub Actions / cppcheck

There is an unknown macro here somewhere. Configuration is required. If Q_SLOTS is a macro then please configure it.
void onPropertyChanged(const QDBusMessage &msg);
};
}