2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2013-04-04 14:14:12 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
|
2013-04-04 14:14:12 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2013-04-04 14:14:12 +00:00
|
|
|
#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>
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
namespace KActivities
|
|
|
|
{
|
2013-04-04 14:14:12 +00:00
|
|
|
class Controller;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
2022-04-22 17:39:12 +00:00
|
|
|
class Window;
|
2013-04-04 14:14:12 +00:00
|
|
|
|
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:
|
2022-07-20 10:53:54 +00:00
|
|
|
explicit Activities();
|
2013-04-04 14:14:12 +00:00
|
|
|
|
|
|
|
bool stop(const QString &id);
|
|
|
|
bool start(const QString &id);
|
|
|
|
void setCurrent(const QString &activity);
|
|
|
|
/**
|
2022-04-28 07:44:11 +00:00
|
|
|
* Adds/removes window \a window to/from \a activity.
|
2019-02-02 18:17:44 +00:00
|
|
|
*
|
|
|
|
* Takes care of transients as well.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2022-04-28 07:44:11 +00:00
|
|
|
void toggleWindowOnActivity(Window *window, const QString &activity, bool dont_activate);
|
2013-04-04 14:14:12 +00:00
|
|
|
|
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-07-29 18:58:33 +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-07-29 18:58:33 +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-07-29 18:58:33 +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);
|
2022-03-23 10:13:38 +00:00
|
|
|
void reallyStop(const QString &id); // dbus deadlocks suck
|
2013-04-04 14:14:12 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline 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
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline const QString &Activities::current() const
|
2013-04-04 14:14:12 +00:00
|
|
|
{
|
|
|
|
return m_current;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline const QString &Activities::previous() const
|
2013-04-04 14:14:12 +00:00
|
|
|
{
|
|
|
|
return m_previous;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline 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
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
inline QString Activities::nullUuid()
|
2013-04-10 07:46:07 +00:00
|
|
|
{
|
|
|
|
// 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
|