Commit 47bf5796 authored by Laurent Montel's avatar Laurent Montel 😁

Add zoomtext plugins

parent 3a17cf7b
add_definitions(-DTRANSLATION_DOMAIN=\"kmail_editor_plugins\")
add_subdirectory(insertspecialcharacter)
add_subdirectory(changecase)
add_subdirectory(zoomtext)
set(kmail_zoomtexteditorplugin_SRCS
zoomtextplugineditor.cpp
zoomtextplugineditorinterface.cpp
)
add_library(kmail_zoomtexteditorplugin MODULE ${kmail_zoomtexteditorplugin_SRCS})
target_link_libraries(kmail_zoomtexteditorplugin
KF5::IconThemes KF5::MessageComposer KF5::XmlGui
)
install(TARGETS kmail_zoomtexteditorplugin DESTINATION ${PLUGIN_INSTALL_DIR}/kmail)
if(BUILD_TESTING)
add_subdirectory(autotests)
endif()
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)
endmacro ()
add_kmail_editorplugin_unittest(zoomtextplugineditortest.cpp "../zoomtextplugineditor.cpp;../zoomtextplugineditorinterface.cpp")
add_kmail_editorplugin_unittest(zoomtextplugineditorinterfacetest.cpp "../zoomtextplugineditorinterface.cpp")
/*
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, version 2, as
published by the Free Software Foundation.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "zoomtextplugineditorinterfacetest.h"
#include "../zoomtextplugineditorinterface.h"
#include <QTest>
ZoomTextPluginEditorInterfaceTest::ZoomTextPluginEditorInterfaceTest(QObject *parent)
: QObject(parent)
{
}
ZoomTextPluginEditorInterfaceTest::~ZoomTextPluginEditorInterfaceTest()
{
}
QTEST_MAIN(ZoomTextPluginEditorInterfaceTest)
/*
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, version 2, as
published by the Free Software Foundation.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ZoomTextPLUGINEDITORINTERFACETEST_H
#define ZoomTextPLUGINEDITORINTERFACETEST_H
#include <QObject>
class ZoomTextPluginEditorInterfaceTest : public QObject
{
Q_OBJECT
public:
explicit ZoomTextPluginEditorInterfaceTest(QObject *parent = Q_NULLPTR);
~ZoomTextPluginEditorInterfaceTest();
};
#endif
/*
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, version 2, as
published by the Free Software Foundation.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "zoomtextplugineditortest.h"
#include "../zoomtextplugineditor.h"
#include <KActionCollection>
#include <QTest>
ZoomTextPluginEditorTest::ZoomTextPluginEditorTest(QObject *parent)
: QObject(parent)
{
}
ZoomTextPluginEditorTest::~ZoomTextPluginEditorTest()
{
}
void ZoomTextPluginEditorTest::shouldHaveDefaultValue()
{
ZoomTextPluginEditor plugin;
QVERIFY(plugin.createInterface(new KActionCollection(this)));
}
QTEST_MAIN(ZoomTextPluginEditorTest)
/*
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, version 2, as
published by the Free Software Foundation.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ZoomTextPLUGINEDITORTEST_H
#define ZoomTextPLUGINEDITORTEST_H
#include <QObject>
class ZoomTextPluginEditorTest : public QObject
{
Q_OBJECT
public:
explicit ZoomTextPluginEditorTest(QObject *parent = Q_NULLPTR);
~ZoomTextPluginEditorTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif
{
"KPlugin": {
"Name": "Zoom Text",
"ServiceTypes": [
"KMailEditor/Plugin"
],
"Version": "1.0"
},
"X-KDE-KMailEditor-Order": "2"
}
/*
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, version 2, as
published by the Free Software Foundation.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "zoomtextplugineditor.h"
#include "zoomtextplugineditorinterface.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
K_PLUGIN_FACTORY_WITH_JSON(ZoomTextPluginEditorFactory, "kmail_zoomtexteditorplugin.json", registerPlugin<ZoomTextPluginEditor>();)
ZoomTextPluginEditor::ZoomTextPluginEditor(QObject *parent, const QList<QVariant> &)
: MessageComposer::PluginEditor(parent)
{
}
ZoomTextPluginEditor::~ZoomTextPluginEditor()
{
}
MessageComposer::PluginEditorInterface *ZoomTextPluginEditor::createInterface(KActionCollection *ac, QObject *parent)
{
ZoomTextPluginEditorInterface *interface = new ZoomTextPluginEditorInterface(parent);
interface->createAction(ac);
return interface;
}
#include "zoomtextplugineditor.moc"
/*
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, version 2, as
published by the Free Software Foundation.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ZOOMTEXTPLUGINEDITOR_H
#define ZOOMTEXTPLUGINEDITOR_H
#include <messagecomposer/plugineditor.h>
#include <messagecomposer/plugineditorinterface.h>
#include <QVariant>
class ZoomTextPluginEditor : public MessageComposer::PluginEditor
{
Q_OBJECT
public:
explicit ZoomTextPluginEditor(QObject *parent = Q_NULLPTR, const QList<QVariant> & = QList<QVariant>());
~ZoomTextPluginEditor();
MessageComposer::PluginEditorInterface *createInterface(KActionCollection *ac, QObject *parent = Q_NULLPTR) Q_DECL_OVERRIDE;
};
#endif
/*
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, version 2, as
published by the Free Software Foundation.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "zoomtextplugineditorinterface.h"
#include <KPIMTextEdit/RichTextEditor>
#include <KLocalizedString>
#include <KActionCollection>
#include <QAction>
#include <QDebug>
ZoomTextPluginEditorInterface::ZoomTextPluginEditorInterface(QObject *parent)
: MessageComposer::PluginEditorInterface(parent),
mType(Unknown)
{
}
ZoomTextPluginEditorInterface::~ZoomTextPluginEditorInterface()
{
}
bool ZoomTextPluginEditorInterface::hasPopupMenuSupport() const
{
return false;
}
void ZoomTextPluginEditorInterface::createAction(KActionCollection *ac)
{
#if 0
PimCommon::KActionMenuZoomText *ZoomTextMenu = new PimCommon::KActionMenuZoomText(this);
ZoomTextMenu->appendInActionCollection(ac);
ac->addAction(QStringLiteral("change_case_menu"), ZoomTextMenu);
connect(ZoomTextMenu, &PimCommon::KActionMenuZoomText::upperCase, this, &ZoomTextPluginEditorInterface::slotUpperCase);
connect(ZoomTextMenu, &PimCommon::KActionMenuZoomText::lowerCase, this, &ZoomTextPluginEditorInterface::slotLowerCase);
connect(ZoomTextMenu, &PimCommon::KActionMenuZoomText::sentenceCase, this, &ZoomTextPluginEditorInterface::slotSentenceCase);
connect(ZoomTextMenu, &PimCommon::KActionMenuZoomText::reverseCase, this, &ZoomTextPluginEditorInterface::slotReverseCase);
MessageComposer::ActionType type(ZoomTextMenu, MessageComposer::ActionType::Edit);
setActionType(type);
#endif
}
void ZoomTextPluginEditorInterface::exec()
{
#if 0
switch(mType) {
case Unknown:
qDebug() << " There is an error here. We can't call this plugin with unknown type";
break;
case UpperCase:
upperCase();
break;
case LowerCase:
lowerCase();
break;
case SentenseCase:
sentenceCase();
break;
case ReverseCase:
reverseCase();
break;
}
#endif
}
#if 0
void ZoomTextPluginEditorInterface::slotReverseCase()
{
mType = ReverseCase;
Q_EMIT emitPluginActivated(this);
}
#endif
/*
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, version 2, as
published by the Free Software Foundation.
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; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ZOOMTEXTPLUGINEDITORINTERFACE_H
#define ZOOMTEXTPLUGINEDITORINTERFACE_H
#include <messagecomposer/plugineditorinterface.h>
#include <QPointer>
class ZoomTextPluginEditorInterface : public MessageComposer::PluginEditorInterface
{
Q_OBJECT
public:
explicit ZoomTextPluginEditorInterface(QObject *parent = Q_NULLPTR);
~ZoomTextPluginEditorInterface();
void createAction(KActionCollection *ac) Q_DECL_OVERRIDE;
void exec() Q_DECL_OVERRIDE;
bool hasPopupMenuSupport() const Q_DECL_OVERRIDE;
private:
enum ZoomTextType {
Unknown = -1,
Reset = 0,
ZoomIn,
ZoomOut
};
ZoomTextType mType;
};
#endif
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