KActivities::Consumer Class

class KActivities::Consumer

Read-only information about activities. More...

Header: #include <PlasmaActivities/Consumer>
CMake: find_package(Plasma REQUIRED COMPONENTS Activities)
target_link_libraries(mytarget PRIVATE Plasma::Activities)
Inherited By:

KActivities::Controller

Public Types

enum ServiceStatus { NotRunning, Unknown, Running }

Properties

Public Functions

Consumer(QObject *parent = nullptr)
QStringList activities() const
QString currentActivity() const
KActivities::Consumer::ServiceStatus serviceStatus()

Signals

void activitiesChanged(const QStringList &activities)
void activityAdded(const QString &id)
void activityRemoved(const QString &id)
void currentActivityChanged(const QString &id)
void serviceStatusChanged(KActivities::Consumer::ServiceStatus status)

Detailed Description

Contextual information can be, from the user's point of view, divided into three aspects - "who am I?", "where am I?" (what are my surroundings?) and "what am I doing?".

Activities deal with the last one - "what am I doing?". The current activity refers to what the user is doing at the moment, while the other activities represent things that he/she was doing before, and probably will be doing again.

Activity is an abstract concept whose meaning can differ from one user to another. Typical examples of activities are "developing a KDE project", "studying the 19th century art", "composing music", "lazing on a Sunday afternoon" etc.

Consumer provides read-only information about activities.

Before relying on the values retrieved by the class, make sure that the serviceStatus is set to Running. Otherwise, you can get invalid data either because the service is not functioning properly (or at all) or because the class did not have enough time to synchronize the data with it.

For example, if this is the only existing instance of the Consumer class, the listActivities method will return an empty list.

void someMethod() {
    // Do not copy. This approach is not a good one!
    Consumer c;
    doSomethingWith(c.listActivities());
}

Instances of the Consumer class should be long-lived. For example, members of the classes that use them, and you should listen for the changes in the provided properties.

Member Type Documentation

enum Consumer::ServiceStatus

Different states of the activities service

ConstantValueDescription
KActivities::Consumer::NotRunning0Service is not running
KActivities::Consumer::Unknown1Unable to determine the status of the service
KActivities::Consumer::Running2Service is running properly

Property Documentation

[read-only] activities : QStringList

Access functions:

QStringList activities() const

Notifier signal:

void activitiesChanged(const QStringList &activities)

[read-only] currentActivity : QString

Access functions:

QString currentActivity() const

Notifier signal:

void currentActivityChanged(const QString &id)

[read-only] serviceStatus : ServiceStatus

Access functions:

KActivities::Consumer::ServiceStatus serviceStatus()

Notifier signal:

void serviceStatusChanged(KActivities::Consumer::ServiceStatus status)

Member Function Documentation

[explicit] Consumer::Consumer(QObject *parent = nullptr)

QStringList Consumer::activities() const

Returns the list of all existing activities

Note: If the serviceStatus is not Running, only a null activity will be returned.

Note: Getter function for property activities.

[signal] void Consumer::activitiesChanged(const QStringList &activities)

This signal is emitted when the activity list changes

activities list of activities

Note: Notifier signal for property activities.

[signal] void Consumer::activityAdded(const QString &id)

This signal is emitted when a new activity is added

id id of the new activity

[signal] void Consumer::activityRemoved(const QString &id)

This signal is emitted when an activity has been removed

id id of the removed activity

QString Consumer::currentActivity() const

Returns the id of the current activity

Note: Activity ID is a UUID-formatted string. If the serviceStatus is not Running, a null UUID is returned. The ID can also be an empty string in the case there is no current activity.

Note: Getter function for property currentActivity.

[signal] void Consumer::currentActivityChanged(const QString &id)

This signal is emitted when the current activity is changed

id id of the new current activity

Note: Notifier signal for property currentActivity.

KActivities::Consumer::ServiceStatus Consumer::serviceStatus()

Returns status of the activities service

Note: Getter function for property serviceStatus.

[signal] void Consumer::serviceStatusChanged(KActivities::Consumer::ServiceStatus status)

This signal is emitted when the activity service goes online or offline, or when the class manages to synchronize the data with the service.

status new status of the service

Note: Notifier signal for property serviceStatus.