on xenial help sign in
Disable Preview interaction until the scope responds.

Approved by Michał Sawicz.

commit0294f7593a3d66d873388fc901f255232f82bf6d authorDiego Sarmentero <diego.sarmentero@gmail.com> dateWed 16 Oct 2013, 17:52 (13 years ago) parent33eb6be9af639d
9 files changed+38−3
Dash/DashPreview.qml+8 Dash/Generic/GenericPreview.qml+4−1 Dash/GenericScopeView.qml+7 plugins/Unity/scope.cpp+2 plugins/Unity/scope.h+1 tests/qmltests/Dash/Apps/tst_AppPreview.qml+3−2 tests/qmltests/Dash/Movie/tst_MoviePreview.qml+1 tests/qmltests/Dash/tst_GenericPreview.qml+1 tests/qmltests/Dash/tst_GenericScopeView.qml+11
Dash/DashPreview.qml+8
@@ -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: waitingForActionMouseArea.enabled
2526
2627 property real previewWidthRatio: 0.5
2728
@@ -196,4 +197,11 @@ Rectangle {
196197 }
197198 sourceComponent: root.header
198199 }
200+
201+ MouseArea {
202+ id: waitingForActionMouseArea
203+ objectName: "waitingForActionMouseArea"
204+ anchors.fill: parent
205+ enabled: false
206+ }
199207}
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
@@ -59,6 +59,7 @@ ScopeView {
5959 target: scopeView.scope
6060 onShowDash: previewLoader.open = false;
6161 onHideDash: previewLoader.open = false;
62+ onActivated: previewLoader.closePreviewSpinner();
6263 }
6364
6465 ScopeListView {
@@ -345,6 +346,12 @@ ScopeView {
345346 onLoaded: {
346347 item.previewData = Qt.binding(function() { return previewLoader.previewData })
347348 }
349+
350+ function closePreviewSpinner() {
351+ if(item) {
352+ item.showProcessingAction = false;
353+ }
354+ }
348355 }
349356
350357 // TODO: Move as InverseMouseArea to DashPreview
plugins/Unity/scope.cpp+2
@@ -228,6 +228,7 @@ void Scope::cancelActivation()
228228
229229void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints)
230230{
231+ Q_EMIT activated();
231232 // note: we will not get called on SHOW_PREVIEW, instead UnityCore will signal preview_ready.
232233 switch (type)
233234 {
@@ -261,6 +262,7 @@ void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::Sco
261262
262263void Scope::onPreviewReady(unity::dash::LocalResult const& /* result */, unity::dash::Preview::Ptr const& preview)
263264{
265+ Q_EMIT activated();
264266 auto prv = Preview::newFromUnityPreview(preview);
265267 // is this the best solution? QML may need to keep more than one preview instance around, so we can't own it.
266268 // passing it by value is not possible.
plugins/Unity/scope.h+1
@@ -117,6 +117,7 @@ Q_SIGNALS:
117117 void showDash();
118118 void hideDash();
119119 void gotoUri(const QString &uri);
120+ void activated();
120121
121122 void activateApplication(const QString &desktop);
122123
tests/qmltests/Dash/Apps/tst_AppPreview.qml+3−2
@@ -137,11 +137,12 @@ Item {
137137 for(var i = 0; i < buttons.count; i++) {
138138 var button = findChild(appPreview, "button" + i);
139139 mouseClick(button, 1, 1);
140+ appPreview.showProcessingAction = false;
140141 }
141142
142143 var actions = data.actions;
143− for(var i = 0; i < actions.length; i++) {
144− compare(root.calls[i][0], actions[i].id, "Id of action not found.");
144+ for(var j = 0; j < actions.length; j++) {
145+ compare(root.calls[j][0], actions[j].id, "Id of action not found.");
145146 }
146147 }
147148
tests/qmltests/Dash/Movie/tst_MoviePreview.qml+1
@@ -74,6 +74,7 @@ Item {
7474 for(var i = 0; i < buttons.count; i++) {
7575 var button = findChild(moviePreview, "button" + i);
7676 mouseClick(button, 1, 1);
77+ moviePreview.showProcessingAction = false;
7778 }
7879
7980 var actions = get_actions_data();
tests/qmltests/Dash/tst_GenericPreview.qml+1
@@ -76,6 +76,7 @@ Item {
7676 for(var i = 0; i < buttons.count; i++) {
7777 var button = findChild(genericPreview, "button" + i);
7878 mouseClick(button, 1, 1);
79+ genericPreview.showProcessingAction = false;
7980 }
8081
8182 var actions = get_actions_data();
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, "waitingForActionMouseArea");
76+ tryCompare(waitingForAction, "enabled", true);
77+ previewLoader.closePreviewSpinner();
78+ tryCompare(waitingForAction, "enabled", false);
79+ }
6980 }
7081 }
7182}