| 1 |
/* |
| 2 |
* Copyright (C) 2015 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.4 |
| 18 |
import Lomiri.Components |
| 19 |
|
| 20 |
/*! |
| 21 |
\qmltype ToolbarButton |
| 22 |
\inqmlmodule Lomiri.Components |
| 23 |
\ingroup lomiri |
| 24 |
\deprecated |
| 25 |
\brief An \l ActionItem that represents a button in the toolbar. |
| 26 |
ToolbarButtons should be included in \l ToolbarItems to define the tools of a \l Page. |
| 27 |
The behavior and look of the toolbar button can be specified by setting an \l Action for |
| 28 |
the button, or by setting the other properties inherited by the \l ActionItem. |
| 29 |
|
| 30 |
Example of different ways to define the toolbar button: |
| 31 |
\qml |
| 32 |
import QtQuick 2.4 |
| 33 |
import Lomiri.Components 1.2 |
| 34 |
|
| 35 |
MainView { |
| 36 |
width: units.gu(50) |
| 37 |
height: units.gu(80) |
| 38 |
|
| 39 |
Action { |
| 40 |
id: action1 |
| 41 |
text: "action 1" |
| 42 |
iconName: "compose" |
| 43 |
onTriggered: print("one!") |
| 44 |
} |
| 45 |
|
| 46 |
Page { |
| 47 |
title: "test page" |
| 48 |
|
| 49 |
Label { |
| 50 |
anchors.centerIn: parent |
| 51 |
text: "Hello, world" |
| 52 |
} |
| 53 |
|
| 54 |
tools: ToolbarItems { |
| 55 |
// reference to an action: |
| 56 |
ToolbarButton { |
| 57 |
action: action1 |
| 58 |
} |
| 59 |
|
| 60 |
// define the action: |
| 61 |
ToolbarButton { |
| 62 |
action: Action { |
| 63 |
text: "Second action" |
| 64 |
iconName: "add" |
| 65 |
onTriggered: print("two!") |
| 66 |
} |
| 67 |
// override the text of the action: |
| 68 |
text: "action 2" |
| 69 |
} |
| 70 |
|
| 71 |
// no associated action: |
| 72 |
ToolbarButton { |
| 73 |
iconName: "cancel" |
| 74 |
text: "button" |
| 75 |
onTriggered: print("three!") |
| 76 |
} |
| 77 |
} |
| 78 |
} |
| 79 |
} |
| 80 |
\endqml |
| 81 |
See \l ToolbarItems for more information on how to use ToolbarButton. |
| 82 |
*/ |
| 83 |
ActionItem { |
| 84 |
id: toolbarButton |
| 85 |
height: parent ? parent.height : undefined |
| 86 |
width: units.gu(5) |
| 87 |
|
| 88 |
styleName: "ToolbarButtonStyle" |
| 89 |
} |