Dekko
ActionRegistry.h
1 /* Copyright (C) 2017 Dan Chapman <dpniel@ubuntu.com>
2 
3  This file is part of Dekko email client for Ubuntu devices
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License as
7  published by the Free Software Foundation; either version 2 of
8  the License or (at your option) version 3
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef ACTIONREGISTRY_H
19 #define ACTIONREGISTRY_H
20 
21 #include <QLoggingCategory>
22 #include <QObject>
23 #include <QQmlIncubator>
24 #include <QQmlListProperty>
25 #include "PluginIncubator.h"
26 
27 
28 Q_DECLARE_LOGGING_CATEGORY(PLUGIN_ACTION)
29 
30 class ActionRegistry : public QObject
31 {
32  Q_OBJECT
33  Q_PROPERTY(QQmlListProperty<QObject> defaultActions READ defaultActions)
34  Q_PROPERTY(QList<QObject *> actions READ actions NOTIFY actionsChanged)
35  Q_PROPERTY(QString location READ location WRITE setLocation NOTIFY locationChanged)
36 
37 public:
38  explicit ActionRegistry(QObject *parent = 0);
39  ~ActionRegistry();
40 
41  QQmlListProperty<QObject> defaultActions();
42  QList<QObject *> actions() const;
43  QString location() const;
44 
45 signals:
46  void actionsChanged(QList<QObject *> actions);
47  void locationChanged(QString location);
48 
49 public slots:
50  void setLocation(QString location);
51 
52 private slots:
53  void loadActions();
54  void finishLoading();
55  void handleError();
56 
57 private:
58  QList<QObject *> m_actions;
59  QList<QObject *> m_defaults;
60  QString m_location;
61  IncubatorList m_incubators;
62 };
63 
64 #endif // ACTIONREGISTRY_H
ActionRegistry
Definition: ActionRegistry.h:30