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