Commit bd6917be authored by Laurent Montel's avatar Laurent Montel 😁

Add translator plugin for akregator

parent 2615fe58
......@@ -108,6 +108,7 @@ add_subdirectory(plugins)
add_subdirectory(korganizer)
add_subdirectory(kmail)
add_subdirectory(kaddressbook)
add_subdirectory(akregator)
install( FILES kdepim-addons.categories DESTINATION ${KDE_INSTALL_CONFDIR} )
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
add_subdirectory(viewer)
add_subdirectory(translatorplugin)
set(akregator_translatorplugin_SRCS
akregatorplugintranslator.cpp
akregatorplugintranslatorinterface.cpp
)
add_library(akregator_translatorplugin MODULE ${akregator_translatorplugin_SRCS})
target_link_libraries(akregator_translatorplugin
KF5::MessageViewer KF5::XmlGui KF5::PimTextEdit
)
install(TARGETS akregator_translatorplugin DESTINATION ${PLUGIN_INSTALL_DIR}/akregator)
{
"KPlugin": {
"Name": "Translator",
"ServiceTypes": [
"Akregator/ViewerPlugin"
],
"Version": "1.0"
}
}
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "akregatorplugintranslator.h"
#include "akregatorplugintranslatorinterface.h"
#include <KActionCollection>
#include <KToggleAction>
#include <kpluginfactory.h>
using namespace MessageViewer;
K_PLUGIN_FACTORY_WITH_JSON(AkregatorPluginTranslatorFactory, "akregator_translatorplugin.json", registerPlugin<AkregatorPluginTranslator>();)
AkregatorPluginTranslator::AkregatorPluginTranslator(QObject *parent, const QList<QVariant> &)
: MessageViewer::ViewerPlugin(parent)
{
}
ViewerPluginInterface *AkregatorPluginTranslator::createView(QWidget *parent, KActionCollection *ac)
{
MessageViewer::ViewerPluginInterface *view = new AkregatorPluginTranslatorInterface(ac, parent);
return view;
}
QString AkregatorPluginTranslator::viewerPluginName() const
{
return QStringLiteral("translator");
}
#include "akregatorplugintranslator.moc"
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AKREGATORPLUGINTRANSLATOR_H
#define AKREGATORPLUGINTRANSLATOR_H
#include <messageviewer/viewerplugin.h>
#include <QVariant>
namespace MessageViewer
{
class AkregatorPluginTranslator : public MessageViewer::ViewerPlugin
{
Q_OBJECT
public:
explicit AkregatorPluginTranslator(QObject *parent = Q_NULLPTR, const QList<QVariant> & = QList<QVariant>());
ViewerPluginInterface *createView(QWidget *parent, KActionCollection *ac) Q_DECL_OVERRIDE;
QString viewerPluginName() const Q_DECL_OVERRIDE;
};
}
#endif // AKREGATORPLUGINTRANSLATOR_H
/*
Copyright (c) 2015-2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "akregatorplugintranslatorinterface.h"
#include "pimcommon/translatorwidget.h"
#include <QHBoxLayout>
#include <QIcon>
#include <QAction>
#include <KActionCollection>
#include <KLocalizedString>
using namespace MessageViewer;
AkregatorPluginTranslatorInterface::AkregatorPluginTranslatorInterface(KActionCollection *ac, QWidget *parent)
: ViewerPluginInterface(parent),
mAction(Q_NULLPTR)
{
mTranslatorWidget = new PimCommon::TranslatorWidget(parent);
mTranslatorWidget->setObjectName(QStringLiteral("translatorwidget"));
parent->layout()->addWidget(mTranslatorWidget);
createAction(ac);
}
AkregatorPluginTranslatorInterface::~AkregatorPluginTranslatorInterface()
{
}
void AkregatorPluginTranslatorInterface::setText(const QString &text)
{
mTranslatorWidget->setTextToTranslate(text);
}
QAction *AkregatorPluginTranslatorInterface::action() const
{
return mAction;
}
void AkregatorPluginTranslatorInterface::showWidget()
{
mTranslatorWidget->show();
}
ViewerPluginInterface::SpecificFeatureTypes AkregatorPluginTranslatorInterface::featureTypes() const
{
return NeedSelection;
}
void AkregatorPluginTranslatorInterface::createAction(KActionCollection *ac)
{
if (ac) {
mAction = new QAction(i18n("Translate..."), this);
ac->setDefaultShortcut(mAction, QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_T));
mAction->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-locale")));
ac->addAction(QStringLiteral("translate_text"), mAction);
connect(mAction, &QAction::triggered, this, &AkregatorPluginTranslatorInterface::slotActivatePlugin);
}
}
/*
Copyright (c) 2015-2016 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AKREGATORPLUGINTRANSLATORINTERFACE_H
#define AKREGATORPLUGINTRANSLATORINTERFACE_H
#include <messageviewer/viewerplugininterface.h>
class KActionCollection;
namespace PimCommon
{
class TranslatorWidget;
}
namespace MessageViewer
{
class AkregatorPluginTranslatorInterface : public ViewerPluginInterface
{
Q_OBJECT
public:
explicit AkregatorPluginTranslatorInterface(KActionCollection *ac, QWidget *parent = Q_NULLPTR);
~AkregatorPluginTranslatorInterface();
void setText(const QString &text) Q_DECL_OVERRIDE;
QAction *action() const Q_DECL_OVERRIDE;
void showWidget() Q_DECL_OVERRIDE;
ViewerPluginInterface::SpecificFeatureTypes featureTypes() const Q_DECL_OVERRIDE;
private:
void createAction(KActionCollection *ac);
QAction *mAction;
PimCommon::TranslatorWidget *mTranslatorWidget;
};
}
#endif // AKREGATORPLUGINTRANSLATORINTERFACE_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment