LoginScreen.qml
4.78 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import QtQuick
import QtQuick.Controls.Basic
import QtQuick.Layouts
import "components"
import "." as App
Rectangle {
id: root
color: App.Theme.bgCanvas
focus: true
Keys.onReturnPressed: appState.login(usernameField.text, passwordField.text || "demo")
Keys.onEnterPressed: appState.login(usernameField.text, passwordField.text || "demo")
ColumnLayout {
anchors.centerIn: parent
width: 360
spacing: 0
// 标题
Label {
text: "登录"
font.family: App.Theme.fontFamily
font.pointSize: App.Theme.fontXxl
font.weight: Font.Bold
color: App.Theme.textPrimary
Layout.alignment: Qt.AlignHCenter
Layout.bottomMargin: 4
}
Label {
text: "珠宝壹佰图像生成器"
font.family: App.Theme.fontFamily
font.pointSize: App.Theme.fontSm
color: App.Theme.textSecondary
Layout.alignment: Qt.AlignHCenter
Layout.bottomMargin: App.Theme.space5
}
// 用户名
CaptionLabel {
text: "用户名"
Layout.bottomMargin: App.Theme.space2
}
ThemedTextField {
id: usernameField
text: "chaijin"
Layout.fillWidth: true
Layout.bottomMargin: App.Theme.space4
}
// 密码
CaptionLabel {
text: "密码"
Layout.bottomMargin: App.Theme.space2
}
ThemedTextField {
id: passwordField
echoMode: TextInput.Password
placeholderText: "••••••••"
Layout.fillWidth: true
Layout.bottomMargin: App.Theme.space2
}
// 复选行
RowLayout {
spacing: App.Theme.space4
Layout.fillWidth: true
Layout.bottomMargin: App.Theme.space5
CheckBox {
text: "记住用户名"
checked: true
font.family: App.Theme.fontFamily
font.pointSize: App.Theme.fontSm
contentItem: Text {
text: parent.text
font: parent.font
color: App.Theme.textPrimary
leftPadding: parent.indicator.width + 6
verticalAlignment: Text.AlignVCenter
}
indicator: Rectangle {
implicitWidth: 18
implicitHeight: 18
radius: 4
border.width: 1
border.color: parent.checked ? App.Theme.accent : App.Theme.borderStrong
color: parent.checked ? App.Theme.accent : App.Theme.bgSurface
Text {
anchors.centerIn: parent
text: "✓"
color: "white"
font.pixelSize: 12
font.weight: Font.Bold
visible: parent.parent.checked
}
}
}
CheckBox {
text: "记住密码"
checked: true
font.family: App.Theme.fontFamily
font.pointSize: App.Theme.fontSm
contentItem: Text {
text: parent.text
font: parent.font
color: App.Theme.textPrimary
leftPadding: parent.indicator.width + 6
verticalAlignment: Text.AlignVCenter
}
indicator: Rectangle {
implicitWidth: 18
implicitHeight: 18
radius: 4
border.width: 1
border.color: parent.checked ? App.Theme.accent : App.Theme.borderStrong
color: parent.checked ? App.Theme.accent : App.Theme.bgSurface
Text {
anchors.centerIn: parent
text: "✓"
color: "white"
font.pixelSize: 12
font.weight: Font.Bold
visible: parent.parent.checked
}
}
}
Item { Layout.fillWidth: true }
}
// 登录按钮
PrimaryButton {
text: "登录"
Layout.fillWidth: true
onClicked: appState.login(usernameField.text, passwordField.text || "demo")
}
Label {
id: hint
text: ""
font.family: App.Theme.fontFamily
font.pointSize: App.Theme.fontXs
color: App.Theme.textTertiary
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: App.Theme.space3
}
}
}