make left swipe reset search string
commit61e488d1150ac5b1968d3461945a5d7b16e6dcae
authorhandsome_feng <445865575@qq.com>
dateThu 12 Feb 2015, 14:45 (12 years ago)
parent3f18c22
plugins/Unity/DashCommunicator/dashcommunicator.cpp+9
@@ -39,6 +39,15 @@ void DashCommunicator::setCurrentScope(int index, bool animate, bool isSwipe)
3939 m_mutex.unlock();
4040}
4141
42+void DashCommunicator::resetAll()
43+{
44+ m_mutex.lock();
45+ if(m_created) {
46+ QMetaObject::invokeMethod(m_dashConnection, "resetAll");
47+ }
48+ m_mutex.unlock();
49+}
50+
4251void DashCommunicator::run()
4352{
4453 m_dashConnection = new DashConnection("com.canonical.UnityDash",
plugins/Unity/DashCommunicator/dashcommunicator.h+1
@@ -32,6 +32,7 @@ public:
3232
3333public Q_SLOTS:
3434 void setCurrentScope(int index, bool animate, bool isSwipe);
35+ void resetAll();
3536
3637protected:
3738 void run() override;
plugins/Unity/DashCommunicator/dashcommunicatorservice.cpp+1
@@ -21,6 +21,7 @@ DashCommunicatorService::DashCommunicatorService(QObject *parent):
2121 m_dbusService(new DBusDashCommunicatorService(this))
2222{
2323 connect(m_dbusService, &DBusDashCommunicatorService::setCurrentScopeRequested, this, &DashCommunicatorService::setCurrentScopeRequested);
24+ connect(m_dbusService, &DBusDashCommunicatorService::resetAllRequested, this, &DashCommunicatorService::resetAllRequested);
2425}
2526
2627
plugins/Unity/DashCommunicator/dashcommunicatorservice.h+1
@@ -30,6 +30,7 @@ public:
3030
3131Q_SIGNALS:
3232 void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
33+ void resetAllRequested();
3334
3435private:
3536 DBusDashCommunicatorService *m_dbusService;
plugins/Unity/DashCommunicator/dashconnection.cpp+7
@@ -61,3 +61,10 @@ void DashConnection::setCurrentScope(int index, bool animate, bool isSwipe)
6161 dbusInterface()->asyncCall("SetCurrentScope", index, animate, isSwipe);
6262 }
6363}
64+
65+void DashConnection::resetAll()
66+{
67+ if (dbusInterface()) {
68+ dbusInterface()->asyncCall("ResetAll");
69+ }
70+}
plugins/Unity/DashCommunicator/dashconnection.h+1
@@ -28,6 +28,7 @@ public:
2828
2929public Q_SLOTS:
3030 void setCurrentScope(int index, bool animate, bool isSwipe);
31+ void resetAll();
3132
3233private:
3334 QDBusAbstractInterface* createInterface(const QString &service, const QString &path,
plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.cpp+5
@@ -33,3 +33,8 @@ void DBusDashCommunicatorService::SetCurrentScope(int index, bool animate, bool
3333{
3434 Q_EMIT setCurrentScopeRequested(index, animate, isSwipe);
3535}
36+
37+void DBusDashCommunicatorService::ResetAll()
38+{
39+ Q_EMIT resetAllRequested();
40+}
plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.h+2
@@ -30,9 +30,11 @@ public:
3030
3131Q_SIGNALS:
3232 void setCurrentScopeRequested(int index, bool animate, bool isSwipe);
33+ void resetAllRequested();
3334
3435public Q_SLOTS:
3536 Q_SCRIPTABLE void SetCurrentScope(int index, bool animate, bool isSwipe);
37+ Q_SCRIPTABLE void ResetAll();
3638
3739};
3840
qml/Dash/Dash.qml+3
@@ -49,6 +49,9 @@ Showable {
4949 }
5050 }
5151 }
52+ onResetAllRequested:{
53+ dashContent.resetSearch();
54+ }
5255 }
5356
5457 function setCurrentScope(scopeId, animate, reset) {
qml/Dash/DashContent.qml+6
@@ -40,6 +40,7 @@ Item {
4040 signal gotoScope(string scopeId)
4141 signal openScope(var scope)
4242 signal closePreview()
43+ signal resetSearch()
4344
4445 // If we set the current scope index before the scopes have been added,
4546 // then we need to wait until the loaded signals gets emitted from the scopes
@@ -211,6 +212,11 @@ Item {
211212 onClosePreview: if (item) item.closePreview()
212213 }
213214
215+ Connections {
216+ target: dashContent
217+ onResetSearch: if(item) item.resetSearch()
218+ }
219+
214220 Component.onDestruction: active = false
215221 }
216222 }
qml/Dash/GenericScopeView.qml+5
@@ -67,6 +67,11 @@ FocusScope {
6767 subPageLoader.closeSubPage()
6868 }
6969
70+ function resetSearch() {
71+ if(pageHeaderLoader.item && showPageHeader)
72+ pageHeaderLoader.item.resetSearch()
73+ }
74+
7075 function itemClicked(index, result, item, itemModel, resultsModel, limitedCategoryItemCount) {
7176 if (itemModel.uri.indexOf("scope://") === 0 || scope.id === "clickscope") {
7277 // TODO Technically it is possible that calling activate() will make the scope emit
qml/Shell.qml+1
@@ -784,6 +784,7 @@ Item {
784784 onDashSwipeChanged: {
785785 if (dashSwipe) {
786786 dash.setCurrentScope(0, false, true)
787+ dash.resetAll()
787788 }
788789 }
789790 onLauncherApplicationSelected: {