Commit 344751bf authored by Laurent Montel's avatar Laurent Montel 😁

Move as common plugin

parent 1e3e5b63
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",
"Name[ca@valencia]": "Traductor",
"Name[ca]": "Traductor",
"Name[cs]": "Překladatel",
"Name[de]": "Übersetzer",
"Name[es]": "Traductor",
"Name[fi]": "Käännösohjelma",
"Name[gl]": "Tradutor",
"Name[it]": "Traduttore",
"Name[nl]": "Vertaler",
"Name[pl]": "Tłumacz",
"Name[pt]": "Tradutor",
"Name[pt_BR]": "Tradutor",
"Name[ru]": "Машинный перевод",
"Name[sk]": "Prekladateľ",
"Name[sl]": "Prevajalnik",
"Name[sr@ijekavian]": "Преводилац",
"Name[sr@ijekavianlatin]": "Prevodilac",
"Name[sr@latin]": "Prevodilac",
"Name[sr]": "Преводилац",
"Name[sv]": "Översättning",
"Name[uk]": "Перекладач",
"Name[x-test]": "xxTranslatorxx",
"Name[zh_CN]": "翻译者",
"ServiceTypes": [
"Akregator/ViewerPlugin"
],
"Version": "1.0"
}
}
\ No newline at end of file
/*
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
......@@ -3,8 +3,7 @@ if(BUILD_TESTING)
endif()
add_definitions(-DTRANSLATION_DOMAIN=\"messageviewerplugins\")
add_subdirectory(translatorplugin)
add_subdirectory(createnoteplugin)
add_subdirectory(createtodoplugin)
add_subdirectory(createeventplugin)
add_subdirectory(expandurlplugin)
add_subdirectory(common)
......@@ -51,4 +51,4 @@ add_messageviewer_viewerplugin_widget_unittest(eventdatetimewidgettest.cpp "../c
add_messageviewer_viewerplugin_unittest(viewerplugincreateeventtest.cpp "../createeventplugin/eventdatetimewidget.cpp;../createeventplugin/eventedit.cpp;../createeventplugin/viewerplugincreateevent.cpp;../createeventplugin/viewerplugincreateeventinterface.cpp" "")
add_messageviewer_viewerplugin_unittest(viewerplugincreatetodotest.cpp "../createtodoplugin/viewerplugincreatetodo.cpp;../createtodoplugin/viewerplugincreatetodointerface.cpp;../createtodoplugin/todoedit.cpp" "")
add_messageviewer_viewerplugin_unittest(viewerplugincreatenotetest.cpp "../createnoteplugin/noteedit.cpp;../createnoteplugin/viewerplugincreatenote.cpp;../createnoteplugin/viewerplugincreatenoteinterface.cpp" "")
add_messageviewer_viewerplugin_unittest(viewerplugintranslatortest.cpp "../translatorplugin/viewerplugintranslator.cpp;../translatorplugin/viewerplugintranslatorinterface.cpp" "")
add_messageviewer_viewerplugin_unittest(viewerplugintranslatortest.cpp "../common/translatorplugin/viewerplugintranslator.cpp;../common/translatorplugin/viewerplugintranslatorinterface.cpp" "")
......@@ -16,7 +16,7 @@
*/
#include "viewerplugintranslatortest.h"
#include "../translatorplugin/viewerplugintranslator.h"
#include "../common/translatorplugin/viewerplugintranslator.h"
#include <QTest>
#include <KActionCollection>
#include <QHBoxLayout>
......
add_subdirectory(translatorplugin)
add_subdirectory(expandurlplugin)
......@@ -2,7 +2,7 @@
"KPlugin": {
"Name": "Expand Url",
"ServiceTypes": [
"MessageViewer/ViewerPlugin"
"MessageViewer/ViewerCommonPlugin"
],
"Version": "1.0"
}
......
......@@ -25,8 +25,8 @@
"Name[x-test]": "xxTranslatorxx",
"Name[zh_CN]": "翻译者",
"ServiceTypes": [
"MessageViewer/ViewerPlugin"
"MessageViewer/ViewerCommonPlugin"
],
"Version": "1.0"
}
}
\ No newline at end of file
}
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