Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 85221ce3 authored by Laurent Montel's avatar Laurent Montel 😁

Create plugin

parent d3ecb8c7
......@@ -41,3 +41,4 @@ org.kde.pim.mailtransport_sendmail kdepim-addons (kmailtransport sendmail plugin
org.kde.pim.kmail_sharetexteditorplugin kdepim-addons (share text editor plugin) IDENTIFIER [KMAIL_EDITOR_SHARETEXT_PLUGIN_LOG]
org.kde.pim.kmail_grammalecteplugin kdepim-addons (grammalecte plugin) IDENTIFIER [KMAIL_EDITOR_GRAMMALECTE_PLUGIN_LOG]
org.kde.pim.libgrammalecteplugin kdepim-addons (libgramalecte) IDENTIFIER [LIBGRAMMALECTE_PLUGIN_LOG]
org.kde.pim.kmail_languagetoolplugin kdepim-addons (languagetool plugin) IDENTIFIER [KMAIL_EDITOR_LANGUAGETOOL_PLUGIN_LOG]
......@@ -18,10 +18,30 @@
*/
#include "languagetoolconfigdialogtest.h"
#include "languagetoolconfigdialog.h"
#include "languagetoolconfigwidget.h"
#include <QVBoxLayout>
#include <QStandardPaths>
#include <QTest>
#include <QDialogButtonBox>
QTEST_MAIN(LanguagetoolConfigDialogTest)
LanguagetoolConfigDialogTest::LanguagetoolConfigDialogTest(QObject *parent)
: QObject(parent)
{
QStandardPaths::setTestModeEnabled(true);
}
void LanguagetoolConfigDialogTest::shouldHaveDefaultValue()
{
LanguagetoolConfigDialog w(nullptr, true);
QVERIFY(!w.windowTitle().isEmpty());
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout);
LanguagetoolConfigWidget *mConfigWidget = w.findChild<LanguagetoolConfigWidget *>(QStringLiteral("configwidget"));
QVERIFY(mConfigWidget);
QDialogButtonBox *box = w.findChild<QDialogButtonBox *>(QStringLiteral("box"));
QVERIFY(box);
}
......@@ -28,6 +28,8 @@ class LanguagetoolConfigDialogTest : public QObject
public:
explicit LanguagetoolConfigDialogTest(QObject *parent = nullptr);
~LanguagetoolConfigDialogTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // LANGUAGETOOLCONFIGDIALOGTEST_H
if(BUILD_TESTING)
add_subdirectory(autotests)
endif()
set(languagetoolplugin_SRCS
languagetoolplugin.cpp
languagetoolinterface.cpp
)
ecm_qt_declare_logging_category(languagetoolplugin_SRCS HEADER languagetoolplugin_debug.h IDENTIFIER KMAIL_EDITOR_LANGUAGETOOL_PLUGIN_LOG CATEGORY_NAME org.kde.pim.kmail_languagetoolplugin)
kcoreaddons_add_plugin(kmail_languagetoolplugin JSON kmail_languagetoolplugin.json SOURCES
${languagetoolplugin_SRCS} INSTALL_NAMESPACE kmail)
target_link_libraries(kmail_languagetoolplugin
KF5::IconThemes KF5::MessageComposer KF5::I18n KF5::PimCommon KF5::XmlGui kmaillanguagetool grammarcommon
)
......@@ -18,7 +18,7 @@
*/
#include "languagetoolinterface.h"
#include "grammalecteresultwidget.h"
#include "languagetoolresultwidget.h"
#include "languagetoolplugin_debug.h"
#include <KPIMTextEdit/RichTextComposer>
......@@ -35,9 +35,9 @@ LanguagetoolInterface::LanguagetoolInterface(KActionCollection *ac, QWidget *par
{
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
mGrammarResultWidget = new GrammalecteResultWidget(this);
connect(mGrammarResultWidget, &GrammalecteResultWidget::replaceText, this, &LanguagetoolInterface::slotReplaceText);
connect(mGrammarResultWidget, &GrammalecteResultWidget::checkAgain, this, &LanguagetoolInterface::checkAgain);
mGrammarResultWidget = new LanguagetoolResultWidget(this);
connect(mGrammarResultWidget, &LanguagetoolResultWidget::replaceText, this, &LanguagetoolInterface::slotReplaceText);
connect(mGrammarResultWidget, &LanguagetoolResultWidget::checkAgain, this, &LanguagetoolInterface::checkAgain);
layout->addWidget(mGrammarResultWidget);
createAction(ac);
......@@ -94,6 +94,6 @@ void LanguagetoolInterface::checkAgain()
mGrammarResultWidget->setText(richTextEditor()->toPlainText());
mGrammarResultWidget->checkGrammar();
} else {
qCWarning(KMAIL_EDITOR_GRAMMALECTE_PLUGIN_LOG) << "richtexteditor not setted, it's a bug";
qCWarning(KMAIL_EDITOR_LANGUAGETOOL_PLUGIN_LOG) << "richtexteditor not setted, it's a bug";
}
}
......@@ -21,7 +21,7 @@
#include <MessageComposer/PluginEditorGrammarCustomToolsViewInterface>
class KActionCollection;
class GrammalecteResultWidget;
class LanguagetoolResultWidget;
class LanguagetoolInterface : public MessageComposer::PluginEditorGrammarCustomToolsViewInterface
{
Q_OBJECT
......@@ -36,7 +36,7 @@ private:
void slotActivateGrammalecte(bool state);
void createAction(KActionCollection *ac);
void checkAgain();
GrammalecteResultWidget *mGrammarResultWidget = nullptr;
LanguagetoolResultWidget *mGrammarResultWidget = nullptr;
KToggleAction *mAction = nullptr;
};
......
......@@ -18,9 +18,9 @@
*/
#include "languagetoolplugin.h"
#include "grammalecteinterface.h"
#include "grammalecteconfigdialog.h"
#include "grammalectemanager.h"
#include "languagetoolinterface.h"
#include "languagetoolconfigdialog.h"
//#include "grammalectemanager.h"
#include <PimCommon/CustomToolsWidgetng>
#include <KLocalizedString>
#include <kpluginfactory.h>
......@@ -39,17 +39,17 @@ LanguagetoolPlugin::~LanguagetoolPlugin()
PimCommon::CustomToolsViewInterface *LanguagetoolPlugin::createView(KActionCollection *ac, PimCommon::CustomToolsWidgetNg *parent)
{
GrammalecteInterface *view = new GrammalecteInterface(ac, parent);
LanguagetoolInterface *view = new LanguagetoolInterface(ac, parent);
connect(view, &GrammalecteInterface::toolsWasClosed, parent, &PimCommon::CustomToolsWidgetNg::slotToolsWasClosed);
connect(view, &GrammalecteInterface::insertText, parent, &PimCommon::CustomToolsWidgetNg::insertText);
connect(view, &GrammalecteInterface::activateView, parent, &PimCommon::CustomToolsWidgetNg::slotActivateView);
connect(view, &LanguagetoolInterface::toolsWasClosed, parent, &PimCommon::CustomToolsWidgetNg::slotToolsWasClosed);
connect(view, &LanguagetoolInterface::insertText, parent, &PimCommon::CustomToolsWidgetNg::insertText);
connect(view, &LanguagetoolInterface::activateView, parent, &PimCommon::CustomToolsWidgetNg::slotActivateView);
return view;
}
QString LanguagetoolPlugin::customToolName() const
{
return i18n("Grammalecte Plugin");
return i18n("Languagetool Plugin");
}
bool LanguagetoolPlugin::hasConfigureDialog() const
......@@ -59,9 +59,9 @@ bool LanguagetoolPlugin::hasConfigureDialog() const
void LanguagetoolPlugin::showConfigureDialog(QWidget *parent)
{
QPointer<GrammalecteConfigDialog> dlg = new GrammalecteConfigDialog(parent);
QPointer<LanguagetoolConfigDialog> dlg = new LanguagetoolConfigDialog(parent);
if (dlg->exec()) {
GrammalecteManager::self()->loadSettings();
//TODO GrammalecteManager::self()->loadSettings();
}
delete dlg;
}
......
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