Commit 2ec1c6e8 authored by Laurent Montel's avatar Laurent Montel 😁

Add plugin for expand url

parent c60f151d
......@@ -7,3 +7,4 @@ add_subdirectory(translatorplugin)
add_subdirectory(createnoteplugin)
add_subdirectory(createtodoplugin)
add_subdirectory(createeventplugin)
add_subdirectory(expandurlplugin)
set(messageviewer_expandurlplugin_SRCS
viewerpluginexpandurl.cpp
viewerpluginexpandurlinterface.cpp
)
add_library(messageviewer_expandurlplugin MODULE ${messageviewer_expandurlplugin_SRCS})
target_link_libraries(messageviewer_expandurlplugin
KF5::MessageViewer KF5::XmlGui
)
install(TARGETS messageviewer_expandurlplugin DESTINATION ${PLUGIN_INSTALL_DIR}/messageviewer)
{
"KPlugin": {
"Name": "Expand Url",
"ServiceTypes": [
"MessageViewer/ViewerPlugin"
],
"Version": "1.0"
}
}
/*
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 "viewerpluginexpandurl.h"
#include "viewerpluginexpandurlinterface.h"
#include <KActionCollection>
#include <KToggleAction>
#include <kpluginfactory.h>
using namespace MessageViewer;
K_PLUGIN_FACTORY_WITH_JSON(ViewerPluginExpandurlFactory, "messageviewer_expandurlplugin.json", registerPlugin<ViewerPluginExpandurl>();)
ViewerPluginExpandurl::ViewerPluginExpandurl(QObject *parent, const QList<QVariant> &)
: MessageViewer::ViewerPlugin(parent)
{
}
ViewerPluginInterface *ViewerPluginExpandurl::createView(QWidget *parent, KActionCollection *ac)
{
MessageViewer::ViewerPluginInterface *view = new MessageViewer::ViewerPluginExpandurlInterface(ac, parent);
return view;
}
QString ViewerPluginExpandurl::viewerPluginName() const
{
return QStringLiteral("expandurl");
}
#include "viewerpluginexpandurl.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 VIEWERPLUGINEXPANDURL_H
#define VIEWERPLUGINEXPANDURL_H
#include <messageviewer/viewerplugin.h>
#include <QVariant>
namespace MessageViewer
{
class ViewerPluginExpandurl : public MessageViewer::ViewerPlugin
{
Q_OBJECT
public:
explicit ViewerPluginExpandurl(QObject *parent = Q_NULLPTR, const QList<QVariant> & = QList<QVariant>());
ViewerPluginInterface *createView(QWidget *parent, KActionCollection *ac) Q_DECL_OVERRIDE;
QString viewerPluginName() const Q_DECL_OVERRIDE;
};
}
#endif // VIEWERPLUGINEXPANDURL_H
/*
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 "viewerpluginexpandurlinterface.h"
#include <QHBoxLayout>
#include <QIcon>
#include <QAction>
#include <KActionCollection>
#include <KLocalizedString>
using namespace MessageViewer;
ViewerPluginExpandurlInterface::ViewerPluginExpandurlInterface(KActionCollection *ac, QWidget *parent)
: ViewerPluginInterface(parent),
mAction(Q_NULLPTR)
{
createAction(ac);
}
ViewerPluginExpandurlInterface::~ViewerPluginExpandurlInterface()
{
}
QAction *ViewerPluginExpandurlInterface::action() const
{
return mAction;
}
void ViewerPluginExpandurlInterface::showWidget()
{
//Nothing
}
ViewerPluginInterface::SpecificFeatureTypes ViewerPluginExpandurlInterface::featureTypes() const
{
return NeedUrl;
}
void ViewerPluginExpandurlInterface::createAction(KActionCollection *ac)
{
if (ac) {
#if 0
mAction = new QAction(i18n("Translate..."), this);
ac->setDefaultShortcut(mAction, QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_T));
mAction->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-locale")));
ac->addAction(QStringLiteral("translate_text"), mAction);
connect(mAction, &QAction::triggered, this, &ViewerPluginExpandurlInterface::slotActivatePlugin);
#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 VIEWERPLUGINEXPANDURLINTERFACE_H
#define VIEWERPLUGINEXPANDURLINTERFACE_H
#include <messageviewer/viewerplugininterface.h>
class KActionCollection;
namespace MessageViewer
{
class ViewerPluginExpandurlInterface : public ViewerPluginInterface
{
Q_OBJECT
public:
explicit ViewerPluginExpandurlInterface(KActionCollection *ac, QWidget *parent = Q_NULLPTR);
~ViewerPluginExpandurlInterface();
QAction *action() const Q_DECL_OVERRIDE;
void showWidget() Q_DECL_OVERRIDE;
ViewerPluginInterface::SpecificFeatureTypes featureTypes() const Q_DECL_OVERRIDE;
private:
void createAction(KActionCollection *ac);
QAction *mAction;
};
}
#endif // VIEWERPLUGINEXPANDURLINTERFACE_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