Unity Action API
 All Classes Functions Enumerations Enumerator Properties Pages
unity-action-context.h
1 /* This file is part of unity-action-api
2  * Copyright 2013 Canonical Ltd.
3  *
4  * unity-action-api is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * unity-action-api is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranties of
10  * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11  * PURPOSE. See the GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef UNITY_ACTION_CONTEXT
18 #define UNITY_ACTION_CONTEXT
19 
20 namespace unity {
21 namespace action {
22  class ActionContext;
23  class Action;
24 }
25 }
26 
27 #include <QObject>
28 #include <QScopedPointer>
29 #include <QSet>
30 
31 class Q_DECL_EXPORT unity::action::ActionContext : public QObject
32 {
33  Q_OBJECT
34  Q_DISABLE_COPY(ActionContext)
35 
36  Q_PROPERTY(bool active
37  READ active
38  WRITE setActive
39  NOTIFY activeChanged)
40 
41 public:
42 
43  explicit ActionContext(QObject *parent = 0);
44  virtual ~ActionContext();
45 
46  Q_INVOKABLE void addAction(unity::action::Action *action);
47  Q_INVOKABLE void removeAction(unity::action::Action *action);
48 
49  bool active() const;
50  void setActive(bool value);
51 
52  QSet<Action *> actions() const;
53 
54 signals:
55  void activeChanged(bool value);
56  void actionsChanged();
57 
58 private:
59  class Private;
60  QScopedPointer<Private> d;
61 };
62 #endif