/** Copyright 2014 Sebastian KΓΌgler <sebas@kde.org>** 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) any later version.** 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, write to the Free Software Foundation, Inc.,* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.*/import QtQuick 2.0import org.kde.plasma.core 2.0 as PlasmaCoreimport org.kde.plasma.components 2.0 as PlasmaComponentsimport org.kde.plasma.extras 2.0 as PlasmaExtrasimport org.kde.kcoreaddons 1.0 as KCoreAddonsItem {id: headerimplicitHeight: units.gridUnit * 5property alias query: queryField.textproperty Item input: queryFieldKCoreAddons.KUser {id: kuser}state: (header.query != "") ? "query" : "hint"Timer {id: labelTimerinterval: 8000repeat: truerunning: (header.state === "hint" || header.state === "info") && plasmoid.expanded && (header.query === "")onTriggered: {if (header.state == "info") {header.state = "hint";} else if (header.state == "hint") {header.state = "info";}}}//Rectangle { color: "orange"; visible: root.debug; anchors.fill: parent; opacity: 0.3 }Image {id: faceIconsource: kuser.faceIconUrlcache: falsevisible: source != ""width: units.gridUnit * 3height: widthanchors {top: parent.topleft: parent.lefttopMargin: units.gridUnitleftMargin: units.gridUnit}//Rectangle { color: "green"; opacity: 0.3; anchors.fill: parent; visible: root.debug; }}PlasmaCore.IconItem {source: "user-identity"visible: faceIcon.source == ""width: units.gridUnit * 3height: widthanchors {top: faceIcon.topright: faceIcon.rightrightMargin: -units.gridUnit/2}}PlasmaExtras.Heading {id: nameLabellevel: 2text: kuser.fullNameelide: Text.ElideRightverticalAlignment: Text.AlignTopheight: paintedHeightanchors {left: faceIcon.righttop: faceIcon.topright: parent.rightleftMargin: units.gridUnitrightMargin: units.gridUnit}}Item {id: searchWidgetproperty int animationDuration: units.longDurationproperty real normalOpacity: .6property int yOffset: height / 2height: infoLabel.heightanchors {left: nameLabel.lefttop: nameLabel.bottomright: nameLabel.right}PlasmaComponents.Label {id: infoLabelanchors {left: parent.leftright: parent.right}verticalAlignment: Text.AlignBottomtext: kuser.os != "" ? i18n("%2@%3 (%1)", kuser.os, kuser.loginName, kuser.host) : i18n("%1@%2", kuser.loginName, kuser.host)elide: Text.ElideRightBehavior on opacity { NumberAnimation { duration: searchWidget.animationDuration; easing.type: Easing.InOutQuad; } }Behavior on y { NumberAnimation { duration: searchWidget.animationDuration; easing.type: Easing.InOutQuad; } }}PlasmaComponents.Label {id: hintLabelanchors {left: parent.leftright: parent.right}verticalAlignment: Text.AlignBottomtext: i18nc("Type is a verb here, not a noun", "Type to search...")Behavior on opacity { NumberAnimation { duration: searchWidget.animationDuration; easing.type: Easing.InOutQuad; } }Behavior on y { NumberAnimation { duration: searchWidget.animationDuration; easing.type: Easing.InOutQuad; } }}PlasmaComponents.TextField {id: queryFieldanchors.fill: parentclearButtonShown: truevisible: opacity > 0Behavior on opacity { NumberAnimation { duration: searchWidget.animationDuration / 4 } }onTextChanged: {if (root.state != "Search") {root.previousState = root.state;root.state = "Search";}if (text == "") {root.state = root.previousState;root.forceActiveFocus();header.state = "info";} else {header.state = "query";}}}}states: [State {name: "info"PropertyChanges {target: infoLabelopacity: searchWidget.normalOpacityy: 0}PropertyChanges {target: hintLabelopacity: 0y: searchWidget.yOffset}PropertyChanges {target: queryFieldopacity: 0}},State {name: "hint"PropertyChanges {target: infoLabely: -searchWidget.yOffsetopacity: 0}PropertyChanges {target: hintLabely: 0opacity: searchWidget.normalOpacity}PropertyChanges {target: queryFieldopacity: 0}},State {name: "query"PropertyChanges {target: infoLabelopacity: 0}PropertyChanges {target: hintLabelopacity: 0}PropertyChanges {target: queryFieldopacity: 1}}] // states}