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

Move plugin here

parent 0f5d36ba
add_subdirectory(allheaderstyleplugin)
add_subdirectory(briefheaderstyleplugin)
add_subdirectory(customheaderstyleplugin)
add_subdirectory(enterpriseheaderstyleplugin)
add_subdirectory(fancyheaderstyleplugin)
add_subdirectory(grantleeheaderstyleplugin)
add_subdirectory(longheaderstyleplugin)
add_subdirectory(standardsheaderstyleplugin)
if(BUILD_TESTING)
add_subdirectory(autotests)
add_subdirectory(tests)
endif()
\ No newline at end of file
set(messageviewer_allheaderstyleplugin_SRCS
allheaderstyleplugin.cpp
allheaderstyleinterface.cpp
allheaderstrategy.cpp
)
add_library(messageviewer_allheaderstyleplugin MODULE ${messageviewer_allheaderstyleplugin_SRCS})
target_link_libraries(messageviewer_allheaderstyleplugin
KF5::MessageViewer
KF5::XmlGui
KF5::GrantleeTheme
)
install(TARGETS messageviewer_allheaderstyleplugin DESTINATION ${PLUGIN_INSTALL_DIR}/messageviewer)
kcoreaddons_desktop_to_json(messageviewer_allheaderstyleplugin messageviewer_allheaderstyleplugin.desktop)
/*
Copyright (c) 2015 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 "allheaderstrategy.h"
using namespace MessageViewer;
AllHeaderStrategy::AllHeaderStrategy()
: HeaderStrategy()
{
}
AllHeaderStrategy::~AllHeaderStrategy()
{
}
/*
Copyright (c) 2015 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 ALLHEADERSTRATEGY_H
#define ALLHEADERSTRATEGY_H
#include <messageviewer/headerstrategy.h>
#include <QStringList>
namespace MessageViewer
{
class AllHeaderStrategy : public HeaderStrategy
{
public:
AllHeaderStrategy();
~AllHeaderStrategy();
const char *name() const Q_DECL_OVERRIDE
{
return "all";
}
DefaultPolicy defaultPolicy() const Q_DECL_OVERRIDE
{
return Display;
}
bool showHeader(const QString &) const Q_DECL_OVERRIDE
{
return true; // more efficient than default impl
}
};
}
#endif // ALLHEADERSTRATEGY_H
/*
Copyright (c) 2015 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 "allheaderstyleinterface.h"
#include <KToggleAction>
#include <KLocalizedString>
#include <KActionCollection>
using namespace MessageViewer;
AllHeaderStyleInterface::AllHeaderStyleInterface(MessageViewer::HeaderStylePlugin *plugin, QObject *parent)
: MessageViewer::HeaderStyleInterface(plugin, parent)
{
}
AllHeaderStyleInterface::~AllHeaderStyleInterface()
{
}
void AllHeaderStyleInterface::createAction(KActionMenu *menu, QActionGroup *actionGroup, KActionCollection *ac)
{
KToggleAction *act = new KToggleAction(i18nc("View->headers->", "&All Headers"), this);
ac->addAction(QStringLiteral("view_headers_all"), act);
connect(act, &KToggleAction::triggered, this, &AllHeaderStyleInterface::slotStyleChanged);
addHelpTextAction(act, i18n("Show all message headers"));
mAction.append(act);
addActionToMenu(menu, actionGroup);
}
void AllHeaderStyleInterface::activateAction()
{
mAction.at(0)->setChecked(true);
}
/*
Copyright (c) 2015 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 ALLHEADERSTYLEINTERFACE_H
#define ALLHEADERSTYLEINTERFACE_H
#include <messageviewer/headerstyleinterface.h>
namespace MessageViewer
{
class AllHeaderStyleInterface : public MessageViewer::HeaderStyleInterface
{
Q_OBJECT
public:
explicit AllHeaderStyleInterface(MessageViewer::HeaderStylePlugin *plugin, QObject *parent = Q_NULLPTR);
~AllHeaderStyleInterface();
void createAction(KActionMenu *menu, QActionGroup *actionGroup, KActionCollection *ac) Q_DECL_OVERRIDE;
void activateAction() Q_DECL_OVERRIDE;
};
}
#endif // ALLHEADERSTYLEINTERFACE_H
/*
Copyright (c) 2015 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 "allheaderstyleplugin.h"
#include "messageviewer/plainheaderstyle.h"
#include "allheaderstyleinterface.h"
#include "allheaderstrategy.h"
#include <kpluginfactory.h>
using namespace MessageViewer;
K_PLUGIN_FACTORY_WITH_JSON(MessageViewerAllHeaderStylePluginFactory, "messageviewer_allheaderstyleplugin.json", registerPlugin<AllHeaderStylePlugin>();)
AllHeaderStylePlugin::AllHeaderStylePlugin(QObject *parent, const QList<QVariant> &)
: MessageViewer::HeaderStylePlugin(parent),
mHeaderStyle(new PlainHeaderStyle),
mHeaderStrategy(new AllHeaderStrategy)
{
}
AllHeaderStylePlugin::~AllHeaderStylePlugin()
{
}
HeaderStyle *AllHeaderStylePlugin::headerStyle() const
{
return mHeaderStyle;
}
HeaderStrategy *AllHeaderStylePlugin::headerStrategy() const
{
return mHeaderStrategy;
}
HeaderStyleInterface *AllHeaderStylePlugin::createView(KActionMenu *menu, QActionGroup *actionGroup, KActionCollection *ac, QObject *parent)
{
MessageViewer::AllHeaderStyleInterface *view = new MessageViewer::AllHeaderStyleInterface(this, parent);
if (ac) {
view->createAction(menu, actionGroup, ac);
}
return view;
}
QString MessageViewer::AllHeaderStylePlugin::name() const
{
return QStringLiteral("all-headers");
}
#include "allheaderstyleplugin.moc"
/*
Copyright (c) 2015 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 ALLHEADERSTYLEPLUGIN_H
#define ALLHEADERSTYLEPLUGIN_H
#include "messageviewer/headerstyleplugin.h"
#include <QVariant>
namespace MessageViewer
{
class AllHeaderStylePlugin : public MessageViewer::HeaderStylePlugin
{
Q_OBJECT
public:
explicit AllHeaderStylePlugin(QObject *parent = Q_NULLPTR, const QList<QVariant> & = QList<QVariant>());
~AllHeaderStylePlugin();
HeaderStyle *headerStyle() const Q_DECL_OVERRIDE;
HeaderStrategy *headerStrategy() const Q_DECL_OVERRIDE;
HeaderStyleInterface *createView(KActionMenu *menu, QActionGroup *actionGroup, KActionCollection *ac, QObject *parent = Q_NULLPTR) Q_DECL_OVERRIDE;
QString name() const Q_DECL_OVERRIDE;
private:
HeaderStyle *mHeaderStyle;
HeaderStrategy *mHeaderStrategy;
};
}
#endif // ALLHEADERSTYLEPLUGIN_H
[Desktop Entry]
Type=Service
ServiceTypes=MessageViewerHeaderStyle/Plugin
X-KDE-Library=messageviewer_allheaderstyleplugin
Name=All Header Style
Name[ca]=Tots els estils de capçalera
Name[ca@valencia]=Tots els estils de capçalera
Name[en_GB]=All Header Style
Name[es]=Todos los estilos de encabezado
Name[fi]=Kaikki otsakkeet -tyyli
Name[gl]=Estilo de cabeceira completa
Name[it]=Stile con tutte le intestazioni
Name[nl]=Stijl met alle headers
Name[pl]=Pełne nagłówki
Name[pt]=Estilo com Todos os Cabeçalhos
Name[pt_BR]=Estilo com todos os cabeçalhos
Name[sk]=Všetky štýly hlavičiek
Name[sl]=Slog z vsemi glavami
Name[sr]=потпуни стил заглавља
Name[sr@ijekavian]=потпуни стил заглавља
Name[sr@ijekavianlatin]=potpuni stil zaglavlja
Name[sr@latin]=potpuni stil zaglavlja
Name[sv]=Stil med alla rubriker
Name[tr]=Tüm Başlık Biçemi
Name[uk]=Стиль усіх заголовків
Name[x-test]=xxAll Header Stylexx
X-KDE-MessageViewer-Header-Order=6
# convenience macro to add qtest unit tests
macro(add_messageviewer_header_unittest _source _additional _jsonfile)
set( _test ${_source} ${_additional})
get_filename_component(_name ${_source} NAME_WE)
add_executable( ${_name} ${_test} )
kcoreaddons_desktop_to_json(${_name} ${_jsonfile})
add_test( ${_name} ${_name} )
ecm_mark_as_test(messageviewer-header-${_name})
target_link_libraries( ${_name} KF5::MessageViewer KF5::Libkleo KF5::QGpgme Qt5::Test Qt5::WebKitWidgets KF5::KIOCore KF5::Mime KF5::AkonadiCore KF5::AkonadiNotes KF5::CalendarCore KF5::GrantleeTheme)
endmacro ()
macro(add_messageviewer_header_class_unittest _source )
set( _test ${_source})
get_filename_component(_name ${_source} NAME_WE)
add_executable( ${_name} ${_test} )
add_test( ${_name} ${_name} )
ecm_mark_as_test(messageviewer-header-${_name})
target_link_libraries( ${_name} KF5::MessageViewer KF5::Libkleo KF5::QGpgme Qt5::Test Qt5::WebKitWidgets KF5::KIOCore KF5::Mime KF5::AkonadiCore KF5::AkonadiNotes KF5::CalendarCore KF5::GrantleeTheme)
endmacro ()
add_messageviewer_header_unittest( briefheaderstyleplugintest.cpp "../briefheaderstyleplugin/briefheaderstrategy.cpp;../briefheaderstyleplugin/briefheaderstyle.cpp;../briefheaderstyleplugin/briefheaderstyleplugin.cpp;../briefheaderstyleplugin/briefheaderstyleinterface.cpp" "../briefheaderstyleplugin/messageviewer_briefheaderstyleplugin.desktop")
add_messageviewer_header_unittest( allheaderstyleplugintest.cpp "../allheaderstyleplugin/allheaderstrategy.cpp;../allheaderstyleplugin/allheaderstyleplugin.cpp;../allheaderstyleplugin/allheaderstyleinterface.cpp" "../allheaderstyleplugin/messageviewer_allheaderstyleplugin.desktop")
add_messageviewer_header_unittest( customheaderstyleplugintest.cpp "../customheaderstyleplugin/customheaderstrategy.cpp;../customheaderstyleplugin/customheaderstyle.cpp;../customheaderstyleplugin/customheaderstyleplugin.cpp;../customheaderstyleplugin/customheaderstyleinterface.cpp" "../customheaderstyleplugin/messageviewer_customheaderstyleplugin.desktop")
add_messageviewer_header_unittest( enterpriseheaderstyleplugintest.cpp "../enterpriseheaderstyleplugin/enterpriseheaderstyle.cpp;../enterpriseheaderstyleplugin/enterpriseheaderstyleplugin.cpp;../enterpriseheaderstyleplugin/enterpriseheaderstyleinterface.cpp" "../enterpriseheaderstyleplugin/messageviewer_enterpriseheaderstyleplugin.desktop")
add_messageviewer_header_unittest( fancyheaderstyleplugintest.cpp "../fancyheaderstyleplugin/fancyheaderstyle.cpp;../fancyheaderstyleplugin/fancyheaderstyleplugin.cpp;../fancyheaderstyleplugin/fancyheaderstyleinterface.cpp" "../fancyheaderstyleplugin/messageviewer_fancyheaderstyleplugin.desktop")
add_messageviewer_header_unittest( grantleeheaderstyleplugintest.cpp "../grantleeheaderstyleplugin/grantleeheaderstrategy.cpp;../grantleeheaderstyleplugin/grantleeheaderstyleplugin.cpp;../grantleeheaderstyleplugin/grantleeheaderstyleinterface.cpp" "../grantleeheaderstyleplugin/messageviewer_grantleeheaderstyleplugin.desktop")
add_messageviewer_header_unittest( longheaderstyleplugintest.cpp "../longheaderstyleplugin/longheaderstyleplugin.cpp;../longheaderstyleplugin/longheaderstyleinterface.cpp" "../longheaderstyleplugin/messageviewer_longheaderstyleplugin.desktop")
add_messageviewer_header_unittest( standardsheaderstyleplugintest.cpp "../standardsheaderstyleplugin/standardheaderstrategy.cpp;../standardsheaderstyleplugin/standardsheaderstyleplugin.cpp;../standardsheaderstyleplugin/standardsheaderstyleinterface.cpp" "../standardsheaderstyleplugin/messageviewer_standardsheaderstyleplugin.desktop")
add_messageviewer_header_class_unittest( headerstylepluginmanagertest.cpp)
/*
Copyright (c) 2015 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 "allheaderstyleplugintest.h"
#include "../allheaderstyleplugin/allheaderstyleplugin.h"
#include "../allheaderstyleplugin/allheaderstyleinterface.h"
#include <QTest>
#include <KActionCollection>
#include <KActionMenu>
#include <QActionGroup>
AllHeaderStylePluginTest::AllHeaderStylePluginTest(QObject *parent)
: QObject(parent)
{
}
AllHeaderStylePluginTest::~AllHeaderStylePluginTest()
{
}
void AllHeaderStylePluginTest::shouldHaveDefaultValue()
{
MessageViewer::AllHeaderStylePlugin plugin;
QVERIFY(plugin.headerStyle());
QVERIFY(plugin.headerStrategy());
}
void AllHeaderStylePluginTest::shouldCreateInterface()
{
MessageViewer::AllHeaderStylePlugin plugin;
KActionMenu *menu = new KActionMenu(this);
QActionGroup *act = new QActionGroup(this);
MessageViewer::HeaderStyleInterface *interface = plugin.createView(menu, act, new KActionCollection(this));
QVERIFY(interface);
QVERIFY(!interface->action().isEmpty());
}
QTEST_MAIN(AllHeaderStylePluginTest)
/*
Copyright (c) 2015 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 ALLHEADERSTYLEPLUGINTEST_H
#define ALLHEADERSTYLEPLUGINTEST_H
#include <QObject>
class AllHeaderStylePluginTest : public QObject
{
Q_OBJECT
public:
explicit AllHeaderStylePluginTest(QObject *parent = Q_NULLPTR);
~AllHeaderStylePluginTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldCreateInterface();
};
#endif // ALLHEADERSTYLEPLUGINTEST_H
/*
Copyright (c) 2015 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 "briefheaderstyleplugintest.h"
#include "../briefheaderstyleplugin/briefheaderstyleplugin.h"
#include "../briefheaderstyleplugin/briefheaderstyleinterface.h"
#include <QTest>
#include <KActionCollection>
#include <KActionMenu>
#include <QActionGroup>
BriefHeaderStylePluginTest::BriefHeaderStylePluginTest(QObject *parent)
: QObject(parent)
{
}
BriefHeaderStylePluginTest::~BriefHeaderStylePluginTest()
{
}
void BriefHeaderStylePluginTest::shouldHaveDefaultValue()
{
MessageViewer::BriefHeaderStylePlugin plugin;
QVERIFY(plugin.headerStyle());
QVERIFY(plugin.headerStrategy());
}
void BriefHeaderStylePluginTest::shouldCreateInterface()
{
MessageViewer::BriefHeaderStylePlugin plugin;
KActionMenu *menu = new KActionMenu(this);
QActionGroup *act = new QActionGroup(this);
MessageViewer::HeaderStyleInterface *interface = plugin.createView(menu, act, new KActionCollection(this));
QVERIFY(interface);
QVERIFY(!interface->action().isEmpty());
}
QTEST_MAIN(BriefHeaderStylePluginTest)
/*
Copyright (c) 2015 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 BRIEFHEADERSTYLEPLUGINTEST_H
#define BRIEFHEADERSTYLEPLUGINTEST_H
#include <QObject>
class BriefHeaderStylePluginTest : public QObject
{
Q_OBJECT
public:
explicit BriefHeaderStylePluginTest(QObject *parent = Q_NULLPTR);
~BriefHeaderStylePluginTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldCreateInterface();
};
#endif // BRIEFHEADERSTYLEPLUGINTEST_H
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>