KActivities 5.109.0
Public Types | Properties | Signals | Public Member Functions | List of all members
KActivities::Info

This class provides info about an activity. More...

#include <info.h>

Public Types

enum  Availability { Nothing = 0 , BasicInfo = 1 , Everything = 2 }
 Specifies which parts of this class are functional. More...
 
enum  State {
  Invalid = 0 , Unknown = 1 , Running = 2 , Starting = 3 ,
  Stopped = 4 , Stopping = 5
}
 State of the activity. More...
 

Properties

QString description
 
QString icon
 
QString id
 
bool isCurrent
 
QString name
 
Info::State state
 

Signals

void added ()
 Emitted when the activity is added.
 
void descriptionChanged (const QString &description)
 Emitted when the description is changed.
 
void iconChanged (const QString &icon)
 Emitted when the icon was changed.
 
void infoChanged ()
 Links the specified resource to the activity.
 
void isCurrentChanged (bool current)
 Emitted when the activity becomes the current one, or when it stops being the current one.
 
void nameChanged (const QString &name)
 Emitted when the name is changed.
 
void removed ()
 Emitted when the activity is removed.
 
void started ()
 Emitted when the activity is started.
 
void stateChanged (KActivities::Info::State state)
 Emitted when the activity changes state.
 
void stopped ()
 Emitted when the activity is stopped.
 

Public Member Functions

 Info (const QString &activity, QObject *parent=nullptr)
 
Availability availability () const
 
QString description () const
 
QString icon () const
 
QString id () const
 
bool isCurrent () const
 
bool isValid () const
 
QString name () const
 
State state () const
 
QString uri () const
 

Detailed Description

This class provides info about an activity.

Most methods in it require a semantic backend running to function properly.

This class is not thread-safe.

See also
Consumer for info about activities

The API of the class is synchronous, but the most used properties are pre-fetched and cached. This means that, in order to get the least amount of d-bus related locks, you should declare long-lived instances of this class.

Before relying on the values retrieved by the class, make sure that the state is not Info::Unknown. 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 Info class, the name method will return an empty string.

For example, this is wrong (works, but blocks):

void someMethod(const QString & activity) {
// Do not copy. This approach is not a good one!
Info info(activity);
doSomethingWith(info.name());
}
This class provides info about an activity.
Definition info.h:57

Instances of the Info 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.

Since
4.5

Member Enumeration Documentation

◆ Availability

Specifies which parts of this class are functional.

Enumerator
Nothing 

No activity info provided (isValid is false)

BasicInfo 

Basic info is provided.

Everything 

Everything is available.

◆ State

State of the activity.

Enumerator
Invalid 

This activity does not exist.

Unknown 

Information is not yet retrieved from the service.

Running 

Activity is running.

Starting 

Activity is begin started.

Stopped 

Activity is stopped.

Stopping 

Activity is begin started.

Member Function Documentation

◆ added

void KActivities::Info::added ( )
signal

Emitted when the activity is added.

◆ availability()

Availability KActivities::Info::availability ( ) const
Returns
what info is provided by this instance of Info

◆ description()

QString KActivities::Info::description ( ) const
Returns
the description of the activity

◆ descriptionChanged

void KActivities::Info::descriptionChanged ( const QString &  description)
signal

Emitted when the description is changed.

◆ icon()

QString KActivities::Info::icon ( ) const
Returns
the icon of the activity. Icon can be a freedesktop.org name or a file path. Or empty if no icon is set.

◆ iconChanged

void KActivities::Info::iconChanged ( const QString &  icon)
signal

Emitted when the icon was changed.

◆ id()

QString KActivities::Info::id ( ) const
Returns
the id of the activity

◆ infoChanged

void KActivities::Info::infoChanged ( )
signal

Links the specified resource to the activity.

Parameters
resourceUriresource URI
Note
This method is asynchronous. It will return before the resource is actually linked to the activity. Unlinks the specified resource from the activity
Parameters
resourceUriresource URI
Note
This method is asynchronous. It will return before the resource is actually unlinked from the activity.
Returns
whether a resource is linked to this activity
Note
This QFuture is not thread-based, you can not call synchronous methods like waitForFinished, cancel, pause on it.
Since
5.0 Emitted when the activity's name, icon or some custom property is changed

◆ isCurrent()

bool KActivities::Info::isCurrent ( ) const
Returns
whether this activity is the current one

◆ isCurrentChanged

void KActivities::Info::isCurrentChanged ( bool  current)
signal

Emitted when the activity becomes the current one, or when it stops being the current one.

◆ isValid()

bool KActivities::Info::isValid ( ) const
Returns
true if the activity represented by this object exists and is valid

◆ name()

QString KActivities::Info::name ( ) const
Returns
the name of the activity

◆ nameChanged

void KActivities::Info::nameChanged ( const QString &  name)
signal

Emitted when the name is changed.

◆ removed

void KActivities::Info::removed ( )
signal

Emitted when the activity is removed.

◆ started

void KActivities::Info::started ( )
signal

Emitted when the activity is started.

◆ state()

State KActivities::Info::state ( ) const
Returns
the state of the activity

◆ stateChanged

void KActivities::Info::stateChanged ( KActivities::Info::State  state)
signal

Emitted when the activity changes state.

Parameters
statenew state of the activity

◆ stopped

void KActivities::Info::stopped ( )
signal

Emitted when the activity is stopped.

◆ uri()

QString KActivities::Info::uri ( ) const
Returns
the URI of this activity. The same URI is used by activities KIO worker.