Commit 2161d950 authored by Bhushan Shah's avatar Bhushan Shah Committed by Jonah Brüchert

Add kpeople action plugin

Very initial scaffolding for creating a proper kpeople action plugin.
parent 92070652
......@@ -29,7 +29,7 @@ include(KDECompilerSettings NO_POLICY_SCOPE)
################# Find dependencies #################
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Svg QuickControls2)
find_package(KF5 REQUIRED COMPONENTS Kirigami2 Contacts)
find_package(KF5 REQUIRED COMPONENTS Kirigami2 Contacts People)
################# Enable C++11 features for clang and gcc #################
......
......@@ -5,3 +5,5 @@ target_link_libraries(plasma-phonebook
KF5::Contacts
)
install(TARGETS plasma-phonebook ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
add_subdirectory(kpeopleactionplugin)
kcoreaddons_add_plugin (phonebook_kpeople_plugin SOURCES kpeopleactionsplugin.cpp JSON "phonebook_kpeople_plugin.json" INSTALL_NAMESPACE "kpeople/actions")
target_link_libraries(phonebook_kpeople_plugin
KF5::CoreAddons
KF5::I18n
KF5::People
KF5::PeopleBackend
)
/*
* Copyright (C) 2019 Bhushan Shah <bshah@kde.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "kpeopleactionsplugin.h"
#include <QDebug>
#include <KLocalizedString>
#include <KPluginFactory>
#include <KPeopleBackend/AbstractContact>
KPeopleActionsPlugin::KPeopleActionsPlugin(QObject* parent, const QVariantList& args)
: AbstractPersonAction(parent)
{
Q_UNUSED(args)
}
QList<QAction *> KPeopleActionsPlugin::actionsForPerson(const KPeople::PersonData& data, QObject* parent) const
{
Q_UNUSED(parent)
QList<QAction *> actions;
QVariant number = data.contactCustomProperty(KPeople::AbstractContact::PhoneNumberProperty);
if(!number.toString().isEmpty()) {
QAction *action = new QAction(QIcon::fromTheme("call-start"),
i18nc("Action to tell user to call person using phone number", "Call %1 on %2", data.name(), number.toString()));
actions << action;
}
return actions;
}
K_PLUGIN_FACTORY_WITH_JSON( KPeopleActionsPluginFactory, "phonebook_kpeople_plugin.json", registerPlugin<KPeopleActionsPlugin>(); )
#include "kpeopleactionsplugin.moc"
/*
* Copyright (C) 2019 Bhushan Shah <bshah@kde.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef KPEOPLEACTIONSPLUGIN_H
#define KPEOPLEACTIONSPLUGIN_H
#include <QObject>
#include <KPeopleBackend/AbstractPersonAction>
class KPeopleActionsPlugin : public KPeople::AbstractPersonAction
{
Q_OBJECT
public:
KPeopleActionsPlugin(QObject *parent, const QVariantList &args);
QList<QAction *> actionsForPerson(const KPeople::PersonData & data, QObject * parent) const override;
};
#endif // KPEOPLEACTIONSPLUGIN_H
{
"Encoding": "UTF-8",
"KPlugin": {
"Authors": [
{
"Email": "bshah@kde.org",
"Name": "Bhushan Shah"
}
],
"EnabledByDefault": true,
"Id": "phonebook",
"License": "GPL",
"ServiceTypes": [
"KPeople/Plugin"
],
"Version": "0.1"
}
}
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