Action QML Type
The main action class. More...
Since: | Qt 1.0 |
Inherited By: |
Properties
- description : string
- enabled : bool
- iconName : string
- keywords : string
- name : string
- parameterType : Type
- text : string
Signals
- triggered(var value)
Methods
- void trigger(var value)
Detailed Description
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.
import Lomiri.Action 1.0 Action { id: myaction1 name: "myaction1" text: i18n.tr("My Action") description: i18n.tr("Perform foo.") onTriggered: { console.debug ("myaction1 is triggered."); } }
Property Documentation
User visible secondary description for the action.
Description is more verbose than the text and should describe the Action with couple of words.
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.
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.
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 { text: i18n.tr("Crop") description: i18n.tr("Crop the image") keywords: i18n.tr("Trim;Cut") }
The name of the action. By default an action gets it's name generated automatically if not overridden with 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.
Type of the parameter passed to trigger() and triggered().
Type is an enumeration:
- Action.None: No paramater. (default)
- Action.String: String parameter.
- Action.Integer: Integer parameter.
- Action.Bool: Boolean parameter.
- Action.Real: Single precision floating point parameter.
Action { id: action parameterType: Action.String onTriggered: { // value arguments now contain strings console.log(value); } Component.onCompleted: action.trigger("Hello World")
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.
Signal Documentation
The value is always compatible with the set parameterType.
Note: The corresponding handler is onTriggered
.
Method Documentation
Checks the value agains parameterType and triggers the action.
If paramType is Action::None the action can be triggered by simly calling:
action.trigger();