TextField moved. Fixed sound on hovering check box

This commit is contained in:
vladest 2017-12-30 19:55:52 +01:00
parent f5f19ea67f
commit c953251cfe
3 changed files with 79 additions and 65 deletions

View file

@ -36,7 +36,7 @@ Original.CheckBox {
onHoveredChanged: { onHoveredChanged: {
if (hovered) { if (hovered) {
tabletInterface.playSound(TabletEnums.ButtonHover); Tablet.playSound(TabletEnums.ButtonHover);
} }
} }

View file

@ -8,9 +8,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
import QtQuick 2.5 import QtQuick 2.7
import QtQuick.Controls 1.4 import QtQuick.Controls 2.2
import QtQuick.Controls.Styles 1.4
import "../styles-uit" import "../styles-uit"
import "../controls-uit" as HifiControls import "../controls-uit" as HifiControls
@ -27,8 +26,7 @@ TextField {
property bool hasRoundedBorder: false property bool hasRoundedBorder: false
property bool error: false; property bool error: false;
property bool hasClearButton: false; property bool hasClearButton: false;
property alias textColor: textField.color
placeholderText: textField.placeholderText
FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; }
font.family: firaSansSemiBold.name font.family: firaSansSemiBold.name
@ -42,41 +40,56 @@ TextField {
// workaround for https://bugreports.qt.io/browse/QTBUG-49297 // workaround for https://bugreports.qt.io/browse/QTBUG-49297
Keys.onPressed: { Keys.onPressed: {
switch (event.key) { switch (event.key) {
case Qt.Key_Return: case Qt.Key_Return:
case Qt.Key_Enter: case Qt.Key_Enter:
event.accepted = true; event.accepted = true;
// emit accepted signal manually // emit accepted signal manually
if (acceptableInput) { if (acceptableInput) {
accepted(); accepted();
} }
} }
} }
style: TextFieldStyle { Text {
textColor: { id: placeholder
if (isLightColorScheme) { x: textField.leftPadding
if (textField.activeFocus) { y: textField.topPadding
hifi.colors.black width: textField.width - (textField.leftPadding + textField.rightPadding)
} else { height: textField.height - (textField.topPadding + textField.bottomPadding)
hifi.colors.lightGray
} text: textField.placeholderText
} else if (isFaintGrayColorScheme) { font: textField.font
if (textField.activeFocus) { color: textField.placeholderTextColor
hifi.colors.black verticalAlignment: textField.verticalAlignment
} else { visible: !textField.length && !textField.preeditText && (!textField.activeFocus || textField.horizontalAlignment !== Qt.AlignHCenter)
hifi.colors.lightGray elide: Text.ElideRight
} }
color: {
if (isLightColorScheme) {
if (textField.activeFocus) {
hifi.colors.black
} else { } else {
if (textField.activeFocus) { hifi.colors.lightGray
hifi.colors.white }
} else { } else if (isFaintGrayColorScheme) {
hifi.colors.lightGrayText if (textField.activeFocus) {
} hifi.colors.black
} else {
hifi.colors.lightGray
}
} else {
if (textField.activeFocus) {
hifi.colors.white
} else {
hifi.colors.lightGrayText
} }
} }
background: Rectangle { }
color: {
background: Rectangle {
color: {
if (isLightColorScheme) { if (isLightColorScheme) {
if (textField.activeFocus) { if (textField.activeFocus) {
hifi.colors.white hifi.colors.white
@ -97,45 +110,46 @@ TextField {
} }
} }
} }
border.color: textField.error ? hifi.colors.redHighlight : border.color: textField.error ? hifi.colors.redHighlight :
(textField.activeFocus ? hifi.colors.primaryHighlight : (isFaintGrayColorScheme ? hifi.colors.lightGrayText : hifi.colors.lightGray)) (textField.activeFocus ? hifi.colors.primaryHighlight : (isFaintGrayColorScheme ? hifi.colors.lightGrayText : hifi.colors.lightGray))
border.width: textField.activeFocus || hasRoundedBorder || textField.error ? 1 : 0 border.width: textField.activeFocus || hasRoundedBorder || textField.error ? 1 : 0
radius: isSearchField ? textField.height / 2 : (hasRoundedBorder ? 4 : 0) radius: isSearchField ? textField.height / 2 : (hasRoundedBorder ? 4 : 0)
HiFiGlyphs { HiFiGlyphs {
text: hifi.glyphs.search text: hifi.glyphs.search
color: textColor color: textColor
size: hifi.fontSizes.textFieldSearchIcon size: hifi.fontSizes.textFieldSearchIcon
anchors.left: parent.left anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: hifi.dimensions.textPadding - 2 anchors.leftMargin: hifi.dimensions.textPadding - 2
visible: isSearchField visible: isSearchField
} }
HiFiGlyphs { HiFiGlyphs {
text: hifi.glyphs.error text: hifi.glyphs.error
color: textColor color: textColor
size: 40 size: 40
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: hifi.dimensions.textPadding - 2 anchors.rightMargin: hifi.dimensions.textPadding - 2
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
visible: hasClearButton && textField.text !== ""; visible: hasClearButton && textField.text !== "";
MouseArea { MouseArea {
anchors.fill: parent; anchors.fill: parent;
onClicked: { onClicked: {
textField.text = ""; textField.text = "";
}
} }
} }
} }
placeholderTextColor: isFaintGrayColorScheme ? hifi.colors.lightGrayText : hifi.colors.lightGray
selectedTextColor: hifi.colors.black
selectionColor: hifi.colors.primaryHighlight
padding.left: (isSearchField ? textField.height - 2 : 0) + hifi.dimensions.textPadding
padding.right: (hasClearButton ? textField.height - 2 : 0) + hifi.dimensions.textPadding
} }
property color placeholderTextColor: isFaintGrayColorScheme ? hifi.colors.lightGrayText : hifi.colors.lightGray
selectedTextColor: hifi.colors.black
selectionColor: hifi.colors.primaryHighlight
leftPadding: (isSearchField ? textField.height - 2 : 0) + hifi.dimensions.textPadding
rightPadding: (hasClearButton ? textField.height - 2 : 0) + hifi.dimensions.textPadding
HifiControls.Label { HifiControls.Label {
id: textFieldLabel id: textFieldLabel
text: textField.label text: textField.label

Binary file not shown.