mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 19:36:50 +02:00
Merge branch 'discovery_April2018' of github.com:zfox23/hifi into discovery_April2018
This commit is contained in:
commit
ee9519bf1b
1 changed files with 71 additions and 99 deletions
|
@ -8,8 +8,9 @@
|
||||||
// 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.7
|
import QtQuick 2.5
|
||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 1.4
|
||||||
|
import QtQuick.Controls.Styles 1.4
|
||||||
|
|
||||||
import "../styles-uit"
|
import "../styles-uit"
|
||||||
import "../controls-uit" as HifiControls
|
import "../controls-uit" as HifiControls
|
||||||
|
@ -28,17 +29,11 @@ TextField {
|
||||||
property int roundedBorderRadius: 4
|
property int roundedBorderRadius: 4
|
||||||
property bool error: false;
|
property bool error: false;
|
||||||
property bool hasClearButton: false;
|
property bool hasClearButton: false;
|
||||||
property alias textColor: textField.color
|
|
||||||
property string leftPermanentGlyph: "";
|
property string leftPermanentGlyph: "";
|
||||||
property string centerPlaceholderGlyph: "";
|
property string centerPlaceholderGlyph: "";
|
||||||
|
|
||||||
placeholderText: textField.placeholderText
|
placeholderText: textField.placeholderText
|
||||||
|
|
||||||
property bool rightAnchorSet: false;
|
|
||||||
anchors.onRightChanged: {
|
|
||||||
rightAnchorSet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
font.family: "Fira Sans"
|
font.family: "Fira Sans"
|
||||||
font.pixelSize: hifi.fontSizes.textFieldInput
|
font.pixelSize: hifi.fontSizes.textFieldInput
|
||||||
height: implicitHeight + 3 // Make surrounding box higher so that highlight is vertically centered.
|
height: implicitHeight + 3 // Make surrounding box higher so that highlight is vertically centered.
|
||||||
|
@ -49,56 +44,42 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
style: TextFieldStyle {
|
||||||
id: placeholder
|
id: style;
|
||||||
x: textField.leftPadding
|
textColor: {
|
||||||
y: textField.topPadding
|
if (isLightColorScheme) {
|
||||||
width: textField.width - (textField.leftPadding + textField.rightPadding)
|
if (textField.activeFocus) {
|
||||||
height: textField.height - (textField.topPadding + textField.bottomPadding)
|
hifi.colors.black
|
||||||
|
} else {
|
||||||
text: textField.placeholderText
|
hifi.colors.lightGray
|
||||||
font: textField.font
|
}
|
||||||
color: textField.placeholderTextColor
|
} else if (isFaintGrayColorScheme) {
|
||||||
verticalAlignment: textField.verticalAlignment
|
if (textField.activeFocus) {
|
||||||
visible: !textField.length && !textField.preeditText && (!textField.activeFocus || textField.horizontalAlignment !== Qt.AlignHCenter)
|
hifi.colors.black
|
||||||
elide: Text.ElideRight
|
} else {
|
||||||
}
|
hifi.colors.lightGray
|
||||||
|
}
|
||||||
color: {
|
|
||||||
if (isLightColorScheme) {
|
|
||||||
if (textField.activeFocus) {
|
|
||||||
hifi.colors.black
|
|
||||||
} else {
|
} else {
|
||||||
hifi.colors.lightGray
|
if (textField.activeFocus) {
|
||||||
}
|
hifi.colors.white
|
||||||
} else if (isFaintGrayColorScheme) {
|
} else {
|
||||||
if (textField.activeFocus) {
|
hifi.colors.lightGrayText
|
||||||
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
|
||||||
|
@ -119,22 +100,22 @@ TextField {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
border.color: textField.error ? hifi.colors.redHighlight :
|
border.color: textField.error ? hifi.colors.redHighlight :
|
||||||
(textField.activeFocus ? hifi.colors.primaryHighlight : (hasDefocusedBorder ? (isFaintGrayColorScheme ? hifi.colors.lightGrayText : hifi.colors.lightGray) : color))
|
(textField.activeFocus ? hifi.colors.primaryHighlight : (hasDefocusedBorder ? (isFaintGrayColorScheme ? hifi.colors.lightGrayText : hifi.colors.lightGray) : color))
|
||||||
border.width: textField.activeFocus || hasRoundedBorder || textField.error ? 1 : 0
|
border.width: textField.activeFocus || hasRoundedBorder || textField.error ? 1 : 0
|
||||||
radius: isSearchField ? textField.height / 2 : (hasRoundedBorder ? roundedBorderRadius : 0)
|
radius: isSearchField ? textField.height / 2 : (hasRoundedBorder ? roundedBorderRadius : 0)
|
||||||
|
|
||||||
HiFiGlyphs {
|
HiFiGlyphs {
|
||||||
text: textField.leftPermanentGlyph;
|
text: textField.leftPermanentGlyph;
|
||||||
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: text;
|
visible: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
HiFiGlyphs {
|
HiFiGlyphs {
|
||||||
text: textField.centerPlaceholderGlyph;
|
text: textField.centerPlaceholderGlyph;
|
||||||
color: textColor;
|
color: textColor;
|
||||||
size: parent.height;
|
size: parent.height;
|
||||||
|
@ -144,57 +125,48 @@ TextField {
|
||||||
}
|
}
|
||||||
|
|
||||||
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: hasRoundedBorder ? textField.height / 2 : ((isSearchField || textField.leftPermanentGlyph !== "") ? 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: hasRoundedBorder ? textField.height / 2 : ((isSearchField || textField.leftPermanentGlyph !== "") ? 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
|
||||||
colorScheme: textField.colorScheme
|
colorScheme: textField.colorScheme
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
Binding on anchors.right {
|
|
||||||
when: rightAnchorSet
|
|
||||||
value: textField.right
|
|
||||||
}
|
|
||||||
Binding on wrapMode {
|
|
||||||
when: rightAnchorSet
|
|
||||||
value: Text.WordWrap
|
|
||||||
}
|
|
||||||
|
|
||||||
anchors.bottom: parent.top
|
anchors.bottom: parent.top
|
||||||
anchors.bottomMargin: 3
|
anchors.bottomMargin: 3
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
visible: label != ""
|
visible: label != ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue