Commit f2a16ddc authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add grammalecte plugin

parent 9e59411c
......@@ -71,7 +71,7 @@ find_package(KF5Holidays ${KF5_MIN_VERSION} CONFIG REQUIRED)
set(MAILCOMMON_LIB_VERSION "5.10.40")
set(GRAVATAR_LIB_VERSION "5.10.40")
set(PIMCOMMON_LIB_VERSION "5.10.41")
set(PIMCOMMON_LIB_VERSION "5.10.42")
set(GRANTLEETHEME_LIB_VERSION "5.10.40")
set(CALENDARSUPPORT_LIB_VERSION "5.10.40")
set(EVENTVIEW_LIB_VERSION "5.10.40")
......
add_definitions(-DTRANSLATION_DOMAIN=\"kmail_editorgrammar_plugins\")
add_subdirectory(src)
add_subdirectory(plugin)
if(BUILD_TESTING)
add_subdirectory(tests)
add_subdirectory(autotests)
......
#! /bin/sh
$XGETTEXT `find . -name '*.cpp' -o -name '*.h' | grep -v '/tests/' | grep -v '/autotests/'` -o $podir/kmail_editorgrammar_plugins.pot
if(BUILD_TESTING)
add_subdirectory(autotests)
endif()
set(grammalecteplugin_SRCS
grammalecteplugin.cpp
grammalecteinterface.cpp
)
kcoreaddons_add_plugin(kmail_grammalecteplugin JSON kmail_grammalecteplugin.json SOURCES
${grammalecteplugin_SRCS} INSTALL_NAMESPACE kmail)
target_link_libraries(kmail_grammalecteplugin
KF5::IconThemes KF5::MessageComposer KF5::I18n KF5::PimCommon KF5::XmlGui libkmailgrammalecte
)
/*
Copyright (C) 2019 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 as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "grammalecteinterface.h"
#include "grammarresultwidget.h"
#include <KPIMTextEdit/RichTextComposer>
#include <KToggleAction>
#include <KLocalizedString>
#include <KActionCollection>
#include <QDebug>
#include <QHBoxLayout>
GrammalecteInterface::GrammalecteInterface(KActionCollection *ac, QWidget *parent)
: MessageComposer::PluginEditorGrammarCustomToolsViewInterface(parent)
{
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
mGrammarResultWidget = new GrammarResultWidget(this);
//TODO ????
//connect(mTranslatorWidget, &PimCommon::TranslatorWidget::toolsWasClosed, this, &TranslatorView::toolsWasClosed);
layout->addWidget(mGrammarResultWidget);
createAction(ac);
}
GrammalecteInterface::~GrammalecteInterface()
{
}
void GrammalecteInterface::slotActivateGrammalecte(bool state)
{
if (state) {
mGrammarResultWidget->show();
Q_EMIT activateView(this);
} else {
mGrammarResultWidget->hide();
Q_EMIT activateView(nullptr);
}
}
void GrammalecteInterface::setText(const QString &text)
{
//TOOD ???? using it ?
Q_UNUSED(text);
if (richTextEditor()) {
mGrammarResultWidget->setText(richTextEditor()->toPlainText());
} else {
//Add qdebug categories
qWarning() << "RichTextEditor not setted";
}
}
KToggleAction *GrammalecteInterface::action() const
{
return mAction;
}
void GrammalecteInterface::createAction(KActionCollection *ac)
{
mAction = new KToggleAction(i18n("&Check Grammar (Grammalecte)"), this);
connect(mAction, &KToggleAction::triggered, this, &GrammalecteInterface::slotActivateGrammalecte);
if (ac) {
ac->addAction(QStringLiteral("checkgrammar-grammalecte"), mAction);
//ac->setDefaultShortcut(mAction, QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_T));
}
mAction->setChecked(false);
}
/*
Copyright (C) 2019 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 as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef GRAMMALECTEINTERFACE_H
#define GRAMMALECTEINTERFACE_H
#include <MessageComposer/PluginEditorGrammarCustomToolsViewInterface>
class KActionCollection;
class GrammarResultWidget;
class GrammalecteInterface : public MessageComposer::PluginEditorGrammarCustomToolsViewInterface
{
Q_OBJECT
public:
explicit GrammalecteInterface(KActionCollection *ac, QWidget *parent = nullptr);
~GrammalecteInterface() override;
void setText(const QString &text) override;
KToggleAction *action() const override;
private:
void slotActivateGrammalecte(bool state);
void createAction(KActionCollection *ac);
GrammarResultWidget *mGrammarResultWidget = nullptr;
KToggleAction *mAction = nullptr;
};
#endif // GRAMMALECTEINTERFACE_H
/*
Copyright (C) 2019 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 as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "grammalecteplugin.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
K_PLUGIN_CLASS_WITH_JSON(GrammalectePlugin, "kmail_grammalecteplugin.json")
GrammalectePlugin::GrammalectePlugin(QObject *parent, const QList<QVariant> &)
: PimCommon::CustomToolsPlugin(parent)
{
}
GrammalectePlugin::~GrammalectePlugin()
{
}
PimCommon::CustomToolsViewInterface *GrammalectePlugin::createView(KActionCollection *ac, PimCommon::CustomToolsWidgetNg *parent)
{
//TODO
return {};
}
QString GrammalectePlugin::customToolName() const
{
return i18n("Grammalecte Plugin");
}
bool GrammalectePlugin::hasConfigureDialog() const
{
return true;
}
void GrammalectePlugin::showConfigureDialog(QWidget *parent)
{
//TODO
}
QString GrammalectePlugin::description() const
{
//TODO
return {};
}
#include "grammalecteplugin.moc"
/*
Copyright (C) 2019 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 as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef GRAMMALECTEPLUGIN_H
#define GRAMMALECTEPLUGIN_H
#include <PimCommon/CustomToolsPlugin>
#include <QVariant>
class GrammalectePlugin : public PimCommon::CustomToolsPlugin
{
Q_OBJECT
public:
explicit GrammalectePlugin(QObject *parent = nullptr, const QList<QVariant> & = QList<QVariant>());
~GrammalectePlugin() override;
PimCommon::CustomToolsViewInterface *createView(KActionCollection *ac, PimCommon::CustomToolsWidgetNg *parent) override;
Q_REQUIRED_RESULT QString customToolName() const override;
Q_REQUIRED_RESULT bool hasConfigureDialog() const override;
void showConfigureDialog(QWidget *parent) override;
Q_REQUIRED_RESULT QString description() const override;
};
#endif // GRAMMALECTEPLUGIN_H
{
"KPlugin": {
"Description": "This plugin allows you to check grammar in french only.",
"EnabledByDefault": "false",
"Id": "kmailgrammalecte",
"Name": "French Grammar Checker",
"ServiceTypes": [
"KMailEditor/PluginEditorGrammar"
],
"Version": "1.0"
}
}
......@@ -26,10 +26,3 @@ set_target_properties(libkmailgrammalecte
install(TARGETS libkmailgrammalecte ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP)
#kcoreaddons_add_plugin(kmail_grammalecteplugin JSON kmail_grammalecteplugin.json SOURCES
# ${kmail_grammalecteplugin_SRCS} INSTALL_NAMESPACE kmail)
#target_link_libraries(kmail_grammalecteplugin
# KF5::IconThemes KF5::MessageComposer KF5::I18n KF5::PimCommon libkmailgrammalect
# )
......@@ -21,10 +21,10 @@
#define GRAMMARRESULTWIDGET_H
#include <QWidget>
#include "libgrammalect_private_export.h"
#include "libkmailgrammalect_export.h"
#include "grammalectegrammarerror.h"
class GrammarResultTextEdit;
class LIBGRAMMALECTPRIVATE_TESTS_EXPORT GrammarResultWidget : public QWidget
class LIBKMAILGRAMMALECT_EXPORT GrammarResultWidget : public QWidget
{
Q_OBJECT
public:
......
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