Property Functions

Property functions are used to retrieve the value of certain properties of an SVG. These can then be used directly as values for properties of the Union data model or used by other elements of the Plasma SVG input plugin.

Function Call Blocks

Any rule definition can call property functions for properties. Whenever you would normally use a value for a property you can instead use a function call block. These are mappings that contain the key function to identify which function to call. Any other entries in this mapping will be passed as arguments to the called function. What exact arguments these functions accept depends on the function and is described below.

For example, the following function call block would call the function element-image and return an image for the element example-element in the SVG example:

image:
    function: element-image
    path: "example"
    element: "example-element"

Contextual Arguments

Some functions can accept contextual arguments. These arguments can be set at any level in a rule definition. When the property function is called it will use the last declared value for such an argument. For example, if you have the following rule definition:

example:
    path: "example"
    layout:
        prefix: "example"
        width:
            function: element-width
            element: "width-element"
        height:
            function: element-height
            element: "height-element"

The function element-width will look up the element named width-element, prefixed with example from the layout block that is it's parent. It will look for this element inside the example SVG that is declared as path at the top level. The function element-height will instead look for the element height-element, but still prefixed with the same example in the same example SVG.

Available Functions

element-size

Returns the size of an SVG element.

Contextual Arguments

  • path The path of the SVG to use. Relative to the theme root path.
  • prefix A prefix that will be prepended to any element name, using "-" as separator.
  • element The name of an SVG element to use.

element-width

Returns the width of an SVG element.

Contextual Arguments

  • path The path of the SVG to use. Relative to the theme root path.
  • prefix A prefix that will be prepended to any element name, using "-" as separator.
  • element The name of an SVG element to use.

element-height

Returns the height of an SVG element.

Contextual Arguments

  • path The path of the SVG to use. Relative to the theme root path.
  • prefix A prefix that will be prepended to any element name, using "-" as separator.
  • element The name of an SVG element to use.

element-image

Returns a rendered image of an SVG element. It will use the current color set and color group for rendering if the SVG supports recoloring.

Contextual Arguments

  • path The path of the SVG to use. Relative to the theme root path.
  • prefix A prefix that will be prepended to any element name, using "-" as separator.
  • element The name of an SVG element to use.
  • colorSet The color set to use when rendering an image of an element.
  • colorGroup The color group to use when rendering an image of an element.

element-image-blend

Renders several elements to images, blends them together using alpha blending and returns the result. The resulting image will use the largest width and height of the elements as width and height.

Arguments

  • elements A list that contains either plain element names or function call blocks. Note that the function call needs to return an image. If using plain element names, this function will call element-image for each element name.
  • align A Qt::Alignment value that indicates how images should be aligned if their sizes are different.
  • stretch A Qt::Orientation value that indicates if images that are smaller than the maximum should be stretched and in which direction.

Contextual Arguments

When elements is a list of element names, these element names will override the element contextual argument before element-image is called.

sum

Returns the sum of several values.

Arguments

  • elements A list that contains either plain element names or function call blocks.
  • function The function to call for each element when elements contains plain element names.
  • multiplier A multiplier to multiply the result by.

Contextual Arguments

When elements is a list of element names, these element names will override the element contextual argument before function is called.

font-name

Return a font by name.

Arguments

  • name The name of a font. The following names are recognised:
    • system-normal The default system font.
    • system-fixed The default system fixed-width font.
    • system-small The system's small font.
    • system-toolbar The system's toolbar font.
    • system-menu The system's menu font.
    • system-window The system's window font.

icon-size

Return an icon size by name.

Arguments

  • name The name of the icon size. The following names are recognised:
    • small
    • small-medium
    • medium
    • large
    • huge
    • enormous

named-value

Return a specific named value.

Arguments

  • name The name of the value. The following names are recognised:
    • small-spacing
    • medium-spacing
    • large-spacing
    • grid-unit
  • multiplier A multiplier to apply to the value.