2 * Copyright (C) 2013,2014 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
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 General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18import Ubuntu.Components 1.1
24 // This is the header displayed, like "Right edge"
25 property alias title: titleLabel.text
27 // This is the block of text displayed below the header
28 property alias text: textLabel.text
30 // Whether animations are paused
33 // Whether to give the text the full width that the title has
34 property bool fullTextWidth
36 // Whether whole page (background + foreground) or just the foreground fades in
37 property bool backgroundFadesIn: false
39 // Whether whole page (background + foreground) or just the foreground fades out
40 property bool backgroundFadesOut: false
42 // The foreground Item, add children to it that you want to fade in
43 property alias foreground: foregroundExtra
45 // The text label bottom, so you can position elements relative to it
46 readonly property real textBottom: Math.max(textLabel.y + textLabel.height, errorTextLabel.y + errorTextLabel.height)
48 // The MouseArea that eats events (so you can adjust size as you will)
49 property alias mouseArea: mouseArea
51 // X/Y offsets for text
52 property real textXOffset: 0
53 property real textYOffset: 0
56 property real foregroundOpacity: 1
60 function showError() {
67 Component.onCompleted: show()
69 property real _foregroundHideOpacity
71 showAnimation: StandardAnimation {
72 property: root.backgroundFadesIn ? "opacity" : "_foregroundHideOpacity"
75 duration: root.backgroundFadesIn ? UbuntuAnimation.SleepyDuration : UbuntuAnimation.BriskDuration
78 hideAnimation: StandardAnimation {
79 property: root.backgroundFadesOut ? "opacity" : "_foregroundHideOpacity"
81 duration: UbuntuAnimation.BriskDuration
92 readonly property real sideMargin: units.gu(5.5)
93 readonly property real verticalOffset: -units.gu(9)
94 readonly property real textXOffset: Math.max(0, root.textXOffset - sideMargin + units.gu(2))
96 property real fadeInOffset: {
97 if (showAnimation.running) {
98 var opacity = root[root.showAnimation.property]
99 return (1 - opacity) * units.gu(3);
111 MouseArea { // eat any errant presses
125 opacity: root.foregroundOpacity < 1 ? root.foregroundOpacity : root._foregroundHideOpacity
130 top: parent.verticalCenter
131 topMargin: d.verticalOffset + root.textYOffset
133 leftMargin: d.sideMargin + d.textXOffset
135 width: parent.width - d.sideMargin * 2
136 horizontalAlignment: Text.AlignLeft
138 font.weight: Font.Light
139 font.pixelSize: units.gu(3.5)
145 top: titleLabel.bottom
146 topMargin: units.gu(2)
148 leftMargin: d.sideMargin + d.textXOffset
150 width: (parent.width - d.sideMargin * 2) * (fullTextWidth ? 1 : 0.66)
151 horizontalAlignment: Text.AlignLeft
153 font.weight: Font.Light
154 font.pixelSize: units.gu(2.5)
157 // We use two separate labels like this rather than just changing
158 // the text of the above labels because we want to know where to place
159 // sliders (via root.textBottom) without having that place change
160 // as the text changes length.
163 objectName: "errorTitleLabel"
166 left: titleLabel.left
168 width: titleLabel.width
169 horizontalAlignment: titleLabel.horizontalAlignment
170 wrapMode: titleLabel.wrapMode
171 font.weight: titleLabel.font.weight
172 font.pixelSize: titleLabel.font.pixelSize
174 text: i18n.tr("You almost got it!")
179 objectName: "errorTextLabel"
181 top: errorTitleLabel.bottom
182 topMargin: textLabel.anchors.topMargin
185 width: textLabel.width
186 horizontalAlignment: textLabel.horizontalAlignment
187 wrapMode: textLabel.wrapMode
188 font.weight: textLabel.font.weight
189 font.pixelSize: textLabel.font.pixelSize
191 text: i18n.tr("Try again.")
194 // A place for subclasses to add extra widgets
203 when: errorTimer.running
204 PropertyChanges { target: titleLabel; opacity: 0 }
205 PropertyChanges { target: textLabel; opacity: 0 }
206 PropertyChanges { target: errorTitleLabel; opacity: 1 }
207 PropertyChanges { target: errorTextLabel; opacity: 1 }
210 transitions: Transition {
213 SequentialAnimation {
218 duration: UbuntuAnimation.BriskDuration
223 duration: UbuntuAnimation.BriskDuration
228 target: errorTitleLabel
230 duration: UbuntuAnimation.BriskDuration
233 target: errorTextLabel
235 duration: UbuntuAnimation.BriskDuration
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list