diff --git a/src/declarative/CMakeLists.txt b/src/declarative/CMakeLists.txt index 6558616..491d05c 100644 --- a/src/declarative/CMakeLists.txt +++ b/src/declarative/CMakeLists.txt @@ -1,12 +1,13 @@ +qt5_wrap_cpp(kpeopledeclarative_SRCS ../widgets/actions.cpp) add_library(KF5PeopleDeclarative SHARED declarativepersondata.cpp personactionsmodel.cpp - peopleqmlplugin.cpp) + peopleqmlplugin.cpp ${kpeopledeclarative_SRCS}) target_link_libraries(KF5PeopleDeclarative Qt5::Qml KF5::PeopleWidgets # QAction ) install(TARGETS KF5PeopleDeclarative DESTINATION ${QML_INSTALL_DIR}/org/kde/people) install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/people) diff --git a/src/declarative/peopleqmlplugin.cpp b/src/declarative/peopleqmlplugin.cpp index c026dfa..e1dd78e 100644 --- a/src/declarative/peopleqmlplugin.cpp +++ b/src/declarative/peopleqmlplugin.cpp @@ -1,74 +1,76 @@ /* Persons Model Copyright (C) 2012 Aleix Pol Gonzalez This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "peopleqmlplugin.h" #include #include #include #include #include #include #include "declarativepersondata.h" #include class ActionTypeWrapper : public QObject { Q_OBJECT public: enum ActionType { TextChatAction = KPeople::TextChatAction, AudioCallAction = KPeople::AudioCallAction, VideoCallAction = KPeople::VideoCallAction, SendEmailAction = KPeople::SendEmailAction, SendFileAction = KPeople::SendFileAction, OtherAction = KPeople::OtherAction }; Q_ENUM(ActionType) }; class DeclarativePersonPluginManager : public QObject { Q_OBJECT public: Q_SCRIPTABLE bool addContact(const QVariantMap &properties) { return KPeople::PersonPluginManager::addContact(properties); } Q_SCRIPTABLE bool deleteContact(const QString &uri) { return KPeople::PersonPluginManager::deleteContact(uri); } }; void PeopleQMLPlugin::registerTypes(const char *uri) { qmlRegisterType(uri, 1, 0, "PersonsModel"); qmlRegisterType(uri, 1, 0, "PersonsSortFilterProxyModel"); qmlRegisterType(uri, 1, 0, "PersonActions"); qmlRegisterType(uri, 1, 0, "PersonData"); #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) qmlRegisterType(); #else qmlRegisterAnonymousType(uri, 1); #endif qmlRegisterUncreatableType(uri, 1, 0, "ActionType", QStringLiteral("You cannot create ActionType")); qmlRegisterSingletonType(uri, 1, 0, "PersonPluginManager", [] (QQmlEngine*, QJSEngine*) -> QObject* { return new DeclarativePersonPluginManager; }); + + qmlRegisterUncreatableMetaObject(KPeople::staticMetaObject, uri, 1, 0, "KPeople", QStringLiteral("Access to enums & flags only")); } #include "peopleqmlplugin.moc" diff --git a/src/widgets/actions.h b/src/widgets/actions.h index 870a157..202a362 100644 --- a/src/widgets/actions.h +++ b/src/widgets/actions.h @@ -1,54 +1,57 @@ /* Copyright (C) 2013 David Edmundson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef KPEOPLEWIDGETS_ACTIONS_H #define KPEOPLEWIDGETS_ACTIONS_H #include +#include #include class QString; class QObject; class QAction; namespace KPeople { +Q_NAMESPACE class PersonData; /** * Each action returned in the list can be one of these * types, however the Type is not mandatory with the action * * The type should be set as QObject property "actionType" */ enum ActionType { TextChatAction, AudioCallAction, VideoCallAction, SendEmailAction, SendFileAction, OtherAction = 100 }; +Q_ENUM_NS(ActionType) /** * Returns a list of actions relevant to the specified @p contactUri where * each QAction will have @p parent passed as its parent QObject */ KPEOPLEWIDGETS_EXPORT QList actionsForPerson(const QString &contactUri, QObject *parent); } #endif // KPEOPLEWIDGETS_ACTIONS_H