1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 10:42:29 +01:00

Fix Qt 6.5 beta3 Text field changes

This commit is contained in:
Elias Steurer 2023-02-24 09:38:55 +01:00
parent bca5f989b8
commit 531860884e

View File

@ -1,169 +1,31 @@
import QtQuick
import QtQuick.Window
import QtQuick.Controls.Material
import QtQuick.Controls as QQC
import Qt5Compat.GraphicalEffects
import QtQuick.Controls
import QtQuick.Layouts
import ScreenPlayApp
import ScreenPlay
Item {
id: root
property bool required: false
property bool dirty: false
ColumnLayout {
id:root
implicitHeight: 70
implicitWidth: 150
property alias text: textField.text
property alias placeholderText: txtPlaceholder.text
property alias placeholderText: textField.placeholderText
property bool required: false
signal editingFinished
height: 55
width: 150
state: {
if (textField.text.length > 0)
return "containsTextEditingFinished";
else
return "";
}
onEditingFinished: {
if (!root.required)
return;
}
Text {
id: txtPlaceholder
text: qsTr("Label")
font.family: App.settings.font
color: Material.primaryTextColor
opacity: 0.4
font.pointSize: 11
font.weight: Font.Medium
anchors {
top: parent.top
topMargin: 15
left: parent.left
leftMargin: 10
}
}
Timer {
id: timerSaveDelay
interval: 1000
onTriggered: root.editingFinished()
}
QQC.TextField {
TextField {
id: textField
function resetState() {
if (textField.text.length === 0)
root.state = "";
textField.focus = false;
}
font.family: App.settings.font
color: Material.secondaryTextColor
placeholderTextColor: Material.secondaryTextColor
width: parent.width
Keys.onEscapePressed: resetState()
onTextEdited: {
timerSaveDelay.start();
root.dirty = true;
}
onEditingFinished: {
resetState();
if (textField.text.length > 0)
root.state = "containsTextEditingFinished";
}
onPressed: {
root.state = "containsText";
}
anchors {
left: parent.left
right: parent.right
bottom: parent.bottom
}
font.weight: Font.Medium
Layout.fillWidth: true
}
Text {
id: requiredText
text: qsTr("*Required")
visible: root.required
text: root.required ? qsTr("*Required") : ""
font.family: App.settings.font
color: Material.secondaryTextColor
anchors {
top: textField.bottom
right: textField.right
}
color: Material.secondaryTextColor
Layout.alignment: Qt.AlignRight
}
states: [
State {
name: ""
PropertyChanges {
target: txtPlaceholder
font.pointSize: 11
color: Material.secondaryTextColor
anchors.topMargin: 15
anchors.leftMargin: 10
}
},
State {
name: "containsText"
PropertyChanges {
target: txtPlaceholder
font.pointSize: 8
opacity: 1
color: Material.accentColor
anchors.topMargin: 0
anchors.leftMargin: 0
}
},
State {
name: "containsTextEditingFinished"
PropertyChanges {
target: txtPlaceholder
font.pointSize: 8
color: Material.secondaryTextColor
opacity: 0.4
anchors.topMargin: 0
anchors.leftMargin: 0
}
}
]
transitions: [
Transition {
from: ""
to: "containsText"
reversible: true
PropertyAnimation {
target: txtPlaceholder
duration: 150
easing.type: Easing.InOutQuart
properties: "font.pointSize,anchors.topMargin,anchors.leftMargin,opacity,color"
}
},
Transition {
from: "containsText"
to: "containsTextEditingFinished"
reversible: true
PropertyAnimation {
target: txtPlaceholder
duration: 150
easing.type: Easing.OutSine
properties: "color,opacity"
}
}
]
}