1/********************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org>
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program. If not, see <http://www.gnu.org/licenses/>.
19*********************************************************************/
20#ifndef KWIN_ACTIVITIES_H
21#define KWIN_ACTIVITIES_H
22
23#include <kwinglobals.h>
24
25#include <QObject>
26#include <QStringList>
27
28namespace KActivities {
29class Controller;
30}
31
32namespace KWin
33{
34class Client;
35
36class Activities : public QObject
37{
38 Q_OBJECT
39
40public:
41 ~Activities();
42
43 bool stop(const QString &id);
44 bool start(const QString &id);
45 void update(bool running, bool updateCurrent, QObject *target = NULL, QString slot = QString());
46 void setCurrent(const QString &activity);
47 /**
48 * Adds/removes client \a c to/from \a activity.
49 *
50 * Takes care of transients as well.
51 */
52 void toggleClientOnActivity(Client* c, const QString &activity, bool dont_activate);
53
54 const QStringList &running() const;
55 const QStringList &all() const;
56 const QString &current() const;
57 const QString &previous() const;
58
59 static QString nullUuid();
60
61Q_SIGNALS:
62 /**
63 * This signal is emitted when the global
64 * activity is changed
65 * @param id id of the new current activity
66 */
67 void currentChanged(const QString &id);
68 /**
69 * This signal is emitted when a new activity is added
70 * @param id id of the new activity
71 */
72 void added(const QString &id);
73 /**
74 * This signal is emitted when the activity
75 * is removed
76 * @param id id of the removed activity
77 */
78 void removed(const QString &id);
79
80private Q_SLOTS:
81 void slotRemoved(const QString &activity);
82 void slotAdded(const QString &activity);
83 void slotCurrentChanged(const QString &newActivity);
84 void reallyStop(const QString &id); //dbus deadlocks suck
85 void handleReply();
86
87private:
88 QStringList m_running;
89 QStringList m_all;
90 QString m_current;
91 QString m_previous;
92 KActivities::Controller *m_controller;
93
94 KWIN_SINGLETON(Activities)
95};
96
97inline
98const QStringList &Activities::all() const
99{
100 return m_all;
101}
102
103inline
104const QString &Activities::current() const
105{
106 return m_current;
107}
108
109inline
110const QString &Activities::previous() const
111{
112 return m_previous;
113}
114
115inline
116const QStringList &Activities::running() const
117{
118 return m_running;
119}
120
121inline
122QString Activities::nullUuid()
123{
124 // cloned from kactivities/src/lib/core/consumer.cpp
125 return QString("00000000-0000-0000-0000-000000000000");
126}
127
128}
129
130#endif // KWIN_ACTIVITIES_H
131