Commit 4ae4d6a4 authored by Laurent Montel's avatar Laurent Montel 😁

Fix Bug 362100 - No mail headers if kdepim-addons is not installed

parent c2765de0
......@@ -6,7 +6,6 @@ add_subdirectory(enterpriseheaderstyleplugin)
add_subdirectory(fancyheaderstyleplugin)
add_subdirectory(grantleeheaderstyleplugin)
add_subdirectory(longheaderstyleplugin)
add_subdirectory(standardsheaderstyleplugin)
add_subdirectory(defaultgrantleeheaderstyleplugin)
if(BUILD_TESTING)
add_subdirectory(autotests)
......
......@@ -34,6 +34,4 @@ add_messageviewer_header_unittest( grantleeheaderstyleplugintest.cpp "../grantle
add_messageviewer_header_unittest( longheaderstyleplugintest.cpp "../longheaderstyleplugin/longheaderstyleplugin.cpp;../longheaderstyleplugin/longheaderstyleinterface.cpp")
add_messageviewer_header_unittest( standardsheaderstyleplugintest.cpp "../standardsheaderstyleplugin/standardheaderstrategy.cpp;../standardsheaderstyleplugin/standardsheaderstyleplugin.cpp;../standardsheaderstyleplugin/standardsheaderstyleinterface.cpp")
add_messageviewer_header_class_unittest( headerstylepluginmanagertest.cpp)
/*
Copyright (c) 2015-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 "standardsheaderstyleplugintest.h"
#include "../standardsheaderstyleplugin/standardsheaderstyleplugin.h"
#include "../standardsheaderstyleplugin/standardsheaderstyleinterface.h"
#include <QTest>
#include <KActionCollection>
#include <KActionMenu>
#include <QActionGroup>
StandardsHeaderStylePluginTest::StandardsHeaderStylePluginTest(QObject *parent)
: QObject(parent)
{
}
StandardsHeaderStylePluginTest::~StandardsHeaderStylePluginTest()
{
}
void StandardsHeaderStylePluginTest::shouldHaveDefaultValue()
{
MessageViewer::StandardsHeaderStylePlugin plugin;
QVERIFY(plugin.headerStyle());
QVERIFY(plugin.headerStrategy());
}
void StandardsHeaderStylePluginTest::shouldCreateInterface()
{
MessageViewer::StandardsHeaderStylePlugin 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(StandardsHeaderStylePluginTest)
/*
Copyright (c) 2015-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 STANDARDSHEADERSTYLEPLUGINTEST_H
#define STANDARDSHEADERSTYLEPLUGINTEST_H
#include <QObject>
class StandardsHeaderStylePluginTest : public QObject
{
Q_OBJECT
public:
explicit StandardsHeaderStylePluginTest(QObject *parent = Q_NULLPTR);
~StandardsHeaderStylePluginTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldCreateInterface();
};
#endif // STANDARDSHEADERSTYLEPLUGINTEST_H
set(messageviewer_standardsheaderstyleplugin_SRCS
standardsheaderstyleplugin.cpp
standardsheaderstyleinterface.cpp
standardheaderstrategy.cpp
)
add_library(messageviewer_standardsheaderstyleplugin MODULE ${messageviewer_standardsheaderstyleplugin_SRCS})
target_link_libraries(messageviewer_standardsheaderstyleplugin
KF5::MessageViewer
KF5::XmlGui
KF5::GrantleeTheme
KF5::I18n
)
install(TARGETS messageviewer_standardsheaderstyleplugin DESTINATION ${PLUGIN_INSTALL_DIR}/messageviewer)
{
"KPlugin": {
"Name": "Standards Header Style",
"Name[ca@valencia]": "Estil de capçalera estàndard",
"Name[ca]": "Estil de capçalera estàndard",
"Name[de]": "Vorspann-Design „Standard“",
"Name[es]": "Estilo de encabezado estándar",
"Name[fi]": "Vakio-otsaketyyli",
"Name[gl]": "Estilo de cabeceira estándar",
"Name[it]": "Stile con intestazioni standard",
"Name[nl]": "Stijl met standaard headers",
"Name[pl]": "Standardowe nagłówki",
"Name[pt]": "Estilo de Cabeçalho-Padrão",
"Name[pt_BR]": "Estilo de cabeçalho Padrão",
"Name[ru]": "Стандартный стиль заголовков",
"Name[sk]": "Štandardný štýl hlavičiek",
"Name[sl]": "Slog z običajnimi glavami",
"Name[sr@ijekavian]": "стандардни стил заглавља",
"Name[sr@ijekavianlatin]": "standardni stil zaglavlja",
"Name[sr@latin]": "standardni stil zaglavlja",
"Name[sr]": "стандардни стил заглавља",
"Name[sv]": "Vanlig rubrikstil",
"Name[uk]": "Стандартний стиль заголовків",
"Name[x-test]": "xxStandards Header Stylexx",
"Name[zh_CN]": "标准信头风格",
"ServiceTypes": [
"MessageViewerHeaderStyle/Plugin"
],
"Version": "1.0"
},
"X-KDE-MessageViewer-Header-Order": "4"
}
\ No newline at end of file
/*
Copyright (c) 2015-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 "standardheaderstrategy.h"
using namespace MessageViewer;
static const char *const standardHeaders[] = {
"subject", "from", "cc", "bcc", "to"
};
static const int numStandardHeaders = sizeof standardHeaders / sizeof * standardHeaders;
StandardHeaderStrategy::StandardHeaderStrategy()
: HeaderStrategy(),
mHeadersToDisplay(stringList(standardHeaders, numStandardHeaders))
{
}
StandardHeaderStrategy::~StandardHeaderStrategy()
{
}
/*
Copyright (c) 2015-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 STANDARDHEADERSTRATEGY_H
#define STANDARDHEADERSTRATEGY_H
#include <messageviewer/headerstrategy.h>
#include <QStringList>
namespace MessageViewer
{
//
// StandardHeaderStrategy:
// BCC, CC, Date, From, Subject, To
//
class StandardHeaderStrategy : public HeaderStrategy
{
public:
StandardHeaderStrategy();
~StandardHeaderStrategy();
public:
const char *name() const Q_DECL_OVERRIDE
{
return "standard";
}
QStringList headersToDisplay() const Q_DECL_OVERRIDE
{
return mHeadersToDisplay;
}
DefaultPolicy defaultPolicy() const Q_DECL_OVERRIDE
{
return Hide;
}
private:
const QStringList mHeadersToDisplay;
};
}
#endif // STANDARDHEADERSTRATEGY_H
/*
Copyright (c) 2015-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 "standardsheaderstyleinterface.h"
#include <KToggleAction>
#include <KLocalizedString>
#include <KActionCollection>
using namespace MessageViewer;
StandardsHeaderStyleInterface::StandardsHeaderStyleInterface(MessageViewer::HeaderStylePlugin *plugin, QObject *parent)
: MessageViewer::HeaderStyleInterface(plugin, parent)
{
}
StandardsHeaderStyleInterface::~StandardsHeaderStyleInterface()
{
}
void StandardsHeaderStyleInterface::createAction(KActionMenu *menu, QActionGroup *actionGroup, KActionCollection *ac)
{
KToggleAction *act = new KToggleAction(i18nc("View->headers->", "&Standard Headers"), this);
ac->addAction(QStringLiteral("view_headers_standard"), act);
connect(act, &KToggleAction::triggered, this, &StandardsHeaderStyleInterface::slotStyleChanged);
addHelpTextAction(act, i18n("Show standard list of message headers"));
mAction.append(act);
addActionToMenu(menu, actionGroup);
}
void StandardsHeaderStyleInterface::activateAction()
{
mAction.at(0)->setChecked(true);
}
/*
Copyright (c) 2015-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 STANDARDSHEADERSTYLEINTERFACE_H
#define STANDARDSHEADERSTYLEINTERFACE_H
#include <messageviewer/headerstyleinterface.h>
namespace MessageViewer
{
class StandardsHeaderStyleInterface : public MessageViewer::HeaderStyleInterface
{
Q_OBJECT
public:
explicit StandardsHeaderStyleInterface(HeaderStylePlugin *plugin, QObject *parent = Q_NULLPTR);
~StandardsHeaderStyleInterface();
void createAction(KActionMenu *menu, QActionGroup *actionGroup, KActionCollection *ac) Q_DECL_OVERRIDE;
void activateAction() Q_DECL_OVERRIDE;
};
}
#endif // STANDARDSHEADERSTYLEINTERFACE_H
/*
Copyright (c) 2015-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 "standardsheaderstyleplugin.h"
#include "standardsheaderstyleinterface.h"
#include "standardheaderstrategy.h"
#include "messageviewer/plainheaderstyle.h"
#include <kpluginfactory.h>
using namespace MessageViewer;
K_PLUGIN_FACTORY_WITH_JSON(MessageViewerStandardsHeaderStylePluginFactory, "messageviewer_standardsheaderstyleplugin.json", registerPlugin<StandardsHeaderStylePlugin>();)
StandardsHeaderStylePlugin::StandardsHeaderStylePlugin(QObject *parent, const QList<QVariant> &)
: MessageViewer::HeaderStylePlugin(parent),
mHeaderStyle(new PlainHeaderStyle),
mHeaderStrategy(new StandardHeaderStrategy)
{
}
StandardsHeaderStylePlugin::~StandardsHeaderStylePlugin()
{
}
HeaderStyle *StandardsHeaderStylePlugin::headerStyle() const
{
return mHeaderStyle;
}
HeaderStrategy *StandardsHeaderStylePlugin::headerStrategy() const
{
return mHeaderStrategy;
}
HeaderStyleInterface *StandardsHeaderStylePlugin::createView(KActionMenu *menu, QActionGroup *actionGroup, KActionCollection *ac, QObject *parent)
{
MessageViewer::HeaderStyleInterface *view = new MessageViewer::StandardsHeaderStyleInterface(this, parent);
if (ac) {
view->createAction(menu, actionGroup, ac);
}
return view;
}
QString StandardsHeaderStylePlugin::name() const
{
return QStringLiteral("standards-header");
}
#include "standardsheaderstyleplugin.moc"
/*
Copyright (c) 2015-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 STANDARDSHEADERSTYLEPLUGIN_H
#define STANDARDSHEADERSTYLEPLUGIN_H
#include "messageviewer/headerstyleplugin.h"
#include <QVariant>
namespace MessageViewer
{
class StandardsHeaderStylePlugin : public MessageViewer::HeaderStylePlugin
{
Q_OBJECT
public:
explicit StandardsHeaderStylePlugin(QObject *parent = Q_NULLPTR, const QList<QVariant> & = QList<QVariant>());
~StandardsHeaderStylePlugin();
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 // STANDARDSHEADERSTYLEPLUGIN_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