on xenial help sign in
Make placeholder text the right color
01653b5Michael Terry
qml/Greeter/GreeterPrompt.qml+24−2
@@ -82,9 +82,10 @@ FocusScope {
82
82
83 inputMethodHints: root.isAlphanumeric ? Qt.ImhNone : Qt.ImhDigitsOnly
83 inputMethodHints: root.isAlphanumeric ? Qt.ImhNone : Qt.ImhDigitsOnly
84 echoMode: root.isSecret ? TextInput.Password : TextInput.Normal
84 echoMode: root.isSecret ? TextInput.Password : TextInput.Normal
85− placeholderText: " " + root.text // add some spacing here
86 hasClearButton: false
85 hasClearButton: false
87
86
87+ readonly property real frameSpacing: units.gu(0.5)
88+
88 style: Item {
89 style: Item {
89 property color color: d.textColor
90 property color color: d.textColor
90 property color selectedTextColor: d.selectedColor
91 property color selectedTextColor: d.selectedColor
@@ -92,12 +93,13 @@ FocusScope {
92 property color borderColor: "transparent"
93 property color borderColor: "transparent"
93 property color backgroundColor: "transparent"
94 property color backgroundColor: "transparent"
94 property color errorColor: d.errorColor
95 property color errorColor: d.errorColor
95− property real frameSpacing: units.gu(0.5)
96+ property real frameSpacing: passwordInput.frameSpacing
96 anchors.fill: parent
97 anchors.fill: parent
97 }
98 }
98
99
99 secondaryItem: [
100 secondaryItem: [
100 Icon {
101 Icon {
102+ id: capsIcon
101 name: "keyboard-caps-enabled"
103 name: "keyboard-caps-enabled"
102 height: units.gu(3)
104 height: units.gu(3)
103 width: units.gu(3)
105 width: units.gu(3)
@@ -124,5 +126,25 @@ FocusScope {
124 }
126 }
125 }
127 }
126 }
128 }
129+
130+ // We use our own custom placeholder label instead of the standard
131+ // TextField one because the standard one hardcodes baseText as the
132+ // palette color, whereas we want raisedSecondaryText.
133+ Label {
134+ id: hint
135+ anchors {
136+ left: parent.left
137+ right: parent.right
138+ verticalCenter: parent.verticalCenter
139+ leftMargin: units.gu(1.5)
140+ rightMargin: anchors.leftMargin +
141+ (capsIcon.visible ? capsIcon.width + passwordInput.frameSpacing
142+ : 0)
143+ }
144+ text: root.text
145+ visible: passwordInput.text == "" && !passwordInput.inputMethodComposing
146+ color: theme.palette.normal.raisedSecondaryText
147+ elide: Text.ElideRight
148+ }
127 }
149 }
128}
150}