on xenial help sign in
Merge
commit546aeef5a6511f4549d3419f32da7d8c7e65c615 authorAlbert Astals <albert.astals@canonical.com> dateThu 7 Aug 2014, 10:37 (12 years ago) parentf581fca737e6c0
12 files changed+146−95
plugins/Dash/ScopeStyle.qml+12−9 qml/Components/PageHeader.qml+1−14 qml/Dash/Dash.qml+67−1 qml/Dash/DashContent.qml+2 qml/Dash/DashNavigationList.qml−5 qml/Dash/GenericScopeView.qml+2−1 qml/Dash/PreviewListView.qml+23−27 tests/autopilot/unity8/shell/emulators/dash.py+1−1 tests/plugins/Dash/tst_ScopeStyle.qml+14−7 tests/qmltests/Components/tst_PageHeader.qml−23 tests/qmltests/Dash/tst_Dash.qml+23−6 tests/qmltests/Dash/tst_GenericScopeView.qml+1−1
plugins/Dash/ScopeStyle.qml+12−9
@@ -38,15 +38,21 @@ QtObject {
3838 /// Color used for text and symbolic icons
3939 readonly property color foreground: "foreground-color" in style ? style["foreground-color"] : d.defaultDark
4040
41+ /// Luminance of the foreground color
42+ readonly property real foregroundLuminance: foreground ? luminance(foreground) : d.defaultForegroundLuminance
43+
4144 /// Color used for the overall background
4245 readonly property color background: "background-color" in style ? style["background-color"] : "transparent"
4346
47+ /// Luminance of the foreground color
48+ readonly property real backgroundLuminance: background ? luminance(background) : d.defaultBackgroundLuminance
49+
4450 /*! \brief Luminance threshold for switching between fore and background color
4551
4652 \note If background colour is not fully opaque, the defaultLightLuminance it's taken into account instead of it.
4753 */
48− readonly property real threshold: background.a !== 1.0 ? (d.foregroundLuminance + d.defaultLightLuminance) / 2
49− : (d.foregroundLuminance + d.backgroundLuminance) / 2
54+ readonly property real threshold: background.a !== 1.0 ? (foregroundLuminance + d.defaultLightLuminance) / 2
55+ : (foregroundLuminance + backgroundLuminance) / 2
5056
5157 /*! \brief The lighter of foreground and background colors
5258
@@ -54,8 +60,8 @@ QtObject {
5460 and defaults to the theme-provided light color.
5561 */
5662 readonly property color light: {
57− if (background.a !== 1.0) return d.foregroundLuminance > d.defaultLightLuminance ? foreground : d.defaultLight;
58− return d.foregroundLuminance > d.backgroundLuminance ? foreground : background;
63+ if (background.a !== 1.0) return foregroundLuminance > d.defaultLightLuminance ? foreground : d.defaultLight;
64+ return foregroundLuminance > backgroundLuminance ? foreground : background;
5965 }
6066
6167 /*! \brief The darker of foreground and background colors
@@ -64,8 +70,8 @@ QtObject {
6470 and defaults to the theme-provided dark color.
6571 */
6672 readonly property color dark: {
67− if (background.a !== 1.0) return d.foregroundLuminance < d.defaultDarkLuminance ? foreground : d.defaultDark;
68− return d.foregroundLuminance < d.backgroundLuminance ? foreground : background;
73+ if (background.a !== 1.0) return foregroundLuminance < d.defaultDarkLuminance ? foreground : d.defaultDark;
74+ return foregroundLuminance < backgroundLuminance ? foreground : background;
6975 }
7076
7177 /// Source of the logo image for the header
@@ -79,9 +85,6 @@ QtObject {
7985
8086 //! @cond
8187 property var d: QtObject {
82− readonly property real foregroundLuminance: luminance(foreground)
83− readonly property real backgroundLuminance: luminance(background)
84−
8588 // FIXME: should be taken from the theme
8689 readonly property color defaultLight: "white"
8790 readonly property color defaultDark: "grey"
qml/Components/PageHeader.qml+1−14
@@ -32,7 +32,6 @@ Item {
3232 property bool searchEntryEnabled: false
3333 property ListModel searchHistory: SearchHistoryModel
3434 property alias searchQuery: searchTextField.text
35− property bool searchInProgress: false
3635 property alias showSignatureLine: bottomBorder.visible
3736
3837 property alias bottomItem: bottomContainer.children
@@ -204,25 +203,13 @@ Item {
204203 anchors.fill: parent
205204 anchors.margins: units.gu(.75)
206205 source: "image://theme/clear"
207− opacity: searchTextField.text.length > 0 && !searchActivityIndicator.running
206+ opacity: searchTextField.text.length > 0
208207 visible: opacity > 0
209208 Behavior on opacity {
210209 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
211210 }
212211 }
213212
214− ActivityIndicator {
215− id: searchActivityIndicator
216− objectName: "searchIndicator"
217− anchors.fill: parent
218− anchors.margins: units.gu(.75)
219− running: root.searchInProgress
220− opacity: running ? 1 : 0
221− Behavior on opacity {
222− UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
223− }
224− }
225−
226213 onClicked: {
227214 root.resetSearch(true);
228215 root.openSearchHistory();
qml/Dash/Dash.qml+67−1
@@ -14,7 +14,7 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−import QtQuick 2.0
17+import QtQuick 2.2
1818import Ubuntu.Components 0.1
1919import Ubuntu.Gestures 0.1
2020import Unity 0.2
@@ -260,6 +260,72 @@ Showable {
260260 }
261261 }
262262
263+ Rectangle {
264+ id: indicator
265+ objectName: "processingIndicator"
266+ anchors {
267+ left: parent.left
268+ right: parent.right
269+ bottom: parent.bottom
270+ }
271+ height: units.dp(3)
272+ color: scopeStyle.backgroundLuminance > 0.7 ? "#50000000" : "#50ffffff"
273+ opacity: 0
274+ visible: opacity > 0
275+
276+ readonly property bool processing: dashContent.processing || scopeItem.processing
277+
278+ Behavior on opacity {
279+ UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
280+ }
281+
282+ onProcessingChanged: {
283+ if (processing) delay.start();
284+ else if (!persist.running) indicator.opacity = 0;
285+ }
286+
287+ Timer {
288+ id: delay
289+ interval: 200
290+ onTriggered: if (indicator.processing) {
291+ persist.restart();
292+ indicator.opacity = 1;
293+ }
294+ }
295+
296+ Timer {
297+ id: persist
298+ interval: 2 * UbuntuAnimation.SleepyDuration - UbuntuAnimation.FastDuration
299+ onTriggered: if (!indicator.processing) indicator.opacity = 0
300+ }
301+
302+ Rectangle {
303+ id: orange
304+ anchors { top: parent.top; bottom: parent.bottom }
305+ width: parent.width / 4
306+ color: Theme.palette.selected.foreground
307+
308+ SequentialAnimation {
309+ running: indicator.visible
310+ loops: Animation.Infinite
311+ XAnimator {
312+ from: -orange.width / 2
313+ to: indicator.width - orange.width / 2
314+ duration: UbuntuAnimation.SleepyDuration
315+ easing.type: Easing.InOutSine
316+ target: orange
317+ }
318+ XAnimator {
319+ from: indicator.width - orange.width / 2
320+ to: -orange.width / 2
321+ duration: UbuntuAnimation.SleepyDuration
322+ easing.type: Easing.InOutSine
323+ target: orange
324+ }
325+ }
326+ }
327+ }
328+
263329 EdgeDragArea {
264330 id: overviewDragHandle
265331 objectName: "overviewDragHandle"
qml/Dash/DashContent.qml+2
@@ -29,6 +29,8 @@ Item {
2929 readonly property var currentScope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null
3030 readonly property bool previewShown: dashContentList.currentItem && dashContentList.currentItem.item ?
3131 dashContentList.currentItem.item.previewShown : false
32+ readonly property bool processing: dashContentList.currentItem && dashContentList.currentItem.item
33+ && dashContentList.currentItem.item.processing || false
3234
3335 signal scopeLoaded(string scopeId)
3436 signal gotoScope(string scopeId)
qml/Dash/DashNavigationList.qml−5
@@ -35,11 +35,6 @@ Item {
3535 anchors.fill: parent
3636 }
3737
38− ActivityIndicator {
39− id: loadingIndicator
40− anchors.centerIn: parent
41− running: !(navigation && navigation.loaded)
42− }
4338 clip: true
4439
4540 Behavior on height {
qml/Dash/GenericScopeView.qml+2−1
@@ -42,6 +42,8 @@ FocusScope {
4242 style: scope ? scope.customizations : {}
4343 }
4444
45+ readonly property bool processing: scope ? scope.searchInProgress || previewListView.processing : false
46+
4547 signal backClicked()
4648
4749 function positionAtBeginning() {
@@ -414,7 +416,6 @@ FocusScope {
414416 title: scopeView.scope ? scopeView.scope.name : ""
415417 showBackButton: scopeView.hasBackAction
416418 searchEntryEnabled: true
417− searchInProgress: scopeView.scope ? scopeView.scope.searchInProgress : false
418419 scopeStyle: scopeView.scopeStyle
419420
420421 bottomItem: DashNavigation {
qml/Dash/PreviewListView.qml+23−27
@@ -32,6 +32,9 @@ Item {
3232 property alias currentItem: previewListView.currentItem
3333 property alias count: previewListView.count
3434
35+ readonly property bool processing: currentItem && (!currentItem.previewModel.loaded
36+ || currentItem.previewModel.processingAction)
37+
3538 PageHeader {
3639 id: header
3740 objectName: "pageHeader"
@@ -83,39 +86,32 @@ Item {
8386 }
8487 }
8588
86− delegate: Item {
87− objectName: "previewItem" + index
89+ delegate: Previews.Preview {
90+ id: preview
91+ objectName: "preview" + index
8892 height: previewListView.height
8993 width: previewListView.width
9094
91− readonly property bool ready: preview.previewModel && preview.previewModel.loaded
92−
93− Previews.Preview {
94− id: preview
95− objectName: "preview" + index
96− anchors.fill: parent
95+ isCurrent: ListView.isCurrentItem
9796
98− isCurrent: parent.ListView.isCurrentItem
99−
100− previewModel: {
101− var previewStack = root.scope.preview(result);
102− return previewStack.getPreviewModel(0);
103− }
104− scopeStyle: root.scopeStyle
97+ previewModel: {
98+ var previewStack = root.scope.preview(result);
99+ return previewStack.getPreviewModel(0);
105100 }
101+ scopeStyle: root.scopeStyle
102+ }
103+ }
106104
107− MouseArea {
108− id: processingMouseArea
109− objectName: "processingMouseArea"
110− anchors.fill: parent
111− enabled: preview.previewModel && (!preview.previewModel.loaded || preview.previewModel.processingAction)
112−
113− ActivityIndicator {
114− anchors.centerIn: parent
115− visible: root.open && parent.enabled
116− running: visible
117− }
118− }
105+ MouseArea {
106+ id: processingMouseArea
107+ objectName: "processingMouseArea"
108+ anchors {
109+ left: parent.left
110+ right: parent.right
111+ top: pageHeader.bottom
112+ bottom: parent.bottom
119113 }
114+
115+ enabled: root.processing
120116 }
121117}
tests/autopilot/unity8/shell/emulators/dash.py+1−1
@@ -150,7 +150,7 @@ class Dash(emulators.UnityEmulatorBase):
150150 headerContainer.contentY.wait_for(0)
151151 search_text_field = self._get_search_text_field()
152152 search_text_field.write(query)
153− current_header.select_single(objectName="searchIndicator").running.wait_for(False)
153+ self.select_single(objectName="processingIndicator").visible.wait_for(False)
154154
155155 def _get_search_text_field(self):
156156 page_header = self._get_current_page_header()
tests/plugins/Dash/tst_ScopeStyle.qml+14−7
@@ -54,6 +54,9 @@ Rectangle {
5454 { tag: "lightgrey", luminance: 0.8275 },
5555 { tag: "grey", luminance: 0.5020 },
5656 { tag: "darkgrey", luminance: 0.6627 },
57+ { tag: "red", luminance: 0.2126 },
58+ { tag: "green", luminance: 0.3590 },
59+ { tag: "blue", luminance: 0.0722 },
5760 ];
5861 }
5962
@@ -64,10 +67,10 @@ Rectangle {
6467
6568 function test_foreground_data() {
6669 return [
67− { tag: "default", index: 0, foreground: "grey" },
68− { tag: "red on black", index: 1, foreground: "red" },
69− { tag: "green on white", index: 2, foreground: "green" },
70− { tag: "blue on darkgrey", index: 3, foreground: "blue" },
70+ { tag: "default", index: 0, foreground: "grey", luminance: 0.5020 },
71+ { tag: "red on black", index: 1, foreground: "red", luminance: 0.2126 },
72+ { tag: "green on white", index: 2, foreground: "green", luminance: 0.3590 },
73+ { tag: "blue on darkgrey", index: 3, foreground: "blue", luminance: 0.0722 },
7174 ];
7275 }
7376
@@ -75,14 +78,15 @@ Rectangle {
7578 tool.style = testCase.styles[data.index];
7679 verify(Qt.colorEqual(tool.foreground, data.foreground),
7780 "Foreground color not equal: %1 != %2".arg(tool.foreground).arg(data.foreground));
81+ compare(tool.foregroundLuminance.toFixed(4), data.luminance.toFixed(4));
7882 }
7983
8084 function test_background_data() {
8185 return [
8286 { tag: "default", index: 0, background: "transparent" },
83− { tag: "red on black", index: 1, background: "black" },
84− { tag: "green on white", index: 2, background: "white" },
85− { tag: "blue on darkgrey", index: 3, background: "darkgrey" },
87+ { tag: "red on black", index: 1, background: "black", luminance: 0 },
88+ { tag: "green on white", index: 2, background: "white", luminance: 1 },
89+ { tag: "blue on darkgrey", index: 3, background: "darkgrey", luminance: 0.6627 },
8690 ];
8791 }
8892
@@ -90,6 +94,9 @@ Rectangle {
9094 tool.style = testCase.styles[data.index];
9195 verify(Qt.colorEqual(tool.background, data.background),
9296 "Background color not equal: %1 != %2".arg(tool.background).arg(data.background));
97+ if (data.hasOwnProperty("luminance")) {
98+ compare(tool.backgroundLuminance.toFixed(4), data.luminance.toFixed(4));
99+ }
93100 }
94101
95102 function test_threshold_data() {
tests/qmltests/Components/tst_PageHeader.qml−23
@@ -119,29 +119,6 @@ Item {
119119 compare(pageHeader.searchHistory.get(0).query, "humppa4")
120120 }
121121
122− function test_search_indicator() {
123− var searchIndicator = findChild(pageHeader, "searchIndicator")
124− var clearIcon = findChild(pageHeader, "clearIcon")
125−
126− pageHeader.triggerSearch()
127−
128− tryCompare(clearIcon, "visible", false)
129− pageHeader.searchQuery = "ubuntu"
130− tryCompare(clearIcon, "visible", true)
131−
132− pageHeader.searchInProgress = false
133− compare(searchIndicator.running, false, "Search indicator is running.")
134− tryCompare(clearIcon, "visible", true)
135−
136− pageHeader.searchInProgress = true
137− compare(searchIndicator.running, true, "Search indicator isn't running.")
138− tryCompare(clearIcon, "visible", false)
139−
140− pageHeader.searchInProgress = false;
141− compare(searchIndicator.running, false, "Search indicator is running.")
142− tryCompare(clearIcon, "visible", true)
143− }
144−
145122 function test_titleImage() {
146123
147124 var titleImage = findChild(pageHeader, "titleImage");
tests/qmltests/Dash/tst_Dash.qml+23−6
@@ -43,12 +43,8 @@ Item {
4343 name: "Dash"
4444 when: windowShown
4545
46− property var scopes
47−
48− Component.onCompleted: {
49− var dashContent = findChild(dash, "dashContent");
50− scopes = dashContent.scopes;
51− }
46+ readonly property Item dashContent: findChild(dash, "dashContent");
47+ readonly property var scopes: dashContent.scopes
5248
5349 function init() {
5450 // clear and reload the scopes.
@@ -321,5 +317,26 @@ Item {
321317 dashCommunicatorService.mockSetCurrentScope("clickscope", true, true);
322318 tryCompare(dashContentList, "currentIndex", 1)
323319 }
320+
321+ function test_processing_indicator() {
322+ tryCompare(scopes, "loaded", true);
323+
324+ var processingIndicator = findChild(dash, "processingIndicator");
325+ verify(processingIndicator, "Can't find the processing indicator.");
326+
327+ verify(!processingIndicator.visible, "Processing indicator should be visible.");
328+
329+ tryCompareFunction(function() {
330+ return scopes.getScope(dashContent.currentIndex) != null;
331+ }, true);
332+ var currentScope = scopes.getScope(dashContent.currentIndex);
333+ verify(currentScope, "Can't find the current scope.");
334+
335+ currentScope.setSearchInProgress(true);
336+ tryCompare(processingIndicator, "visible", true);
337+
338+ currentScope.setSearchInProgress(false);
339+ tryCompare(processingIndicator, "visible", false);
340+ }
324341 }
325342}
tests/qmltests/Dash/tst_GenericScopeView.qml+1−1
@@ -320,7 +320,7 @@ Item {
320320 units.gu(2),
321321 testCase.previewListView.height / 2);
322322 tryCompare(previewListViewList, "moving", false);
323− tryCompare(testCase.previewListView.currentItem, "objectName", "previewItem" + i);
323+ tryCompare(testCase.previewListView.currentItem, "objectName", "preview" + i);
324324
325325 }
326326 closePreview();