Commit 2a130e1c authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Improve convergent logic

parent aca8e26b
...@@ -51,8 +51,6 @@ DiscoverPage { ...@@ -51,8 +51,6 @@ DiscoverPage {
title: category ? category.name : "" title: category ? category.name : ""
onSearchChanged: { onSearchChanged: {
if (search.length === 0)
Navigation.openHome()
appsModel.sortOrder = Qt.AscendingOrder appsModel.sortOrder = Qt.AscendingOrder
} }
signal clearSearch() signal clearSearch()
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
***************************************************************************/ ***************************************************************************/
import QtQuick 2.1 import QtQuick 2.1
import QtQuick.Layouts 1.1
Loader Loader
{ {
...@@ -28,5 +29,6 @@ Loader ...@@ -28,5 +29,6 @@ Loader
property Component componentFalse property Component componentFalse
property bool condition property bool condition
Layout.minimumHeight: item && item.Layout ? item.Layout.minimumHeight : 0
sourceComponent: condition ? componentTrue : componentFalse sourceComponent: condition ? componentTrue : componentFalse
} }
...@@ -56,59 +56,28 @@ Kirigami.GlobalDrawer { ...@@ -56,59 +56,28 @@ Kirigami.GlobalDrawer {
id: toploader id: toploader
condition: drawer.wideScreen condition: drawer.wideScreen
Layout.fillWidth: true Layout.fillWidth: true
componentTrue: TextField { componentFalse: Item {
Layout.minimumHeight: 1
Keys.forwardTo: [window.pageStack]
}
componentTrue: SearchField {
id: searchField id: searchField
visible: drawer.wideScreen
enabled: window.leftPage && (window.leftPage.searchFor != null || window.leftPage.hasOwnProperty("search")) enabled: window.leftPage && (window.leftPage.searchFor != null || window.leftPage.hasOwnProperty("search"))
Keys.forwardTo: [window.pageStack] Keys.forwardTo: [window.pageStack]
Component.onCompleted: { page: window.leftPage
searchField.forceActiveFocus()
}
Shortcut {
sequence: "Ctrl+F"
onActivated: {
searchField.forceActiveFocus()
searchField.selectAll()
}
}
placeholderText: (!enabled || !window.leftPage || window.leftPage.title.length === 0) ? i18n("Search...") : i18n("Search in '%1'...", window.leftPage.title)
onTextChanged: {
if(window.stack.depth > 0)
searchTimer.running = true
drawer.currentSearchText = text
}
Connections {
ignoreUnknownSignals: true
target: window.leftPage
onClearSearch: {
searchField.text = ""
}
}
Connections { onCurrentSearchTextChanged: {
target: window if (currentSearchText.length === 0)
onCurrentTopLevelChanged: { Navigation.openHome()
if (window.currentTopLevel.length > 0)
searchField.text = ""
}
}
Timer { var curr = window.leftPage;
id: searchTimer if (!curr.hasOwnProperty("search")) {
running: false Navigation.clearStack()
repeat: false Navigation.openApplicationList( { search: currentSearchText })
interval: 200 } else {
onTriggered: { curr.search = currentSearchText;
var curr = window.leftPage;
if (!curr.hasOwnProperty("search")) {
Navigation.clearStack()
Navigation.openApplicationList( { search: parent.text })
} else
curr.search = parent.text;
} }
} }
} }
......
/***************************************************************************
* Copyright © 2017 Aleix Pol Gonzalez <aleixpol@blue-systems.com> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License or (at your option) version 3 or any later version *
* accepted by the membership of KDE e.V. (or its successor approved *
* by the membership of KDE e.V.), which shall act as a proxy *
* defined in Section 14 of version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
import QtQuick 2.5
import QtQuick.Controls 2.1
TextField
{
property QtObject page
property string currentSearchText
placeholderText: (!enabled || !page || page.title.length === 0) ? i18n("Search...") : i18n("Search in '%1'...", window.leftPage.title)
Shortcut {
sequence: "Ctrl+F"
onActivated: {
searchField.forceActiveFocus()
searchField.selectAll()
}
}
onTextChanged: {
if (applicationWindow().stack.depth > 0)
searchTimer.running = true
}
Component.onCompleted: forceActiveFocus()
Connections {
ignoreUnknownSignals: true
target: page
onClearSearch: {
searchField.text = ""
}
}
Connections {
target: applicationWindow()
onCurrentTopLevelChanged: {
if (applicationWindow().currentTopLevel.length > 0)
searchField.text = ""
}
}
Timer {
id: searchTimer
running: false
repeat: false
interval: 200
onTriggered: {
currentSearchText = parent.text
}
}
}
...@@ -18,14 +18,34 @@ ...@@ -18,14 +18,34 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/ ***************************************************************************/
import QtQuick.Controls 1.1 import QtQuick 2.5
import org.kde.discover 2.0
ApplicationsListPage { ApplicationsListPage {
id: page id: searchPage
listHeaderExtra: TextField { signal shown()
Timer {
interval: 0
running: true
onTriggered: {
searchPage.shown()
}
}
listHeaderExtra: SearchField {
id: searchField
focus: true focus: true
onTextChanged: page.search = text
Connections {
ignoreUnknownSignals: true
target: searchPage
onShown: {
searchField.forceActiveFocus()
}
}
onCurrentSearchTextChanged: {
searchPage.search = currentSearchText
}
} }
} }
...@@ -17,9 +17,7 @@ ...@@ -17,9 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
import QtQuick 2.1
import org.kde.kirigami 2.0 import org.kde.kirigami 2.0
import "navigation.js" as Navigation
Action { Action {
property string component property string component
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
<file>qml/DiscoverDrawer.qml</file> <file>qml/DiscoverDrawer.qml</file>
<file>qml/ActionListItem.qml</file> <file>qml/ActionListItem.qml</file>
<file>qml/LoadingPage.qml</file> <file>qml/LoadingPage.qml</file>
<file>qml/SearchField.qml</file>
<file>qml/navigation.js</file> <file>qml/navigation.js</file>
</qresource> </qresource>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment