Drop our custom KLocalizedTranslator

It's upstreamed to ki18n framework.
This commit is contained in:
Martin Gräßlin 2014-06-18 15:02:58 +02:00
parent 822fca474b
commit 8aa8617ed4
8 changed files with 6 additions and 113 deletions

View file

@ -16,7 +16,6 @@ set(kcm_kwindecoration_PART_SRCS
configdialog.cpp
preview.cpp
decorationmodel.cpp
../utils/uitranslator.cpp
${AURORAE_SOURCE_DIR}/auroraetheme.cpp
${AURORAE_SOURCE_DIR}/themeconfig.cpp
)

View file

@ -34,7 +34,6 @@
#include "decorationmodel.h"
#include "auroraetheme.h"
#include "preview.h"
#include "uitranslator.h"
// Qt
#include <QtDBus/QtDBus>
#include <QSortFilterProxyModel>
@ -48,6 +47,7 @@
#include <KAboutData>
#include <kconfigloader.h>
#include <KLocalizedString>
#include <KLocalizedTranslator>
#include <KMessageBox>
#include <KNewStuff3/KNS3/DownloadDialog>
#include <KConfigDialogManager>

View file

@ -40,11 +40,11 @@
class QQuickView;
class QSortFilterProxyModel;
class KLocalizedTranslator;
namespace KWin
{
class DecorationModel;
class KLocalizedTranslator;
class KWinDecorationForm : public QWidget, public Ui::KWinDecorationForm
{

View file

@ -1,58 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2014 Martin Gräßlin <mgraesslin@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "uitranslator.h"
// frameworks
#include <KLocalizedString>
// Qt
#include <QComboBox>
#include <QMetaObject>
#include <QMetaProperty>
namespace KWin
{
KLocalizedTranslator::KLocalizedTranslator(QObject* parent)
: QTranslator(parent)
{
}
void KLocalizedTranslator::setTranslationDomain(const QString &translationDomain)
{
m_translationDomain = translationDomain;
}
void KLocalizedTranslator::addContextToMonitor(const QString &context)
{
m_monitoredContexts.insert(context);
}
QString KLocalizedTranslator::translate(const char *context, const char *sourceText, const char *disambiguation, int n) const
{
if (m_translationDomain.isEmpty() || !m_monitoredContexts.contains(QString::fromUtf8(context))) {
return QTranslator::translate(context, sourceText, disambiguation, n);
}
if (qstrlen(disambiguation) == 0) {
return ki18nd(m_translationDomain.toUtf8().constData(), sourceText).toString();
} else {
return ki18ndc(m_translationDomain.toUtf8().constData(), disambiguation, sourceText).toString();
}
}
} // namespace KWin

View file

@ -1,48 +0,0 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2014 Martin Gräßlin <mgraesslin@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_KCMUTILS_UITRANSLATOR_H
#define KWIN_KCMUTILS_UITRANSLATOR_H
#include <QSet>
#include <QTranslator>
class QWidget;
namespace KWin
{
class KLocalizedTranslator : public QTranslator
{
Q_OBJECT
public:
explicit KLocalizedTranslator(QObject *parent = 0);
QString translate(const char *context, const char *sourceText, const char *disambiguation = 0, int n = -1) const override;
void setTranslationDomain(const QString &translationDomain);
void addContextToMonitor(const QString &context);
private:
QString m_translationDomain;
QSet<QString> m_monitoredContexts;
};
}
#endif

View file

@ -1,5 +1,5 @@
include_directories(${KWIN_SOURCE_DIR}/kcmkwin/utils/)
set(kcm_kwin4_genericscripted_SRCS genericscriptedconfig.cpp ${KWIN_SOURCE_DIR}/kcmkwin/utils/uitranslator.cpp)
set(kcm_kwin4_genericscripted_SRCS genericscriptedconfig.cpp)
qt5_add_dbus_interface(kcm_kwin4_genericscripted_SRCS ${kwin_effects_dbus_xml} kwineffects_interface)
add_library(kcm_kwin4_genericscripted MODULE ${kcm_kwin4_genericscripted_SRCS})
target_link_libraries( kcm_kwin4_genericscripted

View file

@ -20,11 +20,11 @@
#include "genericscriptedconfig.h"
#include "config-kwin.h"
#include "uitranslator.h"
#include <kwineffects_interface.h>
#include <KAboutData>
#define TRANSLATION_DOMAIN "kwin_scripting"
#include <KLocalizedString>
#include <KLocalizedTranslator>
#include <kconfigloader.h>
#include <KDesktopFile>

View file

@ -25,11 +25,11 @@
#include <KPluginFactory>
#include <KConfigGroup>
class KLocalizedTranslator;
namespace KWin
{
class KLocalizedTranslator;
class GenericScriptedConfigFactory : public KPluginFactory
{
Q_OBJECT