Commit e7cf495f authored by Laurent Montel's avatar Laurent Montel 😁

We can remove it now

parent 183d4378
set(kmail_rot13editorplugin_SRCS
rot13plugineditor.cpp
rot13plugineditorinterface.cpp
rot13job.cpp
)
kcoreaddons_add_plugin(kmail_rot13editorplugin JSON kmail_rot13editorplugin.json SOURCES
${kmail_rot13editorplugin_SRCS} INSTALL_NAMESPACE kmail)
target_link_libraries(kmail_rot13editorplugin
KF5::IconThemes KF5::MessageComposer KF5::XmlGui KF5::I18n
)
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} COMMAND ${_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(rot13plugineditortest.cpp "../rot13plugineditor.cpp;../rot13plugineditorinterface.cpp;../rot13job.cpp")
add_kmail_editorplugin_unittest(rot13plugineditorinterfacetest.cpp "../rot13plugineditorinterface.cpp;../rot13job.cpp")
/*
Copyright (c) 2015-2017 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 "rot13plugineditorinterfacetest.h"
#include "../rot13plugineditorinterface.h"
#include <QTest>
Rot13PluginEditorInterfaceTest::Rot13PluginEditorInterfaceTest(QObject *parent)
: QObject(parent)
{
}
Rot13PluginEditorInterfaceTest::~Rot13PluginEditorInterfaceTest()
{
}
QTEST_MAIN(Rot13PluginEditorInterfaceTest)
/*
Copyright (c) 2015-2017 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 ROT13PLUGINEDITORINTERFACETEST_H
#define ROT13PLUGINEDITORINTERFACETEST_H
#include <QObject>
class Rot13PluginEditorInterfaceTest : public QObject
{
Q_OBJECT
public:
explicit Rot13PluginEditorInterfaceTest(QObject *parent = nullptr);
~Rot13PluginEditorInterfaceTest();
};
#endif // ROT13PLUGINEDITORINTERFACETEST_H
/*
Copyright (c) 2015-2017 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 "rot13plugineditortest.h"
#include "../rot13plugineditor.h"
#include <KActionCollection>
#include <QTest>
Rot13PluginEditorTest::Rot13PluginEditorTest(QObject *parent)
: QObject(parent)
{
}
Rot13PluginEditorTest::~Rot13PluginEditorTest()
{
}
void Rot13PluginEditorTest::shouldHaveDefaultValue()
{
Rot13PluginEditor plugin;
QVERIFY(plugin.createInterface(new KActionCollection(this)));
}
QTEST_MAIN(Rot13PluginEditorTest)
/*
Copyright (c) 2015-2017 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 ROT13PLUGINEDITORTEST_H
#define ROT13PLUGINEDITORTEST_H
#include <QObject>
class Rot13PluginEditorTest : public QObject
{
Q_OBJECT
public:
explicit Rot13PluginEditorTest(QObject *parent = nullptr);
~Rot13PluginEditorTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // ROT13PLUGINEDITORTEST_H
{
"KPlugin": {
"Description": "ROT13 (rotate by 13 places) is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet",
"Description[ca@valencia]": "ROT13 (gira per 13 llocs) és un xifrat de substitució per a lletres senzill que substitueix a una lletra amb la lletra 13 lletres després en l'alfabet",
"Description[ca]": "ROT13 (gira per 13 llocs) és un xifrat de substitució per a lletres senzill que substitueix a una lletra amb la lletra 13 lletres després en l'alfabet",
"Description[es]": "ROT13 (rotar 13 lugares) es un cifrado sencillo de sustitución de letras que remplaza una letra con la que está trece lugares después en el alfabeto",
"Description[et]": "ROT13 (rpteerimine 13 koha võrra) on väga lihtne tähtede asendamsie šiffer, mis asendab tähe teise tähega, mis asub esimesest 13 tähte tähestikus tagapool.",
"Description[fi]": "ROT13 (siirrä 13 askelta) on yksinkertainen korvaussalaus, joka korvaa kunkin kirjaimen 13 kirjainta sen jälkeen aakkosissa olevalla kirjaimella",
"Description[fr]": "ROT13 (rotation de 13 positions) est un codage de simple substitution de lettre qui remplace une lettre par la lettre 13 positions après elle dans l'alphabet",
"Description[it]": "ROT13 (ruota di 13 posizioni) è un semplice cifrario a sostituzione per lettere che sostituisce una lettera con quella che la segue 13 posizioni dopo nell'alfabeto",
"Description[ko]": "ROT13(13글자 회전)은 현재 글자를 알파벳의 13번째 이후 글자로 치환시키는 간단한 치환 암호입니다",
"Description[nl]": "ROT13 (roteer 13 plaatsen) is een eenvoudige lettersubstitutie vercijfering die een letter vervangt door de letter 13 letters erna in het alfabet",
"Description[pl]": "ROT13 (obróć o 13 miejsc) jest prostym szyfrem podmiany liter, króty podmienia literę, literą przesuniętą o 13 liter w alfabecie",
"Description[pt]": "ROT13 (rodar em 13 posições) é uma cifra de substituição de letra simples que substitui uma letra pela letra 13 posições à frente no alfabeto",
"Description[ru]": "ROT13 (смещение на 13 позиций) — это простой способ шифрования текста, основанный на замене буквы на другую, находящуюся в алфавите на 13 букв после неё.",
"Description[sk]": "ROT13 (rotácia o 13 miest) je jednoduchá šifra náhradou písmen, ktorá nahradí písmeno písmenom o 13 znakov ďalej v abecede.",
"Description[sl]": "ROT13 (zavrti za 13 mest) je preprosta zamenjalna šifra, ki zamenja vsako črko s črko, ki se v abecedi nahaja trinajst mest za njo",
"Description[sr@ijekavian]": "Рот‑13 (ротација за 13 места) је једноставни шифрар сменом слова где се свако слово мења словом 13 места удаљеним у енглеском алфабету",
"Description[sr@ijekavianlatin]": "Rot‑13 (rotacija za 13 mesta) je jednostavni šifrar smenom slova gde se svako slovo menja slovom 13 mesta udaljenim u engleskom alfabetu",
"Description[sr@latin]": "Rot‑13 (rotacija za 13 mesta) je jednostavni šifrar smenom slova gde se svako slovo menja slovom 13 mesta udaljenim u engleskom alfabetu",
"Description[sr]": "Рот‑13 (ротација за 13 места) је једноставни шифрар сменом слова где се свако слово мења словом 13 места удаљеним у енглеском алфабету",
"Description[sv]": "ROT13 (rotera 13 steg) är ett enkelt bokstavsersättningskrypto som ersätter en bokstav med den bokstav som är 13 bokstäver senare i alfabetet",
"Description[tr]": "ROT13 (13 sıra döndür), bir harfi alfabedeki 13 harf sonrakiyle değiştiren basit bir harf değiştirme şifrelemesidir.",
"Description[uk]": "ROT13 (обертання на 13 позицій) — просте шифрування заміною літер із циклічним зсувом на 13 позицій за абеткою",
"Description[x-test]": "xxROT13 (rotate by 13 places) is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabetxx",
"Description[zh_CN]": "ROT13 (旋转 13 位) 是一个简单的字母替换表,它将字母替换成字母表中往后数第 13 字母。",
"EnabledByDefault": "false",
"Id": "rot13",
"Name": "ROT13",
"Name[sr@ijekavian]": "Рот‑13",
"Name[sr@ijekavianlatin]": "Rot‑13",
"Name[sr@latin]": "Rot‑13",
"Name[sr]": "Рот‑13",
"Name[x-test]": "xxROT13xx",
"ServiceTypes": [
"KMailEditor/Plugin"
],
"Version": "1.0"
},
"X-KDE-KMailEditor-Order": "1"
}
/*
Copyright (c) 2015-2017 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 "rot13job.h"
Rot13Job::Rot13Job(QObject *parent)
: QObject(parent)
{
}
Rot13Job::~Rot13Job()
{
}
void Rot13Job::setText(const QString &text)
{
mInitialText = text;
}
QString Rot13Job::rot13() const
{
if (mInitialText.isEmpty()) {
return {};
}
QString r(mInitialText);
const int rLenght(r.length());
for (int i = 0; i < rLenght; ++i) {
const QChar rChar(r.at(i));
if ((rChar >= QLatin1Char('A') && rChar <= QLatin1Char('M'))
|| (rChar >= QLatin1Char('a') && rChar <= QLatin1Char('m'))) {
r[i] = (char)((int)QChar(r[i]).toLatin1() + 13);
} else {
if ((rChar >= QLatin1Char('N') && rChar <= QLatin1Char('Z'))
|| (rChar >= QLatin1Char('n') && rChar <= QLatin1Char('z'))) {
r[i] = (char)((int)QChar(r[i]).toLatin1() - 13);
}
}
}
return r;
}
/*
Copyright (c) 2015-2017 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 ROT13JOB_H
#define ROT13JOB_H
#include <QObject>
class Rot13Job : public QObject
{
Q_OBJECT
public:
explicit Rot13Job(QObject *parent = nullptr);
~Rot13Job();
void setText(const QString &text);
QString rot13() const;
private:
QString mInitialText;
};
#endif // ROT13JOB_H
/*
Copyright (c) 2015-2017 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 "rot13plugineditor.h"
#include "rot13plugineditorinterface.h"
#include <kpluginfactory.h>
K_PLUGIN_FACTORY_WITH_JSON(Rot13PluginEditorFactory, "kmail_rot13editorplugin.json", registerPlugin<Rot13PluginEditor>();
)
Rot13PluginEditor::Rot13PluginEditor(QObject *parent, const QList<QVariant> &)
: MessageComposer::PluginEditor(parent)
{
}
Rot13PluginEditor::~Rot13PluginEditor()
{
}
MessageComposer::PluginEditorInterface *Rot13PluginEditor::createInterface(KActionCollection *ac, QObject *parent)
{
Rot13PluginEditorInterface *interface = new Rot13PluginEditorInterface(parent);
interface->createAction(ac);
return interface;
}
#include "rot13plugineditor.moc"
/*
Copyright (c) 2015-2017 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 ROT13PLUGINEDITOR_H
#define ROT13PLUGINEDITOR_H
#include <messagecomposer/plugineditor.h>
#include <messagecomposer/plugineditorinterface.h>
#include <QVariant>
class Rot13PluginEditor : public MessageComposer::PluginEditor
{
Q_OBJECT
public:
explicit Rot13PluginEditor(QObject *parent = nullptr, const QList<QVariant> & = QList<QVariant>());
~Rot13PluginEditor();
MessageComposer::PluginEditorInterface *createInterface(KActionCollection *ac, QObject *parent = nullptr) override;
};
#endif // ROT13PLUGINEDITOR_H
/*
Copyright (c) 2015-2017 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 "rot13plugineditorinterface.h"
#include "rot13job.h"
#include <KPIMTextEdit/RichTextEditor>
#include <KLocalizedString>
#include <KActionCollection>
#include <QAction>
Rot13PluginEditorInterface::Rot13PluginEditorInterface(QObject *parent)
: MessageComposer::PluginEditorInterface(parent)
{
}
Rot13PluginEditorInterface::~Rot13PluginEditorInterface()
{
}
void Rot13PluginEditorInterface::createAction(KActionCollection *ac)
{
QAction *action = new QAction(i18n("Rot13 converter"), this);
ac->addAction(QStringLiteral("rot13converter"), action);
connect(action, &QAction::triggered, this, &Rot13PluginEditorInterface::slotActivated);
MessageComposer::ActionType type(action, MessageComposer::ActionType::Tools);
setActionType(type);
}
void Rot13PluginEditorInterface::slotActivated()
{
Q_EMIT emitPluginActivated(this);
}
void Rot13PluginEditorInterface::exec()
{
const QString text = richTextEditor()->toPlainText();
if (!text.isEmpty()) {
Rot13Job job;
job.setText(text);
const QString convertedText = job.rot13();
richTextEditor()->setPlainText(convertedText);
}
}
/*
Copyright (c) 2015-2017 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 ROT13PLUGINEDITORINTERFACE_H
#define ROT13PLUGINEDITORINTERFACE_H
#include <messagecomposer/plugineditorinterface.h>
class Rot13PluginEditorInterface : public MessageComposer::PluginEditorInterface
{
Q_OBJECT
public:
explicit Rot13PluginEditorInterface(QObject *parent = nullptr);
~Rot13PluginEditorInterface();
void createAction(KActionCollection *ac) override;
void exec() override;
private Q_SLOTS:
void slotActivated();
};
#endif // ROT13PLUGINEDITORINTERFACE_H
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