editbox improvements
This commit is contained in:
parent
1ef634d25d
commit
742eefd950
|
@ -9,8 +9,6 @@ TextFieldStyle {
|
|||
|
||||
background: Rectangle {
|
||||
radius: 2
|
||||
implicitWidth: root.width
|
||||
implicitHeight: ptToPx(10 * gcd.themeScale)
|
||||
color: windowItem.cwtch_background_color
|
||||
border.color: windowItem.cwtch_color
|
||||
}
|
||||
|
|
|
@ -5,37 +5,45 @@ import QtQuick.Controls.Material 2.0
|
|||
import QtQuick.Layouts 1.3
|
||||
|
||||
|
||||
ColumnLayout {
|
||||
Item {
|
||||
id: root
|
||||
width: parent.width
|
||||
height: lbl.height
|
||||
implicitHeight: lbl.height
|
||||
|
||||
property alias text: lbl.text
|
||||
signal updated
|
||||
|
||||
|
||||
Text { // DISPLAY THE TEXT IN READONLY MODE
|
||||
id: lbl
|
||||
text: root.text
|
||||
fontSizeMode: Text.HorizontalFit
|
||||
font.pixelSize: 36
|
||||
minimumPixelSize: 8
|
||||
Layout.minimumWidth: parent.width
|
||||
Layout.maximumWidth: parent.width
|
||||
width: parent.width / 2
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
textFormat: Text.PlainText
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
||||
Image {
|
||||
id: img
|
||||
anchors.left: lbl.right
|
||||
anchors.leftMargin: 3
|
||||
source: "qrc:/qml/images/fontawesome/solid/edit.svg"
|
||||
height: 16
|
||||
sourceSize.height: 16
|
||||
}
|
||||
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: lbl
|
||||
MouseArea {
|
||||
anchors.fill: lbl
|
||||
|
||||
onClicked: {
|
||||
lbl.visible = false
|
||||
txt.visible = true
|
||||
txt.text = lbl.text
|
||||
txt.selectAll()
|
||||
txt.focus = true
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
console.log("click")
|
||||
lbl.visible = img.visible = false
|
||||
txt.visible = true
|
||||
txt.text = lbl.text
|
||||
txt.selectAll()
|
||||
txt.focus = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,10 +52,9 @@ ColumnLayout {
|
|||
text: root.text
|
||||
visible: false
|
||||
selectByMouse: true
|
||||
Layout.minimumWidth: parent.width
|
||||
Layout.maximumWidth: parent.width
|
||||
font.pixelSize: lbl.font.pixelSize
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
|
||||
onActiveFocusChanged: {
|
||||
if (!activeFocus) {
|
||||
|
@ -64,7 +71,7 @@ ColumnLayout {
|
|||
function save() {
|
||||
root.text = txt.text
|
||||
txt.visible = false
|
||||
lbl.visible = true
|
||||
lbl.visible = img.visible = true
|
||||
root.updated(txt.text)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,10 +101,11 @@ ColumnLayout {
|
|||
InplaceEditText { // USER NICKNAME
|
||||
id: lblNick
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
width: parent.width
|
||||
Layout.minimumWidth: parent.width
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
onUpdated: {
|
||||
nick = lblNick.text
|
||||
//nick = lblNick.text
|
||||
gcd.updateNick(lblNick.text)
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue