summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-08-24 19:25:05 (GMT)
committerMontel Laurent <montel@kde.org>2016-08-24 19:25:05 (GMT)
commit45b172617ba7544fb04ec81724aa66f783902ed7 (patch)
treea8b31eb9dc57fbe617c1804ac649cadebd38c8a9
parente284a3a4b4ff8fe69aed0c16d120f920954e06df (diff)
Start to implement autocorrection tool
-rw-r--r--kmail/editorplugins/autocorrection/CMakeLists.txt17
-rw-r--r--kmail/editorplugins/autocorrection/autocorrectionplugineditor.cpp43
-rw-r--r--kmail/editorplugins/autocorrection/autocorrectionplugineditor.h38
-rw-r--r--kmail/editorplugins/autocorrection/autocorrectionplugineditorinterface.cpp56
-rw-r--r--kmail/editorplugins/autocorrection/autocorrectionplugineditorinterface.h40
-rw-r--r--kmail/editorplugins/autocorrection/autotests/CMakeLists.txt13
-rw-r--r--kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditorinterfacetest.cpp43
-rw-r--r--kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditorinterfacetest.h35
-rw-r--r--kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditortest.cpp42
-rw-r--r--kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditortest.h35
-rw-r--r--kmail/editorplugins/autocorrection/kmail_autocorrectioneditorplugin.json10
-rw-r--r--kmail/editorplugins/nonbreakingspace/nonbreakingspaceplugineditorinterface.cpp2
12 files changed, 373 insertions, 1 deletions
diff --git a/kmail/editorplugins/autocorrection/CMakeLists.txt b/kmail/editorplugins/autocorrection/CMakeLists.txt
index e69de29..89f08eb 100644
--- a/kmail/editorplugins/autocorrection/CMakeLists.txt
+++ b/kmail/editorplugins/autocorrection/CMakeLists.txt
@@ -0,0 +1,17 @@
+set(kmail_autocorrectioneditorplugin_SRCS
+ autocorrectionplugineditor.cpp
+ autocorrectionplugineditorinterface.cpp
+)
+
+add_library(kmail_autocorrectioneditorplugin MODULE ${kmail_autocorrectioneditorplugin_SRCS})
+
+target_link_libraries(kmail_autocorrectioneditorplugin
+ KF5::IconThemes KF5::MessageComposer KF5::XmlGui KF5::I18n
+)
+
+install(TARGETS kmail_autocorrectioneditorplugin DESTINATION ${PLUGIN_INSTALL_DIR}/kmail)
+
+if(BUILD_TESTING)
+ add_subdirectory(autotests)
+endif()
+
diff --git a/kmail/editorplugins/autocorrection/autocorrectionplugineditor.cpp b/kmail/editorplugins/autocorrection/autocorrectionplugineditor.cpp
new file mode 100644
index 0000000..f8bf73d
--- /dev/null
+++ b/kmail/editorplugins/autocorrection/autocorrectionplugineditor.cpp
@@ -0,0 +1,43 @@
+/*
+ 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 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 "autocorrectionplugineditor.h"
+#include "autocorrectionplugineditorinterface.h"
+#include <kpluginfactory.h>
+
+K_PLUGIN_FACTORY_WITH_JSON(AutoCorrectionPluginEditorFactory, "kmail_autocorrectioneditorplugin.json", registerPlugin<AutoCorrectionPluginEditor>();)
+
+AutoCorrectionPluginEditor::AutoCorrectionPluginEditor(QObject *parent, const QList<QVariant> &)
+ : MessageComposer::PluginEditor(parent)
+{
+}
+
+AutoCorrectionPluginEditor::~AutoCorrectionPluginEditor()
+{
+
+}
+
+MessageComposer::PluginEditorInterface *AutoCorrectionPluginEditor::createInterface(KActionCollection *ac, QObject *parent)
+{
+ AutoCorrectionPluginEditorInterface *interface = new AutoCorrectionPluginEditorInterface(parent);
+ interface->createAction(ac);
+ return interface;
+}
+
+#include "autocorrectionplugineditor.moc"
diff --git a/kmail/editorplugins/autocorrection/autocorrectionplugineditor.h b/kmail/editorplugins/autocorrection/autocorrectionplugineditor.h
new file mode 100644
index 0000000..6405fd0
--- /dev/null
+++ b/kmail/editorplugins/autocorrection/autocorrectionplugineditor.h
@@ -0,0 +1,38 @@
+/*
+ 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 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 AUTOCORRECTIONPLUGINEDITOR_H
+#define AUTOCORRECTIONPLUGINEDITOR_H
+
+#include <messagecomposer/plugineditor.h>
+
+#include <messagecomposer/plugineditorinterface.h>
+#include <QVariant>
+
+class AutoCorrectionPluginEditor : public MessageComposer::PluginEditor
+{
+ Q_OBJECT
+public:
+ explicit AutoCorrectionPluginEditor(QObject *parent = Q_NULLPTR, const QList<QVariant> & = QList<QVariant>());
+ ~AutoCorrectionPluginEditor();
+
+ MessageComposer::PluginEditorInterface *createInterface(KActionCollection *ac, QObject *parent = Q_NULLPTR) Q_DECL_OVERRIDE;
+};
+
+#endif
diff --git a/kmail/editorplugins/autocorrection/autocorrectionplugineditorinterface.cpp b/kmail/editorplugins/autocorrection/autocorrectionplugineditorinterface.cpp
new file mode 100644
index 0000000..a34b9e6
--- /dev/null
+++ b/kmail/editorplugins/autocorrection/autocorrectionplugineditorinterface.cpp
@@ -0,0 +1,56 @@
+/*
+ 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 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 "autocorrectionplugineditorinterface.h"
+#include <KPIMTextEdit/RichTextEditor>
+#include <KLocalizedString>
+#include <KActionCollection>
+#include <QAction>
+
+AutoCorrectionPluginEditorInterface::AutoCorrectionPluginEditorInterface(QObject *parent)
+ : MessageComposer::PluginEditorInterface(parent)
+{
+}
+
+AutoCorrectionPluginEditorInterface::~AutoCorrectionPluginEditorInterface()
+{
+
+}
+
+void AutoCorrectionPluginEditorInterface::createAction(KActionCollection *ac)
+{
+ QAction *action = new QAction(i18n("Autocorrect Text"), this);
+ ac->addAction(QStringLiteral("autocorrect_tool"), action);
+ connect(action, &QAction::triggered, this, &AutoCorrectionPluginEditorInterface::slotActivated);
+ MessageComposer::ActionType type(action, MessageComposer::ActionType::Tools);
+ setActionType(type);
+}
+
+void AutoCorrectionPluginEditorInterface::slotActivated()
+{
+ Q_EMIT emitPluginActivated(this);
+}
+
+void AutoCorrectionPluginEditorInterface::exec()
+{
+ //TODO
+#if 0
+ richTextEditor()->insertPlainText(QChar(0x000A0));
+#endif
+}
diff --git a/kmail/editorplugins/autocorrection/autocorrectionplugineditorinterface.h b/kmail/editorplugins/autocorrection/autocorrectionplugineditorinterface.h
new file mode 100644
index 0000000..6fcb8be
--- /dev/null
+++ b/kmail/editorplugins/autocorrection/autocorrectionplugineditorinterface.h
@@ -0,0 +1,40 @@
+/*
+ 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 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 AUTOCORRECTIONPLUGINEDITORINTERFACE_H
+#define AUTOCORRECTIONPLUGINEDITORINTERFACE_H
+
+#include <messagecomposer/plugineditorinterface.h>
+#include <QPointer>
+
+class AutoCorrectionPluginEditorInterface : public MessageComposer::PluginEditorInterface
+{
+ Q_OBJECT
+public:
+ explicit AutoCorrectionPluginEditorInterface(QObject *parent = Q_NULLPTR);
+ ~AutoCorrectionPluginEditorInterface();
+
+ void createAction(KActionCollection *ac) Q_DECL_OVERRIDE;
+ void exec() Q_DECL_OVERRIDE;
+
+private Q_SLOTS:
+ void slotActivated();
+};
+
+#endif
diff --git a/kmail/editorplugins/autocorrection/autotests/CMakeLists.txt b/kmail/editorplugins/autocorrection/autotests/CMakeLists.txt
new file mode 100644
index 0000000..5eb089d
--- /dev/null
+++ b/kmail/editorplugins/autocorrection/autotests/CMakeLists.txt
@@ -0,0 +1,13 @@
+macro(add_kmail_editorplugin_unittest _source _additional)
+ set( _test ${_source} ${_additional})
+ get_filename_component(_name ${_source} NAME_WE)
+ add_executable( ${_name} ${_test} )
+ add_test( ${_name} ${_name} )
+
+ ecm_mark_as_test(kmail_editorplugin-${_name})
+ target_link_libraries( ${_name} Qt5::Test KF5::XmlGui KF5::IconThemes KF5::MessageComposer KF5::I18n)
+endmacro ()
+
+add_kmail_editorplugin_unittest(autocorrectionplugineditortest.cpp "../autocorrectionplugineditor.cpp;../autocorrectionplugineditorinterface.cpp")
+
+add_kmail_editorplugin_unittest(autocorrectionplugineditorinterfacetest.cpp "../autocorrectionplugineditorinterface.cpp")
diff --git a/kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditorinterfacetest.cpp b/kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditorinterfacetest.cpp
new file mode 100644
index 0000000..00964fd
--- /dev/null
+++ b/kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditorinterfacetest.cpp
@@ -0,0 +1,43 @@
+/*
+ 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 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 "autocorrectionplugineditorinterfacetest.h"
+#include "../autocorrectionplugineditorinterface.h"
+#include <QTest>
+
+AutoCorrectionPluginEditorInterfaceTest::AutoCorrectionPluginEditorInterfaceTest(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+AutoCorrectionPluginEditorInterfaceTest::~AutoCorrectionPluginEditorInterfaceTest()
+{
+
+}
+
+void AutoCorrectionPluginEditorInterfaceTest::shouldHaveDefaultValue()
+{
+ AutoCorrectionPluginEditorInterface interface;
+ QVERIFY(!interface.hasConfigureDialog());
+ QVERIFY(!interface.hasPopupMenuSupport());
+ QVERIFY(!interface.hasToolBarSupport());
+}
+
+QTEST_MAIN(AutoCorrectionPluginEditorInterfaceTest)
diff --git a/kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditorinterfacetest.h b/kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditorinterfacetest.h
new file mode 100644
index 0000000..67e70f7
--- /dev/null
+++ b/kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditorinterfacetest.h
@@ -0,0 +1,35 @@
+/*
+ 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 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 AutoCorrectionPLUGINEDITORINTERFACETEST_H
+#define AutoCorrectionPLUGINEDITORINTERFACETEST_H
+
+#include <QObject>
+
+class AutoCorrectionPluginEditorInterfaceTest : public QObject
+{
+ Q_OBJECT
+public:
+ explicit AutoCorrectionPluginEditorInterfaceTest(QObject *parent = Q_NULLPTR);
+ ~AutoCorrectionPluginEditorInterfaceTest();
+private Q_SLOTS:
+ void shouldHaveDefaultValue();
+};
+
+#endif
diff --git a/kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditortest.cpp b/kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditortest.cpp
new file mode 100644
index 0000000..536bfc7
--- /dev/null
+++ b/kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditortest.cpp
@@ -0,0 +1,42 @@
+/*
+ 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 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 "autocorrectionplugineditortest.h"
+#include "../autocorrectionplugineditor.h"
+#include <KActionCollection>
+#include <QTest>
+
+AutoCorrectionPluginEditorTest::AutoCorrectionPluginEditorTest(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+AutoCorrectionPluginEditorTest::~AutoCorrectionPluginEditorTest()
+{
+
+}
+
+void AutoCorrectionPluginEditorTest::shouldHaveDefaultValue()
+{
+ AutoCorrectionPluginEditor plugin;
+ QVERIFY(plugin.createInterface(new KActionCollection(this)));
+}
+
+QTEST_MAIN(AutoCorrectionPluginEditorTest)
diff --git a/kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditortest.h b/kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditortest.h
new file mode 100644
index 0000000..38b9d77
--- /dev/null
+++ b/kmail/editorplugins/autocorrection/autotests/autocorrectionplugineditortest.h
@@ -0,0 +1,35 @@
+/*
+ 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 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 AutoCorrectionPLUGINEDITORTEST_H
+#define AutoCorrectionPLUGINEDITORTEST_H
+
+#include <QObject>
+
+class AutoCorrectionPluginEditorTest : public QObject
+{
+ Q_OBJECT
+public:
+ explicit AutoCorrectionPluginEditorTest(QObject *parent = Q_NULLPTR);
+ ~AutoCorrectionPluginEditorTest();
+private Q_SLOTS:
+ void shouldHaveDefaultValue();
+};
+
+#endif
diff --git a/kmail/editorplugins/autocorrection/kmail_autocorrectioneditorplugin.json b/kmail/editorplugins/autocorrection/kmail_autocorrectioneditorplugin.json
new file mode 100644
index 0000000..90be6b4
--- /dev/null
+++ b/kmail/editorplugins/autocorrection/kmail_autocorrectioneditorplugin.json
@@ -0,0 +1,10 @@
+{
+ "KPlugin": {
+ "Name": "Autocorrection",
+ "ServiceTypes": [
+ "KMailEditor/Plugin"
+ ],
+ "Version": "1.0"
+ },
+ "X-KDE-KMailEditor-Order": "2"
+}
diff --git a/kmail/editorplugins/nonbreakingspace/nonbreakingspaceplugineditorinterface.cpp b/kmail/editorplugins/nonbreakingspace/nonbreakingspaceplugineditorinterface.cpp
index 5d3889e..4459975 100644
--- a/kmail/editorplugins/nonbreakingspace/nonbreakingspaceplugineditorinterface.cpp
+++ b/kmail/editorplugins/nonbreakingspace/nonbreakingspaceplugineditorinterface.cpp
@@ -22,7 +22,7 @@
#include <KLocalizedString>
#include <KActionCollection>
#include <QAction>
-#include <QDebug>
+
NonBreakingSpacePluginEditorInterface::NonBreakingSpacePluginEditorInterface(QObject *parent)
: MessageComposer::PluginEditorInterface(parent)
{