blob: 45c8b6ff0dd951c4e58ec1379715cbe63c4add02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
import QtQuick
import QtQuick.Templates as T
import QtQuick.Controls.impl
import QtQuick.Controls.Fluent.impl
T.TextField {
id: control
implicitWidth: implicitBackgroundWidth + leftInset + rightInset
|| Math.max(contentWidth, placeholder.implicitWidth) + leftPadding + rightPadding
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
contentHeight + topPadding + bottomPadding,
placeholder.implicitHeight + topPadding + bottomPadding)
readonly property string __currentState: [
!enabled && "disabled",
activeFocus && "focused",
enabled && !activeFocus && hovered && "hovered",
].filter(Boolean).join("_") || "normal"
readonly property var config: Config.controls.textfield[__currentState] || {}
topPadding: config.topPadding || 0
bottomPadding: config.bottomPadding || 0
leftPadding: config.leftPadding || 0
rightPadding: config.rightPadding || 0
topInset: -config.topInset || 0
bottomInset: -config.bottomInset || 0
leftInset: -config.leftInset || 0
rightInset: -config.rightInset || 0
color: control.palette.text
selectionColor: control.palette.highlight
selectedTextColor: control.palette.highlightedText
placeholderTextColor: control.palette.placeholderText
verticalAlignment: Text.AlignVCenter
PlaceholderText {
id: placeholder
x: control.leftPadding
y: control.topPadding
width: control.width - (control.leftPadding + control.rightPadding)
height: control.height - (control.topPadding + control.bottomPadding)
text: control.placeholderText
font: control.font
color: control.placeholderTextColor
verticalAlignment: control.verticalAlignment
horizontalAlignment: control.horizontalAlignment
visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter)
elide: Text.ElideRight
renderType: control.renderType
}
background: StyleImage {
imageConfig: control.config.background
Item{
visible: control.activeFocus
width: parent.width
height: 2
y: parent.height
FocusStroke {
width: parent.width
height: parent.height
radius: control.config.background.bottomOffset
color: control.palette.accent
}
}
}
}
|