Commit 944f64f6 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Create a plugin for default grantlee theme

parent 498cf190
......@@ -8,7 +8,7 @@ add_subdirectory(fancyheaderstyleplugin)
add_subdirectory(grantleeheaderstyleplugin)
add_subdirectory(longheaderstyleplugin)
add_subdirectory(standardsheaderstyleplugin)
add_subdirectory(defaultgrantleeheaderstyleplugin)
if(BUILD_TESTING)
add_subdirectory(autotests)
add_subdirectory(tests)
......
set(messageviewer_defaultgrantleeheaderstyleplugin_SRCS
defaultgrantleeheaderstyleplugin.cpp
defaultgrantleeheaderstyleinterface.cpp
defaultgrantleeheaderstrategy.cpp
)
kconfig_add_kcfg_files(messageviewer_defaultgrantleeheaderstyleplugin_SRCS
settings/globalsettings_base.kcfgc
)
add_library(messageviewer_defaultgrantleeheaderstyleplugin MODULE ${messageviewer_defaultgrantleeheaderstyleplugin_SRCS})
target_link_libraries(messageviewer_defaultgrantleeheaderstyleplugin
KF5::MessageViewer
KF5::GrantleeTheme
KF5::XmlGui
)
install(TARGETS messageviewer_defaultgrantleeheaderstyleplugin DESTINATION ${PLUGIN_INSTALL_DIR}/messageviewer)
/*
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 "defaultgrantleeheaderstrategy.h"
using namespace MessageViewer;
DefaultGrantleeHeaderStrategy::DefaultGrantleeHeaderStrategy()
{
}
DefaultGrantleeHeaderStrategy::~DefaultGrantleeHeaderStrategy()
{
}
/*
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 DEFAULTGRANTLEEHEADERSTRATEGY_H
#define DEFAULTGRANTLEEHEADERSTRATEGY_H
#include <messageviewer/headerstrategy.h>
#include <QStringList>
namespace MessageViewer
{
class DefaultGrantleeHeaderStrategy : public HeaderStrategy
{
public:
DefaultGrantleeHeaderStrategy();
~DefaultGrantleeHeaderStrategy();
public:
const char *name() const Q_DECL_OVERRIDE
{
return "defaultgrantlee";
}
DefaultPolicy defaultPolicy() const Q_DECL_OVERRIDE
{
return Hide;
}
};
}
#endif // DEFAULTGRANTLEEHEADERSTRATEGY_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 "defaultgrantleeheaderstyleinterface.h"
#include "messageviewer/headerstyleplugin.h"
#include "messageviewer/headerstyle.h"
#include <grantleetheme/grantleethememanager.h>
#include "globalsettings_base.h"
#include <KToggleAction>
using namespace MessageViewer;
DefaultGrantleeHeaderStyleInterface::DefaultGrantleeHeaderStyleInterface(MessageViewer::HeaderStylePlugin *plugin, QObject *parent)
: MessageViewer::HeaderStyleInterface(plugin, parent),
mThemeManager(Q_NULLPTR)
{
}
DefaultGrantleeHeaderStyleInterface::~DefaultGrantleeHeaderStyleInterface()
{
}
void DefaultGrantleeHeaderStyleInterface::createAction(KActionMenu *menu, QActionGroup *actionGroup, KActionCollection *ac)
{
mThemeManager = new GrantleeTheme::ThemeManager(QStringLiteral("mail"),
QStringLiteral("header.desktop"), ac,
QStringLiteral("messageviewer/themes/"));
mThemeManager->setDownloadNewStuffConfigFile(QStringLiteral("messageviewer_header_themes.knsrc"));
connect(mThemeManager, &GrantleeTheme::ThemeManager::grantleeThemeSelected, this, &DefaultGrantleeHeaderStyleInterface::slotDefaultGrantleeHeaders);
connect(mThemeManager, &GrantleeTheme::ThemeManager::updateThemes, this, &HeaderStyleInterface::styleUpdated);
mThemeManager->setActionGroup(actionGroup);
mThemeManager->setThemeMenu(menu);
const QString themeName = DefaultGrantleeHeaderStylePluginSettings::self()->themeName();
mHeaderStylePlugin->headerStyle()->setTheme(mThemeManager->theme(themeName));
addActionToMenu(menu, actionGroup);
}
void DefaultGrantleeHeaderStyleInterface::activateAction()
{
KToggleAction *act = mThemeManager->actionForTheme();
if (act) {
act->setChecked(true);
}
}
void DefaultGrantleeHeaderStyleInterface::slotDefaultGrantleeHeaders()
{
const QString themeName = mThemeManager->configuredThemeName();
mHeaderStylePlugin->headerStyle()->setTheme(mThemeManager->theme(themeName));
slotStyleChanged();
}
/*
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 DEFAULTGRANTLEEHEADERSTYLEINTERFACE_H
#define DEFAULTGRANTLEEHEADERSTYLEINTERFACE_H
#include <messageviewer/headerstyleinterface.h>
namespace GrantleeTheme
{
class ThemeManager;
}
namespace MessageViewer
{
class DefaultGrantleeHeaderStyleInterface : public MessageViewer::HeaderStyleInterface
{
Q_OBJECT
public:
explicit DefaultGrantleeHeaderStyleInterface(HeaderStylePlugin *plugin, QObject *parent = Q_NULLPTR);
~DefaultGrantleeHeaderStyleInterface();
void createAction(KActionMenu *menu, QActionGroup *actionGroup, KActionCollection *ac) Q_DECL_OVERRIDE;
void activateAction() Q_DECL_OVERRIDE;
private Q_SLOTS:
void slotDefaultGrantleeHeaders();
private:
GrantleeTheme::ThemeManager *mThemeManager;
};
}
#endif // DEFAULTGRANTLEEHEADERSTYLEINTERFACE_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 "defaultgrantleeheaderstyleinterface.h"
#include "defaultgrantleeheaderstyleplugin.h"
#include <messageviewer/grantleeheaderstyle.h>
#include "defaultgrantleeheaderstrategy.h"
#include <kpluginfactory.h>
using namespace MessageViewer;
K_PLUGIN_FACTORY_WITH_JSON(MessageViewerDefaultGrantleeHeaderStylePluginFactory, "messageviewer_defaultgrantleeheaderstyleplugin.json", registerPlugin<DefaultGrantleeHeaderStylePlugin>();)
DefaultGrantleeHeaderStylePlugin::DefaultGrantleeHeaderStylePlugin(QObject *parent, const QList<QVariant> &)
: MessageViewer::HeaderStylePlugin(parent),
mHeaderStyle(new GrantleeHeaderStyle),
mHeaderStrategy(new DefaultGrantleeHeaderStrategy)
{
}
DefaultGrantleeHeaderStylePlugin::~DefaultGrantleeHeaderStylePlugin()
{
}
HeaderStyle *DefaultGrantleeHeaderStylePlugin::headerStyle() const
{
return mHeaderStyle;
}
HeaderStrategy *DefaultGrantleeHeaderStylePlugin::headerStrategy() const
{
return mHeaderStrategy;
}
HeaderStyleInterface *DefaultGrantleeHeaderStylePlugin::createView(KActionMenu *menu, QActionGroup *actionGroup, KActionCollection *ac, QObject *parent)
{
MessageViewer::HeaderStyleInterface *view = new MessageViewer::DefaultGrantleeHeaderStyleInterface(this, parent);
if (ac) {
view->createAction(menu, actionGroup, ac);
}
return view;
}
QString DefaultGrantleeHeaderStylePlugin::name() const
{
return QStringLiteral("defaultgrantlee");
}
#include "defaultgrantleeheaderstyleplugin.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 DEFAULTGRANTLEEHEADERSTYLEPLUGIN_H
#define DEFAULTGRANTLEEHEADERSTYLEPLUGIN_H
#include "messageviewer/headerstyleplugin.h"
#include <QVariant>
namespace MessageViewer
{
class DefaultGrantleeHeaderStylePlugin : public MessageViewer::HeaderStylePlugin
{
Q_OBJECT
public:
explicit DefaultGrantleeHeaderStylePlugin(QObject *parent = Q_NULLPTR, const QList<QVariant> & = QList<QVariant>());
~DefaultGrantleeHeaderStylePlugin();
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 // DEFAULTGRANTLEEHEADERSTYLEPLUGIN_H
{
"KPlugin": {
"Name": "Default Grantlee Header Style",
"ServiceTypes": [
"MessageViewerHeaderStyle/Plugin"
],
"Version": "1.0"
},
"X-KDE-MessageViewer-Header-Order": "100"
}
<?xml version="1.0" encoding="utf-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
<group name="GrantleeDefaultTheme">
<entry name="ThemeName" type="String">
<default></default>
</entry>
</group>
</kcfg>
File=defaultgrantleeheaderstyleplugin.kcfg
ClassName=DefaultGrantleeHeaderStylePluginSettings
Mutators=true
Singleton=true
ItemAccessors=true
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