/usr/lib/x86_64-linux-gnu/qt5/qml/Ubuntu/Components/ListItems/1.3/ValueSelector.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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | /*
* Copyright 2015 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
import Ubuntu.Components 1.3
/*!
****DEPRECATED! PLEASE USE ITEM SELECTOR OR FOR THE UBUNTU SHAPE VERSION THE OPTION SELECTOR.****
\qmltype ValueSelector
\inqmlmodule Ubuntu.Components.ListItems 1.0
\ingroup ubuntu-listitems
\brief List item displaying single selected value when not expanded,
where expanding it opens a listing of all the possible values for selection.
Examples:
\qml
import Ubuntu.Components.ListItems 1.3 as ListItem
Column {
width: 250
ListItem.ValueSelector {
text: "Standard"
values: ["Value 1", "Value 2", "Value 3", "Value 4"]
}
ListItem.ValueSelector {
text: "Disabled"
values: ["Value 1", "Value 2", "Value 3", "Value 4"]
enabled: false
}
ListItem.ValueSelector {
text: "Expanded"
values: ["Value 1", "Value 2", "Value 3", "Value 4"]
expanded: true
}
ListItem.ValueSelector {
text: "Icon"
iconName: "compose"
values: ["Value 1", "Value 2", "Value 3", "Value 4"]
selectedIndex: 2
}
}
\endqml
*/
Empty {
id: selector
__height: column.height
/*!
The text that is shown in the list item as a label.
\qmlproperty string text
*/
/*!
\deprecated
\b{Use iconName or iconSource instead.}
The location of the icon to show in the list item (optional), or an Item that is
shown on the left side inside the list item. The icon will automatically be
anchored to the left side of the list item, and if its height is undefined, to the top
and bottom of the list item.
\qmlproperty variant icon
*/
property alias icon: selectorMain.icon
/*!
The location of the icon to show in the list item if iconSource failed to load (optional).
\qmlproperty url fallbackIconSource
*/
property alias fallbackIconSource: selectorMain.fallbackIconSource
/*!
The icon shown in the list item if iconName failed to load (optional).
\qmlproperty string fallbackIconName
If both fallbackIconSource and fallbackIconName are defined, fallbackIconName will be ignored.
\note The complete list of icons available in Ubuntu is not published yet.
For now please refer to the folders where the icon themes are installed:
\list
\li Ubuntu Touch: \l file:/usr/share/icons/suru
\li Ubuntu Desktop: \l file:/usr/share/icons/ubuntu-mono-dark
\endlist
These 2 separate icon themes will be merged soon.
*/
property alias fallbackIconName: selectorMain.fallbackIconName
/*!
\internal
\deprecated
Width of the icon to be displayed
*/
property real __iconWidth
/*!
\internal
\deprecated
Height of the icon to be displayed
*/
property real __iconHeight
/*!
\internal
\deprecated
The margins on the left side of the icon.
*/
property real __leftIconMargin
/*!
\internal
\deprecated
The margins on the right side of the icon.
*/
property real __rightIconMargin
/*!
Show or hide the frame around the icon
\qmlproperty bool iconFrame
*/
property alias iconFrame: selectorMain.iconFrame
/*!
The list of values that will be shown under the label text
*/
property variant values
/*!
The index of the currently selected element from the \l values array.
*/
property int selectedIndex: 0
/*!
Specifies whether the selector is 'open' or 'closed'.
*/
property bool expanded: false
showDivider: false
Column {
id: column
anchors {
left: parent.left
right: parent.right
topMargin: units.dp(2)
bottomMargin: units.dp(2)
}
Base {
id: selectorMain
height: units.gu(6)
showDivider: true
onClicked: selector.expanded = !selector.expanded
selected: selector.selected
iconSource: selector.iconSource
LabelVisual {
id: label
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
}
text: selector.text
width: Math.min(implicitWidth, parent.width * 0.8)
}
LabelVisual {
id: valueLabel
anchors {
verticalCenter: parent.verticalCenter
right: accordion.left
rightMargin: selector.__contentsMargins
leftMargin: selector.__contentsMargins
left: label.right
}
textSize: Label.Small
text: selector.values[selector.selectedIndex]
font.bold: selector.expanded
horizontalAlignment: Text.AlignRight
}
Item {
id: accordion
width: accordionIcon.width
anchors {
right: parent.right
top: parent.top
bottom: parent.bottom
}
Image {
id: accordionIcon
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
source: Qt.resolvedUrl("../../artwork/chevron.png")
opacity: enabled ? 1.0 : 0.5
rotation: expanded ? 270 : 90
width: implicitWidth / 1.5
height: implicitHeight / 1.5
states: [
State {
name: "expanded"
when: selector.expanded
PropertyChanges { target: accordionIcon; rotation: 270 }
}, State {
name: "closed"
when: !selector.expanded
PropertyChanges { target: accordionIcon; rotation: 90 }
}
]
transitions: Transition {
UbuntuNumberAnimation {
target: accordionIcon
properties: "rotation"
duration: UbuntuAnimation.SnapDuration
}
}
}
}
}
Repeater {
id: valueRepeater
property int valueHeight: selector.expanded ? units.gu(5) : 0
states: [ State {
name: "expanded"
when: selector.expanded
PropertyChanges {
target: valueRepeater
valueHeight: units.gu(5)
}
}, State {
name: "closed"
when: !selector.expanded
PropertyChanges {
target: valueRepeater
valueHeight: 0
}
}
]
transitions: Transition {
UbuntuNumberAnimation {
target: valueRepeater
properties: "valueHeight"
duration: UbuntuAnimation.SnapDuration
}
}
model: selector.values
Rectangle {
color: Qt.lighter(theme.palette.normal.base)
height: valueRepeater.valueHeight
width: parent.width
Empty {
id: valueBase
height: parent.height
visible: valueBase.height > 0
onClicked: {
selector.selectedIndex = index
selector.expanded = false
}
selected: index === selector.selectedIndex
LabelVisual {
text: modelData
anchors {
left: parent.left
leftMargin: units.gu(3)
verticalCenter: parent.verticalCenter
}
font.bold: valueBase.selected
property real heightMargin: valueBase.height - implicitHeight
visible: heightMargin > 0
// fade in/out the values when expanding/contracting the selector.
opacity: heightMargin < 10 ? heightMargin/10 : 1
}
}
}
}
}
}
|