1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
/*
* Copyright 2011 Canonical Ltd.
*
* Authors:
* Olivier Tilloy <olivier@tilloy.net>
*
* 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; version 3.
*
* 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 1.0
FocusScope {
id: searchbox
property alias text: textinput.text
signal activated
height: textinput.height + 7
SystemPalette {
id: activePalette
colorGroup: SystemPalette.Active
}
Rectangle {
anchors.fill: parent
color: activePalette.base
radius: 4
border.color: parent.activeFocus ? activePalette.highlight : activePalette.mid
}
Image {
id: searchicon
source: "file:///usr/share/icons/Humanity/actions/16/edit-find.svg"
asynchronous: true
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.margins: 4
fillMode: Image.PreserveAspectFit
sourceSize.height: height
opacity: searchmousearea.containsMouse ? 0.8 : 1.0
MouseArea {
id: searchmousearea
anchors.fill: parent
hoverEnabled: true
onClicked: textinput.accepted()
}
}
TextInput {
id: textinput
anchors.verticalCenter: parent.verticalCenter
anchors.left: searchicon.right
anchors.right: clearicon.left
anchors.margins: 4
focus: true
selectByMouse: true
onAccepted: if (textinput.text.length > 0) searchbox.activated()
}
Image {
id: clearicon
source: "file:///usr/share/icons/Humanity/actions/16/edit-clear.svg"
asynchronous: true
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.margins: 4
fillMode: Image.PreserveAspectFit
sourceSize.height: height
visible: textinput.text.length > 0
opacity: clearmousearea.containsMouse ? 0.8 : 1.0
MouseArea {
id: clearmousearea
anchors.fill: parent
hoverEnabled: true
onClicked: textinput.text = ""
}
}
}
|