File indexing completed on 2025-01-19 04:46:47

0001 /*
0002    SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "translatorplugin.h"
0008 #include "translatorview.h"
0009 #include <KLocalizedString>
0010 #include <KPluginFactory>
0011 #include <PimCommon/CustomToolsWidgetng>
0012 #include <TextTranslator/TranslatorConfigureDialog>
0013 K_PLUGIN_CLASS_WITH_JSON(TranslatorPlugin, "pimcommon_translatorplugin.json")
0014 TranslatorPlugin::TranslatorPlugin(QObject *parent, const QList<QVariant> &)
0015     : PimCommon::CustomToolsPlugin(parent)
0016 {
0017 }
0018 
0019 TranslatorPlugin::~TranslatorPlugin() = default;
0020 
0021 PimCommon::CustomToolsViewInterface *TranslatorPlugin::createView(KActionCollection *ac, PimCommon::CustomToolsWidgetNg *parent)
0022 {
0023     auto view = new TranslatorView(ac, parent);
0024 
0025     connect(view, &TranslatorView::toolsWasClosed, parent, &PimCommon::CustomToolsWidgetNg::slotToolsWasClosed);
0026     connect(view, &TranslatorView::insertText, parent, &PimCommon::CustomToolsWidgetNg::insertText);
0027     connect(view, &TranslatorView::activateView, parent, &PimCommon::CustomToolsWidgetNg::slotActivateView);
0028     return view;
0029 }
0030 
0031 QString TranslatorPlugin::customToolName() const
0032 {
0033     return i18n("Translator");
0034 }
0035 
0036 bool TranslatorPlugin::hasConfigureDialog() const
0037 {
0038     return true;
0039 }
0040 
0041 void TranslatorPlugin::showConfigureDialog(QWidget *parent)
0042 {
0043     TextTranslator::TranslatorConfigureDialog dialog(parent);
0044     dialog.exec();
0045 }
0046 
0047 #include "translatorplugin.moc"
0048 
0049 #include "moc_translatorplugin.cpp"