Warning, /plasma/milou/plasmoid/package/contents/ui/SearchField.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * This file is part of the KDE Milou Project 0003 * SPDX-FileCopyrightText: 2013-2014 Vishesh Handa <me@vhanda.in> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 * 0007 */ 0008 0009 import QtQuick 2.1 0010 0011 import org.kde.plasma.components 3.0 as PlasmaComponents3 0012 import "globals.js" as Globals 0013 0014 /* 0015 * The SearchField is a simple text field widget. The only complex part 0016 * is the internal timer to reduce the number of textChanged signals 0017 * using searchTextChanged. 0018 */ 0019 Item { 0020 signal searchTextChanged() 0021 signal close() 0022 property alias text: textField.text 0023 0024 height: childrenRect.height 0025 width: Globals.PlasmoidWidth 0026 0027 PlasmaComponents3.TextField { 0028 id: textField 0029 clearButtonShown: true 0030 placeholderText: i18n("Search...") 0031 anchors { 0032 left: parent.left 0033 right: parent.right 0034 top: parent.top 0035 } 0036 0037 focus: true 0038 Keys.forwardTo: listView 0039 0040 // We do not want to send the text instantly as that would result 0041 // in too many queries. Therefore we add a small 200msec delay 0042 Timer { 0043 id: timer 0044 interval: 200 0045 onTriggered: searchTextChanged() 0046 } 0047 0048 onTextChanged: timer.restart() 0049 } 0050 0051 function selectAll() { 0052 textField.selectAll() 0053 } 0054 0055 function setFocus() { 0056 textField.focus = true 0057 } 0058 0059 Keys.onEscapePressed: { 0060 if (textField.text) { 0061 textField.text = "" 0062 } else { 0063 close() 0064 } 0065 } 0066 }