on xenial help sign in
Drop __-prefixed private properties, moving them into a QtObject
7040db0Michael Terry
Components/DemoOverlay.qml+16−15
@@ -48,23 +48,17 @@ Showable {
48 */
48 */
49 readonly property bool active: available && visible
49 readonly property bool active: available && visible
50
50
51− property color __orange_transparent: Qt.hsla(16.0/360.0, 0.83, 0.47, 0.4)
52− property int __edge_margin: units.gu(4)
53− property int __text_margin: units.gu(3)
54− property bool __skip_on_hide: false
55− property int __anim_running: wholeAnimation.running // for testing
56−
57 signal skip()
51 signal skip()
58
52
59 function doSkip() {
53 function doSkip() {
60− __skip_on_hide = true;
54+ d.skipOnHide = true;
61 hide();
55 hide();
62 }
56 }
63
57
64 function hideNow() {
58 function hideNow() {
65 overlay.visible = false;
59 overlay.visible = false;
66 overlay.available = false;
60 overlay.available = false;
67− if (overlay.__skip_on_hide) {
61+ if (d.skipOnHide) {
68 overlay.skip();
62 overlay.skip();
69 }
63 }
70 }
64 }
@@ -81,6 +75,12 @@ Showable {
81 onRunningChanged: if (!running) overlay.hideNow()
75 onRunningChanged: if (!running) overlay.hideNow()
82 }
76 }
83
77
78+ QtObject {
79+ id: d
80+ property bool skipOnHide: false
81+ property int edgeMargin: units.gu(4)
82+ }
83+
84 Rectangle {
84 Rectangle {
85 anchors.fill: parent
85 anchors.fill: parent
86 color: "black"
86 color: "black"
@@ -105,10 +105,10 @@ Showable {
105 Column {
105 Column {
106 id: labelGroup
106 id: labelGroup
107 layer.enabled: true // otherwise the underlining on "Skip intro" jumps
107 layer.enabled: true // otherwise the underlining on "Skip intro" jumps
108− spacing: overlay.__text_margin
108+ spacing: units.gu(3)
109
109
110 anchors {
110 anchors {
111− margins: overlay.__edge_margin
111+ margins: d.edgeMargin
112 left: parent.left
112 left: parent.left
113 top: overlay.edge == "bottom" ? undefined : parent.top
113 top: overlay.edge == "bottom" ? undefined : parent.top
114 bottom: overlay.edge == "bottom" ? parent.bottom : undefined
114 bottom: overlay.edge == "bottom" ? parent.bottom : undefined
@@ -150,7 +150,7 @@ Showable {
150 gradient: Gradient {
150 gradient: Gradient {
151 GradientStop {
151 GradientStop {
152 position: 0.0
152 position: 0.0
153− color: overlay.__orange_transparent
153+ color: Qt.hsla(16.0/360.0, 0.83, 0.47, 0.4) // UbuntuColors.orange, but transparent
154 }
154 }
155 GradientStop {
155 GradientStop {
156 position: 1.0
156 position: 1.0
@@ -185,6 +185,7 @@ Showable {
185
185
186 SequentialAnimation {
186 SequentialAnimation {
187 id: wholeAnimation
187 id: wholeAnimation
188+ objectName: "wholeAnimation"
188 running: overlay.active
189 running: overlay.active
189
190
190 ParallelAnimation {
191 ParallelAnimation {
@@ -203,12 +204,12 @@ Showable {
203 }
204 }
204 from: {
205 from: {
205 if (overlay.edge == "right") {
206 if (overlay.edge == "right") {
206− return overlay.__edge_margin + units.gu(3)
207+ return d.edgeMargin + units.gu(3)
207 } else {
208 } else {
208− return overlay.__edge_margin - units.gu(3)
209+ return d.edgeMargin - units.gu(3)
209 }
210 }
210 }
211 }
211− to: overlay.__edge_margin
212+ to: d.edgeMargin
212 duration: overlay.edge == "none" ? 0 : UbuntuAnimation.SleepyDuration
213 duration: overlay.edge == "none" ? 0 : UbuntuAnimation.SleepyDuration
213 }
214 }
214 StandardAnimation {
215 StandardAnimation {
@@ -251,7 +252,7 @@ Showable {
251 if (status == Powerd.Off && wholeAnimation.running) {
252 if (status == Powerd.Off && wholeAnimation.running) {
252 wholeAnimation.pause();
253 wholeAnimation.pause();
253 } else if (status == Powerd.On) {
254 } else if (status == Powerd.On) {
254− wholeAnimation.pause();
255+ wholeAnimation.resume();
255 }
256 }
256 }
257 }
257 }
258 }
tests/qmltests/Components/tst_DemoOverlay.qml+5−3
@@ -79,11 +79,13 @@ Item {
79 when: windowShown
79 when: windowShown
80
80
81 function test_animations() {
81 function test_animations() {
82− compare(right.__anim_running, 1)
82+ var rightAnim = findChild(right, "wholeAnimation")
83+ compare(rightAnim.running, true)
83
84
84− compare(left.__anim_running, 0)
85+ var leftAnim = findChild(left, "wholeAnimation")
86+ compare(leftAnim.running, false)
85 left.available = true
87 left.available = true
86− compare(left.__anim_running, 1)
88+ compare(leftAnim.running, true)
87 }
89 }
88
90
89 function test_skip() {
91 function test_skip() {