From b14cae83a0b32d60bdad96c0f66e42de25f4f600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 27 Mar 2014 13:01:02 +0100 Subject: [PATCH] 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 --- kcmkwin/kwincompositing/model.cpp | 32 ++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/kcmkwin/kwincompositing/model.cpp b/kcmkwin/kwincompositing/model.cpp index 2634a69745..d55ba0042a 100644 --- a/kcmkwin/kwincompositing/model.cpp +++ b/kcmkwin/kwincompositing/model.cpp @@ -23,6 +23,7 @@ #include "compositing.h" #include +#include #include #include #include @@ -47,6 +48,35 @@ namespace KWin { namespace Compositing { +static QString translatedCategory(const QString &category) +{ + static const QVector knownCategories = { + QStringLiteral("Accessibility"), + QStringLiteral("Appearance"), + QStringLiteral("Candy"), + QStringLiteral("Focus"), + QStringLiteral("Tools"), + QStringLiteral("Virtual Desktop Switching Animation"), + QStringLiteral("Window Management") + }; + + static const QVector 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();