2013-04-04 14:14:12 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program 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 General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#ifndef KWIN_ACTIVITIES_H
|
|
|
|
#define KWIN_ACTIVITIES_H
|
|
|
|
|
2013-04-05 07:41:25 +00:00
|
|
|
#include <kwinglobals.h>
|
|
|
|
|
2013-04-04 14:14:12 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QStringList>
|
|
|
|
|
2014-06-01 16:55:36 +00:00
|
|
|
#include <kactivities/controller.h>
|
|
|
|
|
2013-04-04 14:14:12 +00:00
|
|
|
namespace KActivities {
|
|
|
|
class Controller;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
class Client;
|
|
|
|
|
2016-08-12 10:52:47 +00:00
|
|
|
class KWIN_EXPORT Activities : public QObject
|
2013-04-04 14:14:12 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
~Activities();
|
|
|
|
|
|
|
|
bool stop(const QString &id);
|
|
|
|
bool start(const QString &id);
|
|
|
|
void setCurrent(const QString &activity);
|
|
|
|
/**
|
2019-02-02 18:17:44 +00:00
|
|
|
* Adds/removes client \a c to/from \a activity.
|
|
|
|
*
|
|
|
|
* Takes care of transients as well.
|
|
|
|
**/
|
2013-04-04 14:14:12 +00:00
|
|
|
void toggleClientOnActivity(Client* c, const QString &activity, bool dont_activate);
|
|
|
|
|
2014-06-01 16:55:36 +00:00
|
|
|
QStringList running() const;
|
|
|
|
QStringList all() const;
|
2013-04-04 14:14:12 +00:00
|
|
|
const QString ¤t() const;
|
|
|
|
const QString &previous() const;
|
|
|
|
|
2013-04-10 07:46:07 +00:00
|
|
|
static QString nullUuid();
|
2013-04-04 14:14:12 +00:00
|
|
|
|
2015-02-15 16:00:27 +00:00
|
|
|
KActivities::Controller::ServiceStatus serviceStatus() const;
|
|
|
|
|
2013-04-04 14:14:12 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
|
|
|
* This signal is emitted when the global
|
|
|
|
* activity is changed
|
|
|
|
* @param id id of the new current activity
|
2019-02-02 18:17:44 +00:00
|
|
|
**/
|
2013-04-04 14:14:12 +00:00
|
|
|
void currentChanged(const QString &id);
|
|
|
|
/**
|
|
|
|
* This signal is emitted when a new activity is added
|
|
|
|
* @param id id of the new activity
|
2019-02-02 18:17:44 +00:00
|
|
|
**/
|
2013-04-04 14:14:12 +00:00
|
|
|
void added(const QString &id);
|
|
|
|
/**
|
|
|
|
* This signal is emitted when the activity
|
|
|
|
* is removed
|
|
|
|
* @param id id of the removed activity
|
2019-02-02 18:17:44 +00:00
|
|
|
**/
|
2013-04-04 14:14:12 +00:00
|
|
|
void removed(const QString &id);
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void slotRemoved(const QString &activity);
|
|
|
|
void slotCurrentChanged(const QString &newActivity);
|
|
|
|
void reallyStop(const QString &id); //dbus deadlocks suck
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString m_previous;
|
2014-06-01 16:55:36 +00:00
|
|
|
QString m_current;
|
2013-04-04 14:14:12 +00:00
|
|
|
KActivities::Controller *m_controller;
|
|
|
|
|
2013-04-05 07:41:25 +00:00
|
|
|
KWIN_SINGLETON(Activities)
|
2013-04-04 14:14:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inline
|
2014-06-01 16:55:36 +00:00
|
|
|
QStringList Activities::all() const
|
2013-04-04 14:14:12 +00:00
|
|
|
{
|
2014-06-01 16:55:36 +00:00
|
|
|
return m_controller->activities();
|
2013-04-04 14:14:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
const QString &Activities::current() const
|
|
|
|
{
|
|
|
|
return m_current;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
const QString &Activities::previous() const
|
|
|
|
{
|
|
|
|
return m_previous;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
2014-06-01 16:55:36 +00:00
|
|
|
QStringList Activities::running() const
|
2013-04-04 14:14:12 +00:00
|
|
|
{
|
2014-06-01 16:55:36 +00:00
|
|
|
return m_controller->activities(KActivities::Info::Running);
|
2013-04-04 14:14:12 +00:00
|
|
|
}
|
|
|
|
|
2013-04-10 07:46:07 +00:00
|
|
|
inline
|
|
|
|
QString Activities::nullUuid()
|
|
|
|
{
|
|
|
|
// cloned from kactivities/src/lib/core/consumer.cpp
|
2013-07-23 05:02:52 +00:00
|
|
|
return QStringLiteral("00000000-0000-0000-0000-000000000000");
|
2013-04-10 07:46:07 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 14:14:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // KWIN_ACTIVITIES_H
|