Translate the names of the categories

The category gets read from the KService and is not translated.
Because of that the KCM needs to do the translation of the categories.
This was also the case in the old KCM.

REVIEW: 117111
This commit is contained in:
Martin Gräßlin 2014-03-27 13:01:02 +01:00
parent 30dd9b7820
commit b14cae83a0

View file

@ -23,6 +23,7 @@
#include "compositing.h"
#include <kwin_effects_interface.h>
#include <KLocalizedString>
#include <KPluginInfo>
#include <KService>
#include <KServiceTypeTrader>
@ -47,6 +48,35 @@
namespace KWin {
namespace Compositing {
static QString translatedCategory(const QString &category)
{
static const QVector<QString> knownCategories = {
QStringLiteral("Accessibility"),
QStringLiteral("Appearance"),
QStringLiteral("Candy"),
QStringLiteral("Focus"),
QStringLiteral("Tools"),
QStringLiteral("Virtual Desktop Switching Animation"),
QStringLiteral("Window Management")
};
static const QVector<QString> translatedCategories = {
i18nc("Category of Desktop Effects, used as section header", "Accessibility"),
i18nc("Category of Desktop Effects, used as section header", "Appearance"),
i18nc("Category of Desktop Effects, used as section header", "Candy"),
i18nc("Category of Desktop Effects, used as section header", "Focus"),
i18nc("Category of Desktop Effects, used as section header", "Tools"),
i18nc("Category of Desktop Effects, used as section header", "Virtual Desktop Switching Animation"),
i18nc("Category of Desktop Effects, used as section header", "Window Management")
};
const int index = knownCategories.indexOf(category);
if (index == -1) {
qDebug() << "Unknown category '" << category << "' and thus not translated";
return category;
}
return translatedCategories[index];
}
EffectModel::EffectModel(QObject *parent)
: QAbstractItemModel(parent) {
@ -202,7 +232,7 @@ void EffectModel::loadEffects()
effect.authorEmail = plugin.email();
effect.license = plugin.license();
effect.version = plugin.version();
effect.category = plugin.category();
effect.category = translatedCategory(plugin.category());
effect.serviceName = plugin.pluginName();
effect.effectStatus = kwinConfig.readEntry(effect.serviceName + "Enabled", plugin.isPluginEnabledByDefault());
effect.enabledByDefault = plugin.isPluginEnabledByDefault();