on xenial help sign in
Disable the UI and show spinner until the scope responds
fc0771fDiego Sarmentero
Dash/DashPreview.qml+20
@@ -22,6 +22,7 @@ Rectangle {
22
22
23 property int keyboardSize: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
23 property int keyboardSize: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
24 property var previewData
24 property var previewData
25+ property alias showProcessingAction: waitingForAction.visible
25
26
26 property real previewWidthRatio: 0.5
27 property real previewWidthRatio: 0.5
27
28
@@ -196,4 +197,23 @@ Rectangle {
196 }
197 }
197 sourceComponent: root.header
198 sourceComponent: root.header
198 }
199 }
200+
201+ Rectangle {
202+ id: waitingForAction
203+ objectName: "waitingForAction"
204+ anchors.fill: parent
205+ color: "black"
206+ opacity: 0.6
207+ visible: false
208+
209+ MouseArea {
210+ anchors.fill: parent
211+ }
212+ }
213+
214+ ActivityIndicator {
215+ anchors.centerIn: waitingForAction
216+ visible: waitingForAction.visible
217+ running: waitingForAction.visible
218+ }
199}
219}
Dash/Generic/GenericPreview.qml+4−1
@@ -71,7 +71,10 @@ DashPreview {
71 text: modelData.displayName
71 text: modelData.displayName
72 iconSource: modelData.iconHint
72 iconSource: modelData.iconHint
73 iconPosition: "right"
73 iconPosition: "right"
74+ onClicked: {
74− onClicked: previewData.execute(modelData.id, { })
75+ previewData.execute(modelData.id, { })
76+ genericPreview.showProcessingAction = true;
77+ }
75 }
78 }
76 }
79 }
77 }
80 }
Dash/GenericScopeView.qml+7
@@ -57,6 +57,7 @@ ScopeView {
57 target: scopeView.scope
57 target: scopeView.scope
58 onShowDash: previewLoader.open = false;
58 onShowDash: previewLoader.open = false;
59 onHideDash: previewLoader.open = false;
59 onHideDash: previewLoader.open = false;
60+ onActivated: previewLoader.closePreviewSpinner();
60 }
61 }
61
62
62 ScopeListView {
63 ScopeListView {
@@ -306,6 +307,12 @@ ScopeView {
306 onLoaded: {
307 onLoaded: {
307 item.previewData = Qt.binding(function() { return previewLoader.previewData })
308 item.previewData = Qt.binding(function() { return previewLoader.previewData })
308 }
309 }
310+
311+ function closePreviewSpinner() {
312+ if(open) {
313+ item.showProcessingAction = false;
314+ }
315+ }
309 }
316 }
310
317
311 // TODO: Move as InverseMouseArea to DashPreview
318 // TODO: Move as InverseMouseArea to DashPreview
plugins/Unity/scope.cpp+1
@@ -204,6 +204,7 @@ void Scope::cancelActivation()
204
204
205void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints)
205void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints)
206{
206{
207+ Q_EMIT activated();
207 // note: we will not get called on SHOW_PREVIEW, instead UnityCore will signal preview_ready.
208 // note: we will not get called on SHOW_PREVIEW, instead UnityCore will signal preview_ready.
208 switch (type)
209 switch (type)
209 {
210 {
plugins/Unity/scope.h+1
@@ -113,6 +113,7 @@ Q_SIGNALS:
113 void showDash();
113 void showDash();
114 void hideDash();
114 void hideDash();
115 void gotoUri(const QString &uri);
115 void gotoUri(const QString &uri);
116+ void activated();
116
117
117 void activateApplication(const QString &desktop);
118 void activateApplication(const QString &desktop);
118
119
tests/qmltests/Dash/tst_GenericScopeView.qml+11
@@ -66,6 +66,17 @@ Item {
66 scopes.get(0).hideDash();
66 scopes.get(0).hideDash();
67 tryCompare(genericScopeView, "previewShown", false);
67 tryCompare(genericScopeView, "previewShown", false);
68 }
68 }
69+
70+ function test_show_spinner() {
71+ var previewLoader = findChild(genericScopeView, "previewLoader");
72+ previewLoader.open = true;
73+ previewLoader.source = "../../../Dash/Generic/GenericPreview.qml";
74+ previewLoader.item.showProcessingAction = true;
75+ var waitingForAction = findChild(genericScopeView, "waitingForAction");
76+ tryCompare(waitingForAction, "visible", true);
77+ previewLoader.closePreviewSpinner();
78+ tryCompare(waitingForAction, "visible", false);
79+ }
69 }
80 }
70 }
81 }
71}
82}