on xenial help sign in
Disable Preview interaction until the scope responds.
0294f75Diego Sarmentero
Dash/DashPreview.qml+8
@@ -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: waitingForActionMouseArea.enabled
25
26
26 property real previewWidthRatio: 0.5
27 property real previewWidthRatio: 0.5
27
28
@@ -196,4 +197,11 @@ Rectangle {
196 }
197 }
197 sourceComponent: root.header
198 sourceComponent: root.header
198 }
199 }
200+
201+ MouseArea {
202+ id: waitingForActionMouseArea
203+ objectName: "waitingForActionMouseArea"
204+ anchors.fill: parent
205+ enabled: false
206+ }
199}
207}
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
@@ -59,6 +59,7 @@ ScopeView {
59 target: scopeView.scope
59 target: scopeView.scope
60 onShowDash: previewLoader.open = false;
60 onShowDash: previewLoader.open = false;
61 onHideDash: previewLoader.open = false;
61 onHideDash: previewLoader.open = false;
62+ onActivated: previewLoader.closePreviewSpinner();
62 }
63 }
63
64
64 ScopeListView {
65 ScopeListView {
@@ -345,6 +346,12 @@ ScopeView {
345 onLoaded: {
346 onLoaded: {
346 item.previewData = Qt.binding(function() { return previewLoader.previewData })
347 item.previewData = Qt.binding(function() { return previewLoader.previewData })
347 }
348 }
349+
350+ function closePreviewSpinner() {
351+ if(item) {
352+ item.showProcessingAction = false;
353+ }
354+ }
348 }
355 }
349
356
350 // TODO: Move as InverseMouseArea to DashPreview
357 // TODO: Move as InverseMouseArea to DashPreview
plugins/Unity/scope.cpp+2
@@ -228,6 +228,7 @@ void Scope::cancelActivation()
228
228
229void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints)
229void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints)
230{
230{
231+ Q_EMIT activated();
231 // note: we will not get called on SHOW_PREVIEW, instead UnityCore will signal preview_ready.
232 // note: we will not get called on SHOW_PREVIEW, instead UnityCore will signal preview_ready.
232 switch (type)
233 switch (type)
233 {
234 {
@@ -261,6 +262,7 @@ void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::Sco
261
262
262void Scope::onPreviewReady(unity::dash::LocalResult const& /* result */, unity::dash::Preview::Ptr const& preview)
263void Scope::onPreviewReady(unity::dash::LocalResult const& /* result */, unity::dash::Preview::Ptr const& preview)
263{
264{
265+ Q_EMIT activated();
264 auto prv = Preview::newFromUnityPreview(preview);
266 auto prv = Preview::newFromUnityPreview(preview);
265 // is this the best solution? QML may need to keep more than one preview instance around, so we can't own it.
267 // is this the best solution? QML may need to keep more than one preview instance around, so we can't own it.
266 // passing it by value is not possible.
268 // passing it by value is not possible.
plugins/Unity/scope.h+1
@@ -117,6 +117,7 @@ Q_SIGNALS:
117 void showDash();
117 void showDash();
118 void hideDash();
118 void hideDash();
119 void gotoUri(const QString &uri);
119 void gotoUri(const QString &uri);
120+ void activated();
120
121
121 void activateApplication(const QString &desktop);
122 void activateApplication(const QString &desktop);
122
123
tests/qmltests/Dash/Apps/tst_AppPreview.qml+3−2
@@ -137,11 +137,12 @@ Item {
137 for(var i = 0; i < buttons.count; i++) {
137 for(var i = 0; i < buttons.count; i++) {
138 var button = findChild(appPreview, "button" + i);
138 var button = findChild(appPreview, "button" + i);
139 mouseClick(button, 1, 1);
139 mouseClick(button, 1, 1);
140+ appPreview.showProcessingAction = false;
140 }
141 }
141
142
142 var actions = data.actions;
143 var actions = data.actions;
143− for(var i = 0; i < actions.length; i++) {
144+ for(var j = 0; j < actions.length; j++) {
144− compare(root.calls[i][0], actions[i].id, "Id of action not found.");
145+ compare(root.calls[j][0], actions[j].id, "Id of action not found.");
145 }
146 }
146 }
147 }
147
148
tests/qmltests/Dash/Movie/tst_MoviePreview.qml+1
@@ -74,6 +74,7 @@ Item {
74 for(var i = 0; i < buttons.count; i++) {
74 for(var i = 0; i < buttons.count; i++) {
75 var button = findChild(moviePreview, "button" + i);
75 var button = findChild(moviePreview, "button" + i);
76 mouseClick(button, 1, 1);
76 mouseClick(button, 1, 1);
77+ moviePreview.showProcessingAction = false;
77 }
78 }
78
79
79 var actions = get_actions_data();
80 var actions = get_actions_data();
tests/qmltests/Dash/tst_GenericPreview.qml+1
@@ -76,6 +76,7 @@ Item {
76 for(var i = 0; i < buttons.count; i++) {
76 for(var i = 0; i < buttons.count; i++) {
77 var button = findChild(genericPreview, "button" + i);
77 var button = findChild(genericPreview, "button" + i);
78 mouseClick(button, 1, 1);
78 mouseClick(button, 1, 1);
79+ genericPreview.showProcessingAction = false;
79 }
80 }
80
81
81 var actions = get_actions_data();
82 var actions = get_actions_data();
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, "waitingForActionMouseArea");
76+ tryCompare(waitingForAction, "enabled", true);
77+ previewLoader.closePreviewSpinner();
78+ tryCompare(waitingForAction, "enabled", false);
79+ }
69 }
80 }
70 }
81 }
71}
82}