Commit da91a522 authored by Eike Hein's avatar Eike Hein

Add a signal notifying a change in the names of running activities.

Summary: CCBUG:384001

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: davidedmundson, anthonyfieroni, ivan, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D8524
parent 49884b79
......@@ -20,6 +20,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "activityinfo.h"
#include <KActivities/ActivitiesModel>
#include <KActivities/Consumer>
namespace TaskManager
......@@ -33,10 +34,13 @@ public:
static int instanceCount;
static KActivities::Consumer* activityConsumer;
static KActivities::ActivitiesModel* activitiesModel;
};
int ActivityInfo::Private::instanceCount = 0;
KActivities::Consumer* ActivityInfo::Private::activityConsumer = nullptr;
KActivities::ActivitiesModel* ActivityInfo::Private::activitiesModel = nullptr;
ActivityInfo::Private::Private(ActivityInfo *)
{
......@@ -50,6 +54,8 @@ ActivityInfo::Private::~Private()
if (!instanceCount) {
delete activityConsumer;
activityConsumer = nullptr;
delete activitiesModel;
activitiesModel = nullptr;
}
}
......@@ -64,6 +70,27 @@ ActivityInfo::ActivityInfo(QObject *parent) : QObject(parent)
this, &ActivityInfo::currentActivityChanged);
connect(d->activityConsumer, &KActivities::Consumer::runningActivitiesChanged,
this, &ActivityInfo::numberOfRunningActivitiesChanged);
connect(d->activityConsumer, &KActivities::Consumer::runningActivitiesChanged,
this, &ActivityInfo::namesOfRunningActivitiesChanged);
if (!d->activitiesModel) {
d->activitiesModel = new KActivities::ActivitiesModel();
d->activitiesModel->setShownStates(QVector<KActivities::Info::State>{KActivities::Info::Running});
}
connect(d->activitiesModel, &KActivities::ActivitiesModel::modelReset,
this, &ActivityInfo::namesOfRunningActivitiesChanged);
connect(d->activitiesModel, &KActivities::ActivitiesModel::dataChanged, this,
[this](const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles) {
Q_UNUSED(topLeft)
Q_UNUSED(bottomRight)
if (roles.isEmpty() || roles.contains(Qt::DisplayRole)) {
emit namesOfRunningActivitiesChanged();
}
}
);
}
ActivityInfo::~ActivityInfo()
......
......@@ -86,6 +86,12 @@ Q_SIGNALS:
void currentActivityChanged() const;
void numberOfRunningActivitiesChanged() const;
/**
* The names of the running activities have changed.
* @since 5.40.0
**/
void namesOfRunningActivitiesChanged() const;
private:
class Private;
QScopedPointer<Private> d;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment