Merge improvements made in QtQuick2.0 version of the components.

This commit is contained in:
Abdurrahman AVCI 2013-02-05 09:36:34 +00:00
parent 5f19fc7aad
commit 4b3c839983
2 changed files with 31 additions and 11 deletions

View File

@ -24,20 +24,19 @@
import QtQuick 1.1 import QtQuick 1.1
Item { FocusScope {
id: container id: container
width: 80; height: 30 width: 80; height: 30
property color color: "white" property color color: "white"
property color borderColor: "#ababab" property color borderColor: "#ababab"
property color focusColor: "#266294" property color focusColor: "#266294"
property color hoverColor: "#5692c4"
property alias font: textInput.font property alias font: textInput.font
property alias textColor: textInput.color property alias textColor: textInput.color
property variant items: [ "" ] property variant items: [ "" ]
property int index: 0 property int index: 0
onFocusChanged: textInput.focus = focus
function prevItem() { function prevItem() {
if (index > 0) if (index > 0)
index-- index--
@ -50,11 +49,24 @@ Item {
Rectangle { Rectangle {
id: main id: main
property bool hover: false
anchors.fill: parent anchors.fill: parent
color: container.color color: container.color
border.color: textInput.focus ? container.focusColor : container.borderColor border.color: hover ? container.hoverColor : (container.activeFocus ? container.focusColor : container.borderColor)
border.width: 1 border.width: 1
Behavior on border.color { ColorAnimation { duration: 200 } }
MouseArea {
hoverEnabled: true
anchors.fill: parent
onEntered: parent.hover = true
onExited: parent.hover = false
}
} }
TextInput { TextInput {
@ -64,7 +76,9 @@ Item {
anchors.leftMargin: 8 anchors.leftMargin: 8
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
clip: true
color: "black" color: "black"
focus: true
readOnly: true readOnly: true
text: container.items[container.index] text: container.items[container.index]

View File

@ -24,35 +24,38 @@
import QtQuick 1.1 import QtQuick 1.1
Item { FocusScope {
id: container id: container
width: 80; height: 30 width: 80; height: 30
property color color: "white" property color color: "white"
property color borderColor: "#ababab" property color borderColor: "#ababab"
property color focusColor: "#266294" property color focusColor: "#266294"
property color hoverColor: "#990b678c" property color hoverColor: "#5692c4"
property alias font: textInput.font property alias font: textInput.font
property alias textColor: textInput.color property alias textColor: textInput.color
property alias echoMode: textInput.echoMode property alias echoMode: textInput.echoMode
property alias text: textInput.text property alias text: textInput.text
onFocusChanged: textInput.focus = focus
Rectangle { Rectangle {
id: border id: border
property bool hover: false
anchors.fill: parent anchors.fill: parent
color: container.color color: container.color
border.color: textInput.focus ? container.focusColor : container.borderColor border.color: hover ? container.hoverColor : (container.activeFocus ? container.focusColor : container.borderColor)
border.width: 1 border.width: 1
Behavior on border.color { ColorAnimation { duration: 200 } }
MouseArea { MouseArea {
hoverEnabled: true hoverEnabled: true
anchors.fill: parent anchors.fill: parent
onEntered: parent.border.color = container.hoverColor onEntered: parent.hover = true
onExited: parent.border.color = textInput.focus ? container.focusColor : container.borderColor onExited: parent.hover = false
} }
} }
@ -63,6 +66,9 @@ Item {
color: "black" color: "black"
clip: true
focus: true
passwordCharacter: "\u25cf" passwordCharacter: "\u25cf"
} }
} }