File indexing completed on 2025-01-19 04:46:43
0001 /* 0002 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "grammalecteplugin.h" 0008 #include "grammalecteinterface.h" 0009 #include <KLocalizedString> 0010 #include <KPluginFactory> 0011 #include <PimCommon/CustomToolsWidgetng> 0012 #include <TextGrammarCheck/GrammalecteConfigDialog> 0013 #include <TextGrammarCheck/GrammalecteManager> 0014 0015 #include <QPointer> 0016 0017 K_PLUGIN_CLASS_WITH_JSON(GrammalectePlugin, "kmail_grammalecteplugin.json") 0018 GrammalectePlugin::GrammalectePlugin(QObject *parent, const QList<QVariant> &) 0019 : PimCommon::CustomToolsPlugin(parent) 0020 { 0021 } 0022 0023 GrammalectePlugin::~GrammalectePlugin() = default; 0024 0025 PimCommon::CustomToolsViewInterface *GrammalectePlugin::createView(KActionCollection *ac, PimCommon::CustomToolsWidgetNg *parent) 0026 { 0027 auto view = new GrammalecteInterface(ac, parent); 0028 0029 connect(view, &GrammalecteInterface::toolsWasClosed, parent, &PimCommon::CustomToolsWidgetNg::slotToolsWasClosed); 0030 connect(view, &GrammalecteInterface::insertText, parent, &PimCommon::CustomToolsWidgetNg::insertText); 0031 connect(view, &GrammalecteInterface::activateView, parent, &PimCommon::CustomToolsWidgetNg::slotActivateView); 0032 connect(view, &GrammalecteInterface::configure, this, &GrammalectePlugin::showConfigureDialog); 0033 return view; 0034 } 0035 0036 QString GrammalectePlugin::customToolName() const 0037 { 0038 return i18n("Grammalecte Plugin"); 0039 } 0040 0041 bool GrammalectePlugin::hasConfigureDialog() const 0042 { 0043 return true; 0044 } 0045 0046 void GrammalectePlugin::showConfigureDialog(QWidget *parent) 0047 { 0048 QPointer<TextGrammarCheck::GrammalecteConfigDialog> dlg = new TextGrammarCheck::GrammalecteConfigDialog(parent); 0049 if (dlg->exec()) { 0050 TextGrammarCheck::GrammalecteManager::self()->loadSettings(); 0051 } 0052 delete dlg; 0053 } 0054 0055 #include "grammalecteplugin.moc" 0056 0057 #include "moc_grammalecteplugin.cpp"