on xenial help sign in
Disable the UI and show spinner until the scope responds
commitfc0771f1b2b6e9a7170f22ac309cb0116e72c0b5 authorDiego Sarmentero <diego.sarmentero@gmail.com> dateWed 9 Oct 2013, 11:17 (13 years ago) parent6abd10c
6 files changed+44−1
Dash/DashPreview.qml+20 Dash/Generic/GenericPreview.qml+4−1 Dash/GenericScopeView.qml+7 plugins/Unity/scope.cpp+1 plugins/Unity/scope.h+1 tests/qmltests/Dash/tst_GenericScopeView.qml+11
Dash/DashPreview.qml+20
@@ -22,6 +22,7 @@ Rectangle {
2222
2323 property int keyboardSize: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
2424 property var previewData
25+ property alias showProcessingAction: waitingForAction.visible
2526
2627 property real previewWidthRatio: 0.5
2728
@@ -196,4 +197,23 @@ Rectangle {
196197 }
197198 sourceComponent: root.header
198199 }
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+ }
199219}
Dash/Generic/GenericPreview.qml+4−1
@@ -71,7 +71,10 @@ DashPreview {
7171 text: modelData.displayName
7272 iconSource: modelData.iconHint
7373 iconPosition: "right"
74− onClicked: previewData.execute(modelData.id, { })
74+ onClicked: {
75+ previewData.execute(modelData.id, { })
76+ genericPreview.showProcessingAction = true;
77+ }
7578 }
7679 }
7780 }
Dash/GenericScopeView.qml+7
@@ -57,6 +57,7 @@ ScopeView {
5757 target: scopeView.scope
5858 onShowDash: previewLoader.open = false;
5959 onHideDash: previewLoader.open = false;
60+ onActivated: previewLoader.closePreviewSpinner();
6061 }
6162
6263 ScopeListView {
@@ -306,6 +307,12 @@ ScopeView {
306307 onLoaded: {
307308 item.previewData = Qt.binding(function() { return previewLoader.previewData })
308309 }
310+
311+ function closePreviewSpinner() {
312+ if(open) {
313+ item.showProcessingAction = false;
314+ }
315+ }
309316 }
310317
311318 // TODO: Move as InverseMouseArea to DashPreview
plugins/Unity/scope.cpp+1
@@ -204,6 +204,7 @@ void Scope::cancelActivation()
204204
205205void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints)
206206{
207+ Q_EMIT activated();
207208 // note: we will not get called on SHOW_PREVIEW, instead UnityCore will signal preview_ready.
208209 switch (type)
209210 {
plugins/Unity/scope.h+1
@@ -113,6 +113,7 @@ Q_SIGNALS:
113113 void showDash();
114114 void hideDash();
115115 void gotoUri(const QString &uri);
116+ void activated();
116117
117118 void activateApplication(const QString &desktop);
118119
tests/qmltests/Dash/tst_GenericScopeView.qml+11
@@ -66,6 +66,17 @@ Item {
6666 scopes.get(0).hideDash();
6767 tryCompare(genericScopeView, "previewShown", false);
6868 }
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+ }
6980 }
7081 }
7182}