Loading...
Searching...
No Matches
lomiri::action::Action Class Reference

The main action class. More...

Inheritance diagram for lomiri::action::Action:

## Public Types

enum | Type { None , String , Integer , Bool , Real }
| Available parameter types. More...

## Public Slots

void | trigger (QVariant value=QVariant())

## Signals

void | descriptionChanged (const QString &value)
void | enabledChanged (bool value)
void | iconNameChanged (const QString &value)
void | keywordsChanged (const QString &value)
void | nameChanged (const QString &value)
void | parameterTypeChanged (lomiri::action::Action::Type value)
void | textChanged (const QString &value)
void | triggered (QVariant value)

## Public Member Functions

| Action (QObject *parent=0)
QString | description () const
bool | enabled () const
QString | iconName () const
QString | keywords () const
QString | name () const
Type | parameterType () const
void | setDescription (const QString &value)
void | setEnabled (bool value)
void | setIconName (const QString &value)
void | setKeywords (const QString &value)
void | setName (const QString &value)
void | setParameterType (Type value)
void | setText (const QString &value)
QString | text () const

## Properties

QString | description
bool | enabled
QString | iconName
QString | keywords
QString | name
lomiri::action::Action::Type | parameterType
QString | text

## Detailed Description

The main action class.

Lomiri services visualizing this class will usually be represented it as a simple button or menu item, depending upon where it is contributed.

The optional name property is available through D-Bus and can be used to activate a specific Action from external componenets such as the Launcher. See Platform Integration and Offline Actions for more information.

If the parameterType property is set, the Action is said to be parameterised. This means that when it is bound to a menu or button, the action expects a typed input parameter. The type affects the allowed value of the QVariant that must be passed to the trigger() and triggered().

Note
  As QVariant does automatic conversions between different normally uncorvertable types the developer must be careful of the side effects the conversions might have if accidentally passing wrong type of a parameter to trigger() or when handling the value of triggered(). Please, see the QVariant documentation for more information on the conversions QVariant does.

Action has to be added to the ActionManager or a ActionContext to make it available for external components.

## Member Enumeration Documentation

## Type

enum lomiri::action::Action::Type

Available parameter types.

This enum defines the available types that the action trigger() and triggered() support.

Enumerator
None | No paramater. Trying to pass anything else than an empty QVariant is an error.
String | String parameter.
Integer | Integer parameter.
Bool | Boolean parameter.
Real | Single precision floating point parameter.

## Constructor & Destructor Documentation

## Action()

Action::Action | ( | QObject * | parent = `0` | ) |

explicit

Parameters

  parent | parent QObject or 0

Constructs a new Action. See the property documentation for default values.

## Member Function Documentation

## trigger

void Action::trigger | ( | QVariant | value = `QVariant()` | ) |

slot

Checks the value agains parameterType and triggers the action.

if paramType is Action::None the action can be triggered by simly calling:

action->trigger();

Note
  beware of the automatic conversion QVariant does. See the QVariant documentation for details.

## triggered

void lomiri::action::Action::triggered | ( | QVariant | value | ) |

signal

Parameters

  value | the value which which was passed to trigger()

The value is always compatible with the set parameterType. For example if parameterType is Action::String the value can be converted to QString by using the QVariant conversion functions:

QString param = value.toString();

## Property Documentation

## description

QString lomiri::action::Action::description

read write

User visible secondary description for the action.

Description is more verbose than the text() and should describe the Action with couple of words.

Initial Value:\n ""

Accessors:\n description(), setDescription()

Notify:\n descriptionChanged()

## enabled

bool lomiri::action::Action::enabled

read write

If set to false the action can not be triggered.

Components visualizing the action migth either hide the action or make it insensitive.

If set to false the Action is removed from the search results of the HUD.

Initial Value:\n true

Accessors:\n enabled(), setEnabled()

Notify:\n enabledChanged()

## iconName

QString lomiri::action::Action::iconName

read write

Name of a icon for this action.

When the action is exported to external components the iconName must be avaible on system icon theme engine.

Initial Value:\n ""

Accessors:\n iconName(), setIconName()

Notify:\n iconNameChanged()

## keywords

QString lomiri::action::Action::keywords

read write

Additional user visible keywords for the action.

Keywords improve the HUD search results when the user tries to search for an action with a synonym of the text(). For example if we the application has an action "Crop" but the user tries to "Trim" then without the keywords the HUD would not try to offer the "Crop" action.

The format of the keywords string is "Keyword 1;Keyword 2;Keyword 3" to allow translators to define different number of keywords per language.

The keywords are separated by ; and they may contain spaces.

Action *action = new Action(this);
action->setText(tr("Crop"));
action->description(tr("Crop the image"));
action->setKeywords(tr("Trim;Cut"));
lomiri::action::Action
The main action class.
Definition lomiri-action.h:31
lomiri::action::Action::description
QString description
Definition lomiri-action.h:51

Initial Value:\n ""

Accessors:\n keywords(), setKeywords()

Notify:\n keywordsChanged()

## name

QString lomiri::action::Action::name

read write

The name of the action. By default an action gets it's name generated automatically if not overridden with setName() later. If name is set to "" then the action restores it's autogenerated name.

The actions is accessible from D-Bus with this name.

The name is not user visible.

Note
  Changing the name is potentially an expensive operation if the action is already added to the manager. If possible, set the name for your action before adding it to the manager.

Initial Value:\n autogenerated

Accessors:\n name(), setName()

Notify:\n nameChanged()

## parameterType

Action::Type lomiri::action::Action::parameterType

read write

Type of the parameter passed to trigger() and triggered().

Note
  Changing the parameterType is potentially an expensive operation if the action is already added to the manager. If possible, set the parameterType of your action before adding it to the manager.

Initial Value:\n Action::None

Accessors:\n parameterType(), setParameterType()

Notify:\n parameterTypeChanged()

## text

QString lomiri::action::Action::text

read write

The user visible primary label of the action.

Initial Value:\n ""

Accessors:\n text(), setText()

Notify:\n textChanged()

The documentation for this class was generated from the following files:

- lomiri-action.h
- lomiri-action.cpp