From 531860884efc96b2826cbd890f817a5e8d71bf79 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Fri, 24 Feb 2023 09:38:55 +0100 Subject: [PATCH] Fix Qt 6.5 beta3 Text field changes --- ScreenPlayUtil/qml/TextField.qml | 168 +++---------------------------- 1 file changed, 15 insertions(+), 153 deletions(-) diff --git a/ScreenPlayUtil/qml/TextField.qml b/ScreenPlayUtil/qml/TextField.qml index 086d8b9b..b3147361 100644 --- a/ScreenPlayUtil/qml/TextField.qml +++ b/ScreenPlayUtil/qml/TextField.qml @@ -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" - } - } - ] }