FluentUI/example/qml-Qt6/window/LoginWindow.qml

60 lines
1.5 KiB
QML
Raw Normal View History

2023-08-24 15:50:37 +08:00
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import FluentUI
2024-01-25 17:26:50 +08:00
import "../component"
2023-08-24 15:50:37 +08:00
2023-10-08 18:19:08 +08:00
FluWindow {
2023-08-24 15:50:37 +08:00
2024-03-09 15:35:48 +08:00
id: window
title: qsTr("Login")
2023-08-24 15:50:37 +08:00
width: 400
height: 400
fixSize: true
2024-03-06 00:34:43 +08:00
modality: Qt.ApplicationModal
2023-08-24 15:50:37 +08:00
onInitArgument:
(argument)=>{
textbox_uesrname.updateText(argument.username)
textbox_password.focus = true
}
ColumnLayout{
anchors{
left: parent.left
right: parent.right
verticalCenter: parent.verticalCenter
}
FluAutoSuggestBox{
2024-03-09 15:35:48 +08:00
id: textbox_uesrname
2023-08-24 15:50:37 +08:00
items:[{title:"Admin"},{title:"User"}]
2024-03-09 15:35:48 +08:00
placeholderText: qsTr("Please enter the account")
2023-08-24 15:50:37 +08:00
Layout.preferredWidth: 260
Layout.alignment: Qt.AlignHCenter
}
FluTextBox{
2024-03-09 15:35:48 +08:00
id: textbox_password
2023-08-24 15:50:37 +08:00
Layout.topMargin: 20
Layout.preferredWidth: 260
2024-03-09 15:35:48 +08:00
placeholderText: qsTr("Please enter your password")
2023-08-24 15:50:37 +08:00
echoMode:TextInput.Password
Layout.alignment: Qt.AlignHCenter
}
FluFilledButton{
2024-03-09 15:35:48 +08:00
text: qsTr("Login")
2023-08-24 15:50:37 +08:00
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: 20
onClicked:{
if(textbox_password.text === ""){
2024-03-09 15:35:48 +08:00
showError(qsTr("Please feel free to enter a password"))
2023-08-24 15:50:37 +08:00
return
}
onResult({password:textbox_password.text})
window.close()
}
}
}
}