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
|
/*
* 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 Lomiri.Components 1.3
Template {
id: page
header: PageHeader {
title: i18n.tr("Bottom Edge")
trailingActionBar.actions: [
bottomEdge.hint.action
]
}
TemplateSection {
title: "BottomEdgeHint"
className: "BottomEdgeHint"
TemplateRow {
title: i18n.tr("On clicked")
Row {
spacing: units.gu(1)
CheckBox {
id: contentToLayout
text: i18n.tr("push content into the column")
enabled: bottomEdge.hint.status >= BottomEdgeHint.Active
}
Label {
text: contentToLayout.text
anchors.verticalCenter: contentToLayout.verticalCenter
}
}
}
}
TemplateSection {
title: "BottomEdge"
className: "BottomEdge"
TemplateRow {
title: i18n.tr("Content")
Row {
spacing: units.gu(1)
CheckBox {
id: preloadContent
text: i18n.tr("preload content")
checked: bottomEdge.preloadContent
onTriggered: bottomEdge.preloadContent = checked
}
Label {
text: preloadContent.text
anchors.verticalCenter: preloadContent.verticalCenter
}
}
}
TemplateFlow {
title: i18n.tr("Top")
Slider {
id: bottomEdgeHeight
width: Math.min(units.gu(30), parent.width)
maximumValue: page.height
value: bottomEdge.height
onValueChanged: bottomEdge.height = value
}
}
TemplateFlow {
title: i18n.tr("Regions")
Slider {
id: regionCount
width: Math.min(units.gu(20), parent.width)
maximumValue: 3.0
live: true
}
}
Repeater {
id: regionConfig
model: regionCount.value.toFixed(0)
TemplateRow {
title: i18n.tr("Region #%1").arg(index)
property int regionIndex: index
Repeater {
model: ["from", "to"]
Row {
spacing: units.gu(2)
Label {
text: i18n.tr(modelData)
}
TextField {
id: regionFrom
text: bottomEdge.regions[regionIndex][modelData]
validator: DoubleValidator {bottom: 0.0; top: 1.0; decimals: 2; locale: "d.d"}
inputMethodHints: Qt.ImhPreferNumbers | Qt.ImhFormattedNumbersOnly
width: units.gu(7)
hasClearButton: false
errorHighlight: true
onAccepted: bottomEdge.regions[regionIndex][modelData] = text
onTextChanged: {
if (regionFrom.acceptableInput) {
bottomEdge.regions[regionIndex][modelData] = parseFloat(text);
}
}
onActiveFocusChanged: if (activeFocus) selectAll()
}
}
}
}
}
}
BottomEdge {
id: bottomEdge
// make sure it doesn't land inside the flickable
parent: page
// hint
hint {
action: Action {
text: "Demo content"
iconName: "stock_message"
onTriggered: bottomEdge.commit()
}
flickable: page.flickable
}
contentComponent: bottomEdgeContent
onCommitCompleted: {
if (contentToLayout.checked && contentToLayout.enabled) {
page.pageStack.addPageToCurrentColumn(page, contentComponent);
collapse();
}
}
regions: [
BottomEdgeRegion {
objectName: "CustomRegion1"
enabled: regionConfig.model >= 1
to: 0.3
property color baseColor: LomiriColors.silk
contentComponent: Rectangle {
PageHeader {
title: i18n.tr("CustomRegion #1")
}
width: bottomEdge.width - units.gu(10)
height: bottomEdge.height
color: LomiriColors.blue
}
},
BottomEdgeRegion {
objectName: "CustomRegion2"
enabled: regionConfig.model >= 2
from: 0.3
to: 0.6
contentComponent: Rectangle {
PageHeader {
title: i18n.tr("CustomRegion #2")
}
width: bottomEdge.width - units.gu(30)
height: bottomEdge.height
color: LomiriColors.red
}
},
BottomEdgeRegion {
objectName: "CustomRegion3"
enabled: regionConfig.model >= 3
from: 0.6
},
// default region, mimics the default setup
BottomEdgeRegion {
objectName: "DefaultRegion"
enabled: regionConfig.model <= 0
from: 0.3
}
]
Component {
id: bottomEdgeContent
Page {
height: bottomEdge.height
header: PageHeader {
title: {
var state = "UNDEFINED";
switch (bottomEdge.status) {
case BottomEdge.Hidden: state = "Hidden"; break;
case BottomEdge.Revealed: state = "Revealed"; break;
case BottomEdge.Committed: state = "Committed"; break;
}
return bottomEdge.activeRegion
? i18n.tr("Within region '%1', status: %2").arg(bottomEdge.activeRegion.objectName).arg(state)
: i18n.tr("Not in any active region, status: %1").arg(state);
}
}
Rectangle {
anchors.fill: parent
anchors.margins: units.gu(1)
color: bottomEdge.activeRegion && bottomEdge.activeRegion.hasOwnProperty("baseColor") ?
bottomEdge.activeRegion.baseColor : Qt.rgba(0.5, 1, bottomEdge.dragProgress, 1)
}
}
}
}
}
|