← Back to team overview

ubuntu-touch-coreapps team mailing list archive

Fwd: UITK API update: Toolbar

 

---------- Forwarded message ----------
From: Tim Peeters <tim.peeters@xxxxxxxxxxxxx>
Date: Wed, Jun 19, 2013 at 3:33 PM
Subject: UITK API update: Toolbar
To: ubuntu-phone@xxxxxxxxxxxxxxxxxxx


Hello,

Today there will be an update of the toolbar-related code in the
ubuntu-ui-toolkit that will give you a new API for defining the toolbar.

* CHANGED in Page: property ToolbarActions tools TO property Item tools
* CHANGED IN Toolbar: property ToolbarActions tools TO property Item tools
* DEPRECATED IN Action: property bool visible
* DEPRECATED IN Action: property Item itemHint
* DEPRECATED: ToolbarActions component (use ToolbarItems instead)

If you are using the properties/type that are deprecated, your code will
still work as before, but there will be a warning message when you use the
properties.
There are new ToolbarItems and ToolbarButton components that you can use as
follows:

---------- example code ----------
import QtQuick 2.0
import Ubuntu.Components 0.1

MainView {
    width: units.gu(50)
    height: units.gu(80)

    Action {
        id: action1
        text: "action 1"
        iconSource: Qt.resolvedUrl("icon1.png")
        onTriggered: print("one!")
    }

    Page {
        title: "test page"

        Label {
            anchors.centerIn: parent
            text: "Hello, world"
        }

        tools: ToolbarItems {
            // reference to an action:
            ToolbarButton {
                action: action1
            }

            // define the action:
            ToolbarButton {
                action: Action {
                    text: "Second action"
                    iconSource: Qt.resolvedUrl("icon2.png")
                    onTriggered: print("two!")
                }
                // override the text of the action:
                text: "action 2"
            }

            // no associated action:
            ToolbarButton {
                iconSource: Qt.resolvedUrl("icon3.png")
                text: "button"
                onTriggered: print("three!")
            }
        }
    }
}

----------------------------------

For more examples, check the documentation of ToolbarButton and
ToolbarItems.
It should be relatively straightforward to start using the new API. When
you start using the new API, install the ubuntu-ui-toolkit-doc for the
latest documentation, because the online documentation may not always be
up-to-date.

With the new API we are preparing for a new Action backend that will make
it easy to make Actions available to the HUD, and it makes it more
straightforward to write autopilot tests for toolbar buttons because you
can now name the ToolbarButton and refer to it directly instead of
depending on the internals of the Toolbar implementation to find the
buttons.

If there are any questions, ping me (timp or t1mp) or IRC.

Greets,
Tim.