Something went wrong. Try again.
my over complex system configurations
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697import QtQuickimport QtQuick.Layoutsimport QtQuick.Controls.Basicimport qs.data
Rectangle { id: root
property alias text: field.text property alias placeholder: field.placeholderText property alias input: field property bool password: false property bool revealable: password property bool mono: false property bool error: false property bool clearOnEscape: false property string icon: "" property int fontSize: 13 default property alias trailing: extras.data
signal accepted() signal escaped() signal editingFinished()
function takeFocus(): void { field.forceActiveFocus(); } function shake(): void { shakeAnim.restart(); }
property real shakeOffset: 0 transform: Translate { x: root.shakeOffset }
SequentialAnimation { id: shakeAnim NumberAnimation { target: root; property: "shakeOffset"; to: -10; duration: 50 } NumberAnimation { target: root; property: "shakeOffset"; to: 10; duration: 70 } NumberAnimation { target: root; property: "shakeOffset"; to: -6; duration: 60 } NumberAnimation { target: root; property: "shakeOffset"; to: 0; duration: 50 } }
implicitHeight: 40 radius: Theme.radiusSm color: Theme.colors.surfaceRaised border.width: 1 border.color: error ? Theme.colors.error : field.activeFocus ? Theme.colors.accent : Theme.colors.borderStrong opacity: enabled ? 1 : 0.5
RowLayout { anchors { fill: parent; leftMargin: 12; rightMargin: 4 } spacing: 6
MyIcon { visible: root.icon !== "" icon: root.icon size: 12 color: Theme.colors.textSubtle }
TextField { id: field Layout.fillWidth: true echoMode: root.password && !reveal.revealed ? TextInput.Password : TextInput.Normal placeholderTextColor: Theme.colors.textSubtle color: Theme.colors.text selectByMouse: true selectionColor: Theme.colors.accent selectedTextColor: Theme.colors.textOnAccent font { family: root.mono ? Theme.fonts.mono : Theme.fonts.sans; pixelSize: root.fontSize } background: null padding: 0 verticalAlignment: TextInput.AlignVCenter onAccepted: root.accepted() onEditingFinished: root.editingFinished() Keys.onEscapePressed: (e) => { e.accepted = root.clearOnEscape && text !== ""; if (e.accepted) text = ""; else root.escaped(); } }
IconButton { id: reveal property bool revealed: false visible: root.revealable icon: revealed ? "view-conceal-symbolic" : "view-reveal-symbolic" size: 14 color: Theme.colors.textMuted onClicked: revealed = !revealed }
RowLayout { id: extras spacing: 4 } }}