/usr/lib/x86_64-linux-gnu/qt5/qml/Ubuntu/Components/1.3/ToolbarItems.qml is in qml-module-ubuntu-components 1.3.1918+16.04.20160404-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | /*
* Copyright 2012 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.4
/*!
\qmltype ToolbarItems
\inqmlmodule Ubuntu.Components 1.1
\ingroup ubuntu
\deprecated
\brief Row of Items to be placed in a toolbar.
\b DEPRECATED: DO NOT USE THIS. USE \b head.actions IN \l Page INSTEAD.
Each \l Page has a tools property that can be set to change the tools of toolbar supplied
by \l MainView when the \l Page is active. Each ToolbarItems consists of a set of
Items and several properties that specify the behavior of the toolbar when the \l Page
is active.
When a \l Page is used inside a \l MainView, \l Tabs or \l PageStack, the toolbar will automatically show
the tools of the active \l Page. When the active \l Page inside the \l Tabs or \l PageStack
is updated by changing the selected \l Tab or by pushing/popping a \l Page on the \l PageStack,
the toolbar will automatically hide, except if the new active \l Page has the \l locked property set.
It is recommended to use \l ToolbarButton inside the ToolbarItems to define the buttons that will
be visible to the user:
\qml
import QtQuick 2.4
import Ubuntu.Components 1.3
MainView {
width: units.gu(50)
height: units.gu(50)
Page {
title: "Tools example"
Label {
anchors.centerIn: parent
text: "Custom back button\nToolbar locked"
}
tools: ToolbarItems {
ToolbarButton {
action: Action {
text: "button"
iconName: "compose"
onTriggered: print("success!")
}
}
locked: true
opened: true
}
}
}
\endqml
However, it is possible to include non-\l ToolbarButton Items inside ToolbarItems, and to mix
ToolbarButtons and other Items (for example standard Buttons). ToolbarButtons automatically span
the full height of the toolbar, and other Items you will probably want to center vertically:
\qml
import QtQuick 2.4
import Ubuntu.Components 1.3
MainView {
width: units.gu(50)
height: units.gu(50)
Page {
title: "Tools example"
Label {
anchors.centerIn: parent
text: "buttons!"
}
tools: ToolbarItems {
ToolbarButton {
action: Action {
text: "toolbar"
iconName: "compose"
onTriggered: print("success!")
}
}
Button {
anchors.verticalCenter: parent.verticalCenter
text: "standard"
}
}
}
}
\endqml
*/
Item {
id: toolbarItems
anchors.fill: parent
/*!
Default property, holds the content which will shown in the toolbar.
\qmlproperty list<Object> contents
*/
default property alias contents: toolsContainer.data
/*!
The back button. If it is visible, it will be shown on the left-side of the toolbar.
If there is a \l PageStack with depth greater than 1, the back button will be
visible and triggering it will pop the page on top of the stack. If there is no
\l PageStack with depth greater than 1, the back button is hidden by default
The following example shows how to have a classic cancel button that is always
visible in the toolbar, instead of the default toolbar-styled back button:
\qml
import QtQuick 2.4
import Ubuntu.Components 1.3
MainView {
width: units.gu(50)
height: units.gu(50)
Page {
title: "Custom back button"
tools: ToolbarItems {
back: Button {
text: "cancel"
}
}
}
}
\endqml
*/
property Item back: ToolbarButton {
objectName: "back_toolbar_button"
iconSource: Qt.resolvedUrl("../artwork/back.png")
text: i18n.dtr('ubuntu-ui-toolkit', "Back")
visible: toolbarItems.pageStack && toolbarItems.pageStack.depth > 1
/*!
If there is a \l PageStack of sufficient depth, triggering the back button
will pop the \l Page on top of the \l PageStack.
*/
onTriggered: if (toolbarItems.pageStack && toolbarItems.pageStack.depth > 1) toolbarItems.pageStack.pop()
}
/*!
PageStack for the back button. \l Page will automatically set the pageStack property
of its tools.
*/
property Item pageStack: null
/*!
The toolbar is opened.
When the toolbar is not locked, this value is automatically updated
when the toolbar is opened/closed by user interaction or by other events (such as changing
the active \l Page).
*/
property bool opened: false
/*!
The toolbar cannot be opened/closed by bottom-edge swipes.
If the ToolbarItems contains no visible Items, it is automatically
locked (in closed state).
*/
property bool locked: !internal.hasVisibleItems()
QtObject {
id: internal
/*
Determine whether this ToolbarItems has any visible Items
*/
function hasVisibleItems() {
if (back && back.visible) return true;
for (var i=0; i < toolsContainer.children.length; i++) {
if (toolsContainer.children[i].visible) return true;
}
return false;
}
}
Item {
id: backContainer
anchors {
left: parent.left
top: parent.top
bottom: parent.bottom
leftMargin: units.gu(2)
}
width: childrenRect.width
// internal link to the previous back Item to unset its parent
// when toolbarItems.back is updated.
property Item previousBackItem: null
function updateBackItem() {
if (backContainer.previousBackItem) backContainer.previousBackItem.parent = null;
backContainer.previousBackItem = toolbarItems.back;
if (toolbarItems.back) toolbarItems.back.parent = backContainer;
}
Connections {
target: toolbarItems
onBackChanged: backContainer.updateBackItem()
Component.onCompleted: backContainer.updateBackItem()
}
}
Row {
id: toolsContainer
anchors {
right: parent.right
bottom: parent.bottom
top: parent.top
rightMargin: units.gu(2)
}
spacing: units.gu(1)
}
}
|