on xenial help sign in
change DashCommunicator to use a scope index instead of a scope id
commitf5af5d79ed84ed6045e1eac613803861e7b24ca1 authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 20 Oct 2014, 17:52 (12 years ago) parent1ff2631
16 files changed+32−40
plugins/Unity/DashCommunicator/DashCommunicator.qmltypes+2−2 plugins/Unity/DashCommunicator/dashcommunicator.cpp+2−2 plugins/Unity/DashCommunicator/dashcommunicator.h+1−1 plugins/Unity/DashCommunicator/dashcommunicatorservice.h+1−1 plugins/Unity/DashCommunicator/dashconnection.cpp+2−2 plugins/Unity/DashCommunicator/dashconnection.h+1−1 plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.cpp+2−2 plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.h+2−2 qml/Dash/Dash.qml+4−12 qml/Shell.qml+2−2 tests/mocks/Unity/DashCommunicator/DashCommunicator.qmltypes+4−4 tests/mocks/Unity/DashCommunicator/dashcommunicator.cpp+2−2 tests/mocks/Unity/DashCommunicator/dashcommunicator.h+2−2 tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.cpp+2−2 tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.h+2−2 tests/qmltests/tst_Shell.qml+1−1
plugins/Unity/DashCommunicator/DashCommunicator.qmltypes+2−2
@@ -14,7 +14,7 @@ Module {
1414 exportMetaObjectRevisions: [0]
1515 Method {
1616 name: "setCurrentScope"
17− Parameter { name: "scopeId"; type: "string" }
17+ Parameter { name: "index"; type: "int" }
1818 Parameter { name: "animate"; type: "bool" }
1919 Parameter { name: "reset"; type: "bool" }
2020 }
@@ -26,7 +26,7 @@ Module {
2626 exportMetaObjectRevisions: [0]
2727 Signal {
2828 name: "setCurrentScopeRequested"
29− Parameter { name: "scopeId"; type: "string" }
29+ Parameter { name: "index"; type: "int" }
3030 Parameter { name: "animate"; type: "bool" }
3131 Parameter { name: "reset"; type: "bool" }
3232 }
plugins/Unity/DashCommunicator/dashcommunicator.cpp+2−2
@@ -27,12 +27,12 @@ DashCommunicator::DashCommunicator(QObject *parent):
2727 start();
2828}
2929
30−void DashCommunicator::setCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
30+void DashCommunicator::setCurrentScope(int index, bool animate, bool isSwipe)
3131{
3232 m_mutex.lock();
3333 if (m_created) {
3434 QMetaObject::invokeMethod(m_dashConnection, "setCurrentScope",
35− Q_ARG(QString, scopeId),
35+ Q_ARG(int, index),
3636 Q_ARG(bool, animate),
3737 Q_ARG(bool, isSwipe));
3838 }
plugins/Unity/DashCommunicator/dashcommunicator.h+1−1
@@ -31,7 +31,7 @@ public:
3131 ~DashCommunicator() = default;
3232
3333public Q_SLOTS:
34− void setCurrentScope(const QString &scopeId, bool animate, bool isSwipe);
34+ void setCurrentScope(int index, bool animate, bool isSwipe);
3535
3636protected:
3737 void run() override;
plugins/Unity/DashCommunicator/dashcommunicatorservice.h+1−1
@@ -29,7 +29,7 @@ public:
2929 ~DashCommunicatorService();
3030
3131Q_SIGNALS:
32− void setCurrentScopeRequested(const QString &scopeId, bool animate, bool isSwipe);
32+ void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
3333
3434private:
3535 DBusDashCommunicatorService *m_dbusService;
plugins/Unity/DashCommunicator/dashconnection.cpp+2−2
@@ -25,9 +25,9 @@ DashConnection::DashConnection(const QString &service, const QString &path, cons
2525
2626}
2727
28−void DashConnection::setCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
28+void DashConnection::setCurrentScope(int index, bool animate, bool isSwipe)
2929{
3030 if (dbusInterface()) {
31− dbusInterface()->asyncCall("SetCurrentScope", scopeId, animate, isSwipe);
31+ dbusInterface()->asyncCall("SetCurrentScope", index, animate, isSwipe);
3232 }
3333}
plugins/Unity/DashCommunicator/dashconnection.h+1−1
@@ -28,7 +28,7 @@ public:
2828 DashConnection(const QString &service, const QString &path, const QString &interface, QObject *parent = 0);
2929
3030public Q_SLOTS:
31− void setCurrentScope(const QString &scopeId, bool animate, bool isSwipe);
31+ void setCurrentScope(int index, bool animate, bool isSwipe);
3232};
3333
3434#endif
plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.cpp+2−2
@@ -33,7 +33,7 @@ DBusDashCommunicatorService::~DBusDashCommunicatorService()
3333{
3434}
3535
36−void DBusDashCommunicatorService::SetCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
36+void DBusDashCommunicatorService::SetCurrentScope(int index, bool animate, bool isSwipe)
3737{
38− Q_EMIT setCurrentScopeRequested(scopeId, animate, isSwipe);
38+ Q_EMIT setCurrentScopeRequested(index, animate, isSwipe);
3939}
plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.h+2−2
@@ -29,10 +29,10 @@ public:
2929 ~DBusDashCommunicatorService();
3030
3131Q_SIGNALS:
32− void setCurrentScopeRequested(const QString &scopeId, bool animate, bool isSwipe);
32+ void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
3333
3434public 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);
3636
3737};
3838
qml/Dash/Dash.qml+4−12
@@ -35,7 +35,7 @@ Showable {
3535 onSetCurrentScopeRequested: {
3636 if (!isSwipe || !window.active || overviewController.progress != 0) {
3737 if (overviewController.progress != 0 && window.active) animate = false;
38− dash.setCurrentScope(scopeId, animate, isSwipe)
38+ dash.setCurrentScope(index, animate, isSwipe)
3939 if (overviewController.progress != 0) {
4040 if (window.active) {
4141 dashContentCache.scheduleUpdate();
@@ -48,17 +48,9 @@ Showable {
4848 }
4949 }
5050
51− function setCurrentScope(scopeId, animate, reset) {
52− var scopeIndex = -1;
53− for (var i = 0; i < scopes.count; ++i) {
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))
51+ function setCurrentScope(scopeIndex, animate, reset) {
52+ if (scopeIndex < 0 || scopeIndex >= scopes.count) {
53+ console.warn("No scope with index: %1".arg(scopeIndex))
6254 return
6355 }
6456
qml/Shell.qml+2−2
@@ -610,7 +610,7 @@ Item {
610610 }
611611
612612 var animate = !LightDM.Greeter.active && !stages.shown
613− dash.setCurrentScope("clickscope", animate, false)
613+ dash.setCurrentScope(0, animate, false)
614614 ApplicationManager.requestFocusApplication("unity8-dash")
615615 }
616616
@@ -673,7 +673,7 @@ Item {
673673 onDash: showDash()
674674 onDashSwipeChanged: {
675675 if (dashSwipe) {
676− dash.setCurrentScope("clickscope", false, true)
676+ dash.setCurrentScope(0, false, true)
677677 }
678678 }
679679 onLauncherApplicationSelected: {
tests/mocks/Unity/DashCommunicator/DashCommunicator.qmltypes+4−4
@@ -14,13 +14,13 @@ Module {
1414 exportMetaObjectRevisions: [0]
1515 Signal {
1616 name: "setCurrentScopeCalled"
17− Parameter { name: "scopeId"; type: "string" }
17+ Parameter { name: "index"; type: "int" }
1818 Parameter { name: "animate"; type: "bool" }
1919 Parameter { name: "reset"; type: "bool" }
2020 }
2121 Method {
2222 name: "setCurrentScope"
23− Parameter { name: "scopeId"; type: "string" }
23+ Parameter { name: "index"; type: "int" }
2424 Parameter { name: "animate"; type: "bool" }
2525 Parameter { name: "reset"; type: "bool" }
2626 }
@@ -32,13 +32,13 @@ Module {
3232 exportMetaObjectRevisions: [0]
3333 Signal {
3434 name: "setCurrentScopeRequested"
35− Parameter { name: "scopeId"; type: "string" }
35+ Parameter { name: "index"; type: "int" }
3636 Parameter { name: "animate"; type: "bool" }
3737 Parameter { name: "reset"; type: "bool" }
3838 }
3939 Method {
4040 name: "mockSetCurrentScope"
41− Parameter { name: "scopeId"; type: "string" }
41+ Parameter { name: "index"; type: "int" }
4242 Parameter { name: "animate"; type: "bool" }
4343 Parameter { name: "reset"; type: "bool" }
4444 }
tests/mocks/Unity/DashCommunicator/dashcommunicator.cpp+2−2
@@ -31,7 +31,7 @@ DashCommunicator::~DashCommunicator()
3131}
3232
3333
34−void DashCommunicator::setCurrentScope(const QString &scopeId, bool animate, bool reset)
34+void DashCommunicator::setCurrentScope(int index, bool animate, bool reset)
3535{
36− Q_EMIT setCurrentScopeCalled(scopeId, animate, reset);
36+ Q_EMIT setCurrentScopeCalled(index, animate, reset);
3737}
tests/mocks/Unity/DashCommunicator/dashcommunicator.h+2−2
@@ -29,11 +29,11 @@ public:
2929 ~DashCommunicator();
3030
3131public Q_SLOTS:
32− void setCurrentScope(const QString &scopeId, bool animate, bool reset);
32+ void setCurrentScope(int index, bool animate, bool reset);
3333
3434Q_SIGNALS:
3535 // 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);
3737};
3838
3939#endif
tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.cpp+2−2
@@ -27,7 +27,7 @@ DashCommunicatorService::~DashCommunicatorService()
2727
2828}
2929
30−void DashCommunicatorService::mockSetCurrentScope(const QString &scopeId, bool animate, bool isSwipe)
30+void DashCommunicatorService::mockSetCurrentScope(int index, bool animate, bool isSwipe)
3131{
32− Q_EMIT setCurrentScopeRequested(scopeId, animate, isSwipe);
32+ Q_EMIT setCurrentScopeRequested(index, animate, isSwipe);
3333}
tests/mocks/Unity/DashCommunicator/dashcommunicatorservice.h+2−2
@@ -27,10 +27,10 @@ public:
2727 ~DashCommunicatorService();
2828
2929Q_SIGNALS:
30− void setCurrentScopeRequested(const QString &scopeId, bool animate, bool isSwipe);
30+ void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
3131
3232public Q_SLOTS:
33− void mockSetCurrentScope(const QString &scopeId, bool animate, bool isSwipe);
33+ void mockSetCurrentScope(int index, bool animate, bool isSwipe);
3434};
3535
3636#endif // DBUSUNITYSESSIONSERVICE_H
tests/qmltests/tst_Shell.qml+1−1
@@ -294,7 +294,7 @@ Row {
294294 tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
295295
296296 compare(dashCommunicatorSpy.count, 1);
297− compare(dashCommunicatorSpy.signalArguments[0][0], "clickscope");
297+ compare(dashCommunicatorSpy.signalArguments[0][0], 0);
298298 }
299299
300300 function test_showInputMethod() {