on xenial help sign in
change DashCommunicator to use a scope index instead of a scope id
f5af5d7Michael Zanetti
plugins/Unity/DashCommunicator/DashCommunicator.qmltypes+2−2
@@ -14,7 +14,7 @@ Module {
14 exportMetaObjectRevisions: [0]
14 exportMetaObjectRevisions: [0]
15 Method {
15 Method {
16 name: "setCurrentScope"
16 name: "setCurrentScope"
17− Parameter { name: "scopeId"; type: "string" }
17+ Parameter { name: "index"; type: "int" }
18 Parameter { name: "animate"; type: "bool" }
18 Parameter { name: "animate"; type: "bool" }
19 Parameter { name: "reset"; type: "bool" }
19 Parameter { name: "reset"; type: "bool" }
20 }
20 }
@@ -26,7 +26,7 @@ Module {
26 exportMetaObjectRevisions: [0]
26 exportMetaObjectRevisions: [0]
27 Signal {
27 Signal {
28 name: "setCurrentScopeRequested"
28 name: "setCurrentScopeRequested"
29− Parameter { name: "scopeId"; type: "string" }
29+ Parameter { name: "index"; type: "int" }
30 Parameter { name: "animate"; type: "bool" }
30 Parameter { name: "animate"; type: "bool" }
31 Parameter { name: "reset"; type: "bool" }
31 Parameter { name: "reset"; type: "bool" }
32 }
32 }
plugins/Unity/DashCommunicator/dashcommunicator.cpp+2−2
@@ -27,12 +27,12 @@ DashCommunicator::DashCommunicator(QObject *parent):
27 start();
27 start();
28}
28}
29
29
30−void DashCommunicator::setCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
30+void DashCommunicator::setCurrentScope(int index, bool animate, bool isSwipe)
31{
31{
32 m_mutex.lock();
32 m_mutex.lock();
33 if (m_created) {
33 if (m_created) {
34 QMetaObject::invokeMethod(m_dashConnection, "setCurrentScope",
34 QMetaObject::invokeMethod(m_dashConnection, "setCurrentScope",
35− Q_ARG(QString, scopeId),
35+ Q_ARG(int, index),
36 Q_ARG(bool, animate),
36 Q_ARG(bool, animate),
37 Q_ARG(bool, isSwipe));
37 Q_ARG(bool, isSwipe));
38 }
38 }
plugins/Unity/DashCommunicator/dashcommunicator.h+1−1
@@ -31,7 +31,7 @@ public:
31 ~DashCommunicator() = default;
31 ~DashCommunicator() = default;
32
32
33public Q_SLOTS:
33public Q_SLOTS:
34− void setCurrentScope(const QString &scopeId, bool animate, bool isSwipe);
34+ void setCurrentScope(int index, bool animate, bool isSwipe);
35
35
36protected:
36protected:
37 void run() override;
37 void run() override;
plugins/Unity/DashCommunicator/dashcommunicatorservice.h+1−1
@@ -29,7 +29,7 @@ public:
29 ~DashCommunicatorService();
29 ~DashCommunicatorService();
30
30
31Q_SIGNALS:
31Q_SIGNALS:
32− void setCurrentScopeRequested(const QString &scopeId, bool animate, bool isSwipe);
32+ void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
33
33
34private:
34private:
35 DBusDashCommunicatorService *m_dbusService;
35 DBusDashCommunicatorService *m_dbusService;
plugins/Unity/DashCommunicator/dashconnection.cpp+2−2
@@ -25,9 +25,9 @@ DashConnection::DashConnection(const QString &service, const QString &path, cons
25
25
26}
26}
27
27
28−void DashConnection::setCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
28+void DashConnection::setCurrentScope(int index, bool animate, bool isSwipe)
29{
29{
30 if (dbusInterface()) {
30 if (dbusInterface()) {
31− dbusInterface()->asyncCall("SetCurrentScope", scopeId, animate, isSwipe);
31+ dbusInterface()->asyncCall("SetCurrentScope", index, animate, isSwipe);
32 }
32 }
33}
33}
plugins/Unity/DashCommunicator/dashconnection.h+1−1
@@ -28,7 +28,7 @@ public:
28 DashConnection(const QString &service, const QString &path, const QString &interface, QObject *parent = 0);
28 DashConnection(const QString &service, const QString &path, const QString &interface, QObject *parent = 0);
29
29
30public Q_SLOTS:
30public Q_SLOTS:
31− void setCurrentScope(const QString &scopeId, bool animate, bool isSwipe);
31+ void setCurrentScope(int index, bool animate, bool isSwipe);
32};
32};
33
33
34#endif
34#endif
plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.cpp+2−2
@@ -33,7 +33,7 @@ DBusDashCommunicatorService::~DBusDashCommunicatorService()
33{
33{
34}
34}
35
35
36−void DBusDashCommunicatorService::SetCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
36+void DBusDashCommunicatorService::SetCurrentScope(int index, bool animate, bool isSwipe)
37{
37{
38− Q_EMIT setCurrentScopeRequested(scopeId, animate, isSwipe);
38+ Q_EMIT setCurrentScopeRequested(index, animate, isSwipe);
39}
39}
plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.h+2−2
@@ -29,10 +29,10 @@ public:
29 ~DBusDashCommunicatorService();
29 ~DBusDashCommunicatorService();
30
30
31Q_SIGNALS:
31Q_SIGNALS:
32− void setCurrentScopeRequested(const QString &scopeId, bool animate, bool isSwipe);
32+ void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
33
33
34public Q_SLOTS:
34public Q_SLOTS:
35− Q_SCRIPTABLE void SetCurrentScope(const QString &scopeId, bool animate, bool isSwipe);
35+ Q_SCRIPTABLE void SetCurrentScope(int index, bool animate, bool isSwipe);
36
36
37};
37};
38
38
qml/Dash/Dash.qml+4−12
@@ -35,7 +35,7 @@ Showable {
35 onSetCurrentScopeRequested: {
35 onSetCurrentScopeRequested: {
36 if (!isSwipe || !window.active || overviewController.progress != 0) {
36 if (!isSwipe || !window.active || overviewController.progress != 0) {
37 if (overviewController.progress != 0 && window.active) animate = false;
37 if (overviewController.progress != 0 && window.active) animate = false;
38− dash.setCurrentScope(scopeId, animate, isSwipe)
38+ dash.setCurrentScope(index, animate, isSwipe)
39 if (overviewController.progress != 0) {
39 if (overviewController.progress != 0) {
40 if (window.active) {
40 if (window.active) {
41 dashContentCache.scheduleUpdate();
41 dashContentCache.scheduleUpdate();
@@ -48,17 +48,9 @@ Showable {
48 }
48 }
49 }
49 }
50
50
51− function setCurrentScope(scopeId, animate, reset) {
51+ function setCurrentScope(scopeIndex, animate, reset) {
52− var scopeIndex = -1;
53− for (var i = 0; i < scopes.count; ++i) {
52+ if (scopeIndex < 0 || scopeIndex >= scopes.count) {
54− if (scopes.getScope(i).id == scopeId) {
55− scopeIndex = i;
56− break;
57− }
58− }
59−
60− if (scopeIndex == -1) {
61− console.warn("No match for scope with id: %1".arg(scopeId))
53+ console.warn("No scope with index: %1".arg(scopeIndex))
62 return
54 return
63 }
55 }
64
56
qml/Shell.qml+2−2
@@ -610,7 +610,7 @@ Item {
610 }
610 }
611
611
612 var animate = !LightDM.Greeter.active && !stages.shown
612 var animate = !LightDM.Greeter.active && !stages.shown
613− dash.setCurrentScope("clickscope", animate, false)
613+ dash.setCurrentScope(0, animate, false)
614 ApplicationManager.requestFocusApplication("unity8-dash")
614 ApplicationManager.requestFocusApplication("unity8-dash")
615 }
615 }
616
616
@@ -673,7 +673,7 @@ Item {
673 onDash: showDash()
673 onDash: showDash()
674 onDashSwipeChanged: {
674 onDashSwipeChanged: {
675 if (dashSwipe) {
675 if (dashSwipe) {
676− dash.setCurrentScope("clickscope", false, true)
676+ dash.setCurrentScope(0, false, true)
677 }
677 }
678 }
678 }
679 onLauncherApplicationSelected: {
679 onLauncherApplicationSelected: {
tests/mocks/Unity/DashCommunicator/DashCommunicator.qmltypes+4−4
@@ -14,13 +14,13 @@ Module {
14 exportMetaObjectRevisions: [0]
14 exportMetaObjectRevisions: [0]
15 Signal {
15 Signal {
16 name: "setCurrentScopeCalled"
16 name: "setCurrentScopeCalled"
17− Parameter { name: "scopeId"; type: "string" }
17+ Parameter { name: "index"; type: "int" }
18 Parameter { name: "animate"; type: "bool" }
18 Parameter { name: "animate"; type: "bool" }
19 Parameter { name: "reset"; type: "bool" }
19 Parameter { name: "reset"; type: "bool" }
20 }
20 }
21 Method {
21 Method {
22 name: "setCurrentScope"
22 name: "setCurrentScope"
23− Parameter { name: "scopeId"; type: "string" }
23+ Parameter { name: "index"; type: "int" }
24 Parameter { name: "animate"; type: "bool" }
24 Parameter { name: "animate"; type: "bool" }
25 Parameter { name: "reset"; type: "bool" }
25 Parameter { name: "reset"; type: "bool" }
26 }
26 }
@@ -32,13 +32,13 @@ Module {
32 exportMetaObjectRevisions: [0]
32 exportMetaObjectRevisions: [0]
33 Signal {
33 Signal {
34 name: "setCurrentScopeRequested"
34 name: "setCurrentScopeRequested"
35− Parameter { name: "scopeId"; type: "string" }
35+ Parameter { name: "index"; type: "int" }
36 Parameter { name: "animate"; type: "bool" }
36 Parameter { name: "animate"; type: "bool" }
37 Parameter { name: "reset"; type: "bool" }
37 Parameter { name: "reset"; type: "bool" }
38 }
38 }
39 Method {
39 Method {
40 name: "mockSetCurrentScope"
40 name: "mockSetCurrentScope"
41− Parameter { name: "scopeId"; type: "string" }
41+ Parameter { name: "index"; type: "int" }
42 Parameter { name: "animate"; type: "bool" }
42 Parameter { name: "animate"; type: "bool" }
43 Parameter { name: "reset"; type: "bool" }
43 Parameter { name: "reset"; type: "bool" }
44 }
44 }
tests/mocks/Unity/DashCommunicator/dashcommunicator.cpp+2−2
@@ -31,7 +31,7 @@ DashCommunicator::~DashCommunicator()
31}
31}
32
32
33
33
34−void DashCommunicator::setCurrentScope(const QString &scopeId, bool animate, bool reset)
34+void DashCommunicator::setCurrentScope(int index, bool animate, bool reset)
35{
35{
36− Q_EMIT setCurrentScopeCalled(scopeId, animate, reset);
36+ Q_EMIT setCurrentScopeCalled(index, animate, reset);
37}
37}
tests/mocks/Unity/DashCommunicator/dashcommunicator.h+2−2
@@ -29,11 +29,11 @@ public:
29 ~DashCommunicator();
29 ~DashCommunicator();
30
30
31public Q_SLOTS:
31public Q_SLOTS:
32− void setCurrentScope(const QString &scopeId, bool animate, bool reset);
32+ void setCurrentScope(int index, bool animate, bool reset);
33
33
34Q_SIGNALS:
34Q_SIGNALS:
35 // This mock just emits calls back to the QML api for the plugin to verify calls
35 // This mock just emits calls back to the QML api for the plugin to verify calls
36− void setCurrentScopeCalled(const QString &scopeId, bool animate, bool reset);
36+ void setCurrentScopeCalled(int index, bool animate, bool reset);
37};
37};
38
38
39#endif
39#endif
tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.cpp+2−2
@@ -27,7 +27,7 @@ DashCommunicatorService::~DashCommunicatorService()
27
27
28}
28}
29
29
30−void DashCommunicatorService::mockSetCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
30+void DashCommunicatorService::mockSetCurrentScope(int index, bool animate, bool isSwipe)
31{
31{
32− Q_EMIT setCurrentScopeRequested(scopeId, animate, isSwipe);
32+ Q_EMIT setCurrentScopeRequested(index, animate, isSwipe);
33}
33}
tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.h+2−2
@@ -27,10 +27,10 @@ public:
27 ~DashCommunicatorService();
27 ~DashCommunicatorService();
28
28
29Q_SIGNALS:
29Q_SIGNALS:
30− void setCurrentScopeRequested(const QString &scopeId, bool animate, bool isSwipe);
30+ void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
31
31
32public Q_SLOTS:
32public Q_SLOTS:
33− void mockSetCurrentScope(const QString &scopeId, bool animate, bool isSwipe);
33+ void mockSetCurrentScope(int index, bool animate, bool isSwipe);
34};
34};
35
35
36#endif // DBUSUNITYSESSIONSERVICE_H
36#endif // DBUSUNITYSESSIONSERVICE_H
tests/qmltests/tst_Shell.qml+1−1
@@ -294,7 +294,7 @@ Row {
294 tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
294 tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
295
295
296 compare(dashCommunicatorSpy.count, 1);
296 compare(dashCommunicatorSpy.count, 1);
297− compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
297+ compare(dashCommunicatorSpy.signalArguments[0][0], 0);
298 }
298 }
299
299
300 function test_showInputMethod() {
300 function test_showInputMethod() {