LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
notificationactionhandler.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <functional>
12 #include <QObject>
13 #include <QPointer>
14 #include <interfaces/structures.h>
15 #include "xpcconfig.h"
16 
17 namespace LC::Util
18 {
51  class NotificationActionHandler : public QObject
52  {
53  Q_OBJECT
54 
55  Entity& Entity_;
56  public:
59  using Callback_t = std::function<void ()>;
60  private:
61  QList<QPair<QString, Callback_t>> ActionName2Callback_;
62 
63  QList<QPointer<QObject>> DependentObjects_;
64  public:
71  UTIL_XPC_API explicit NotificationActionHandler (Entity& entity, QObject* = nullptr);
72 
83  UTIL_XPC_API void AddFunction (const QString& name, Callback_t action);
84 
89  UTIL_XPC_API void AddDependentObject (QObject *object);
90  public slots:
91  void notificationActionTriggered (int);
92  };
93 }
QList
Definition: ianrulesstorage.h:14
LC::Util::NotificationActionHandler::AddDependentObject
UTIL_XPC_API void AddDependentObject(QObject *object)
Adds an object as a dependent object.
Definition: notificationactionhandler.cpp:34
xpcconfig.h
LC::Util
Definition: icoreproxy.h:33
LC::Entity
A message used for inter-plugin communication.
Definition: structures.h:95
structures.h
LC::Util::NotificationActionHandler::notificationActionTriggered
void notificationActionTriggered(int)
Definition: notificationactionhandler.cpp:39
LC::Util::NotificationActionHandler::AddFunction
UTIL_XPC_API void AddFunction(const QString &name, Callback_t action)
Adds an action with the given name.
Definition: notificationactionhandler.cpp:26
UTIL_XPC_API
#define UTIL_XPC_API
Definition: xpcconfig.h:16
LC::Util::NotificationActionHandler::Callback_t
std::function< void()> Callback_t
Type of functions used as actions in the handler.
Definition: notificationactionhandler.h:71
LC::Util::NotificationActionHandler::NotificationActionHandler
UTIL_XPC_API NotificationActionHandler(Entity &entity, QObject *=nullptr)
Creates the handler on the given entity.
Definition: notificationactionhandler.cpp:20