diff --git a/data/images/inputfield-border.svg b/data/images/inputfield-border.svg new file mode 100644 index 000000000..3f3ff841c --- /dev/null +++ b/data/images/inputfield-border.svg @@ -0,0 +1,145 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/qml/tomahawkimports/FlexibleHeader.qml b/data/qml/tomahawkimports/FlexibleHeader.qml index e30e2471f..6f6dd5c38 100644 --- a/data/qml/tomahawkimports/FlexibleHeader.qml +++ b/data/qml/tomahawkimports/FlexibleHeader.qml @@ -172,6 +172,8 @@ Rectangle { id: searchField visible: root.showSearchField anchors.verticalCenter: parent.verticalCenter + placeholderText: "Search..." + showSearchIcon: true } ToggleViewButtons { id: toggleViewButtons diff --git a/data/qml/tomahawkimports/InputField.qml b/data/qml/tomahawkimports/InputField.qml index e982aa440..f95a65286 100644 --- a/data/qml/tomahawkimports/InputField.qml +++ b/data/qml/tomahawkimports/InputField.qml @@ -4,20 +4,82 @@ Rectangle { id: root color: "white" border.color: "black" - border.width: 2 + border.width: defaultFontHeight * 0.1 + radius: defaultFontHeight * 0.25 - height: textInput.height * 1.2 + height: textInput.height * 1.4 width: 300 - property alias text: textInput.text + property bool showSearchIcon: false + property string text: "" + property string placeholderText: "" + property int spacing: defaultFontHeight * 0.2 signal accepted( string text ) - TextInput { - id: textInput - width: parent.width - defaultFontHeight - anchors.centerIn: parent + Image { + id: searchIcon + anchors { + left: parent.left + leftMargin: root.spacing + verticalCenter: parent.verticalCenter + } + height: parent.height * 0.6 + width: root.showSearchIcon ? height : 0 + smooth: true + source: "../../images/search-icon.svg" + } - onAccepted: root.accepted( text ); + Item { + id: textItem + anchors.left: searchIcon.right + anchors.leftMargin: root.spacing + anchors.right: clearIcon.right + anchors.rightMargin: root.spacing + height: textInput.height + anchors.verticalCenter: parent.verticalCenter + TextInput { + id: textInput + width: parent.width + anchors.centerIn: parent + text: root.text + + onAccepted: root.accepted( text ); + onTextChanged: root.text = text; + } + Text { + width: parent.width + anchors.centerIn: parent + text: root.text.length === 0 ? root.placeholderText : "" + color: "lightgray" + } + } + + Image { + id: clearIcon + anchors { + right: parent.right + rightMargin: root.spacing + verticalCenter: parent.verticalCenter + } + height: parent.height * 0.8 + width: (root.showSearchIcon && root.text.length > 0) ? height : 0 + smooth: true + source: "../../images/search-box-dismiss-x.svg" + + MouseArea { + anchors.fill: parent + onClicked: textInput.text = "" + } + } + + + BorderImage { + source: "../../images/inputfield-border.svg" + anchors.fill: parent + anchors.margins: root.radius * 0.1 + clip: true + border.left: defaultFontHeight/4; border.top: defaultFontHeight/4 + border.right: defaultFontHeight/4; border.bottom: defaultFontHeight/4 } } diff --git a/resources.qrc b/resources.qrc index 9b6b9aa23..5034fb5db 100644 --- a/resources.qrc +++ b/resources.qrc @@ -167,5 +167,7 @@ data/qml/tomahawkimports/FlexibleHeader.qml data/qml/tomahawkimports/ToggleViewButtons.qml data/qml/DeclarativeHeader.qml + data/images/inputfield-border.svg + data/images/search-box-dismiss-x.svg