2023-08-24 15:50:37 +08:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import QtQuick.Window
|
|
|
|
import FluentUI
|
2024-01-25 17:26:50 +08:00
|
|
|
import "../component"
|
|
|
|
import "../viewmodel"
|
2023-08-24 15:50:37 +08:00
|
|
|
|
|
|
|
FluScrollablePage{
|
2024-03-09 15:35:48 +08:00
|
|
|
|
|
|
|
title: qsTr("TextBox")
|
2023-08-24 15:50:37 +08:00
|
|
|
|
2023-09-12 22:55:42 +08:00
|
|
|
TextBoxViewModel{
|
|
|
|
id:viewModel
|
|
|
|
}
|
|
|
|
|
2023-08-24 15:50:37 +08:00
|
|
|
FluArea{
|
|
|
|
Layout.fillWidth: true
|
|
|
|
height: 68
|
|
|
|
paddings: 10
|
|
|
|
Layout.topMargin: 20
|
|
|
|
|
|
|
|
FluTextBox{
|
2024-03-09 15:35:48 +08:00
|
|
|
placeholderText: qsTr("Single-line Input Box")
|
|
|
|
disabled: text_box_switch.checked
|
2023-08-24 15:50:37 +08:00
|
|
|
cleanEnabled: true
|
2024-03-09 15:35:48 +08:00
|
|
|
text: viewModel.text1
|
2023-09-12 22:55:42 +08:00
|
|
|
onTextChanged: {
|
|
|
|
viewModel.text1 = text
|
|
|
|
}
|
2023-08-24 15:50:37 +08:00
|
|
|
anchors{
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
left: parent.left
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FluToggleSwitch{
|
2024-03-09 15:35:48 +08:00
|
|
|
id: text_box_switch
|
2023-08-24 15:50:37 +08:00
|
|
|
anchors{
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
right: parent.right
|
|
|
|
}
|
2024-03-09 15:35:48 +08:00
|
|
|
text: qsTr("Disabled")
|
2023-08-24 15:50:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CodeExpander{
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: -1
|
|
|
|
code:'FluTextBox{
|
2024-03-09 15:35:48 +08:00
|
|
|
placeholderText: qsTr("Single-line Input Box")
|
2023-08-24 15:50:37 +08:00
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
FluArea{
|
|
|
|
Layout.fillWidth: true
|
|
|
|
height: 68
|
|
|
|
paddings: 10
|
|
|
|
Layout.topMargin: 20
|
|
|
|
|
|
|
|
FluPasswordBox{
|
2024-03-09 15:35:48 +08:00
|
|
|
placeholderText: qsTr("Please enter your password")
|
2023-08-24 15:50:37 +08:00
|
|
|
disabled:password_box_switch.checked
|
|
|
|
anchors{
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
left: parent.left
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FluToggleSwitch{
|
|
|
|
id:password_box_switch
|
|
|
|
anchors{
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
right: parent.right
|
|
|
|
}
|
2024-03-09 15:35:48 +08:00
|
|
|
text: qsTr("Disabled")
|
2023-08-24 15:50:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CodeExpander{
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: -1
|
|
|
|
code:'FluPasswordBox{
|
2024-03-09 15:35:48 +08:00
|
|
|
placeholderText: qsTr("Please enter your password")
|
2023-08-24 15:50:37 +08:00
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FluArea{
|
|
|
|
Layout.fillWidth: true
|
|
|
|
height: 36+multiine_textbox.height
|
|
|
|
paddings: 10
|
|
|
|
Layout.topMargin: 20
|
|
|
|
|
|
|
|
FluMultilineTextBox{
|
2024-03-09 15:35:48 +08:00
|
|
|
id: multiine_textbox
|
|
|
|
placeholderText: qsTr("Multi-line Input Box")
|
2023-09-12 22:55:42 +08:00
|
|
|
text:viewModel.text2
|
|
|
|
onTextChanged: {
|
|
|
|
viewModel.text2 = text
|
|
|
|
}
|
2024-03-09 15:35:48 +08:00
|
|
|
disabled: text_box_multi_switch.checked
|
2023-08-24 15:50:37 +08:00
|
|
|
anchors{
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
left: parent.left
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
FluToggleSwitch{
|
|
|
|
id:text_box_multi_switch
|
|
|
|
anchors{
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
right: parent.right
|
|
|
|
}
|
2024-03-09 15:35:48 +08:00
|
|
|
text: qsTr("Disabled")
|
2023-08-24 15:50:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CodeExpander{
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: -1
|
|
|
|
code:'FluMultilineTextBox{
|
2024-03-09 15:35:48 +08:00
|
|
|
placeholderText: qsTr("Multi-line Input Box")
|
2023-08-24 15:50:37 +08:00
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
FluArea{
|
|
|
|
Layout.fillWidth: true
|
|
|
|
height: 68
|
|
|
|
paddings: 10
|
|
|
|
Layout.topMargin: 20
|
|
|
|
FluAutoSuggestBox{
|
2024-03-09 15:35:48 +08:00
|
|
|
placeholderText: qsTr("AutoSuggestBox")
|
|
|
|
items: generateRandomNames(100)
|
|
|
|
disabled: text_box_suggest_switch.checked
|
2023-08-24 15:50:37 +08:00
|
|
|
anchors{
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
left: parent.left
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FluToggleSwitch{
|
|
|
|
id:text_box_suggest_switch
|
|
|
|
anchors{
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
right: parent.right
|
|
|
|
}
|
2024-03-09 15:35:48 +08:00
|
|
|
text: qsTr("Disabled")
|
2023-08-24 15:50:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CodeExpander{
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: -1
|
|
|
|
code:'FluAutoSuggestBox{
|
2024-03-09 15:35:48 +08:00
|
|
|
placeholderText: qsTr("AutoSuggestBox")
|
2023-08-24 15:50:37 +08:00
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
FluArea{
|
|
|
|
Layout.fillWidth: true
|
|
|
|
height: 68
|
|
|
|
paddings: 10
|
|
|
|
Layout.topMargin: 20
|
|
|
|
FluSpinBox{
|
|
|
|
disabled: spin_box_switch.checked
|
|
|
|
anchors{
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
left: parent.left
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FluToggleSwitch{
|
2024-03-09 15:35:48 +08:00
|
|
|
id: spin_box_switch
|
2023-08-24 15:50:37 +08:00
|
|
|
anchors{
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
right: parent.right
|
|
|
|
}
|
2024-03-09 15:35:48 +08:00
|
|
|
text: qsTr("Disabled")
|
2023-08-24 15:50:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
CodeExpander{
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.topMargin: -1
|
|
|
|
code:'FluSpinBox{
|
|
|
|
|
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
function generateRandomNames(numNames) {
|
|
|
|
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
|
|
const names = [];
|
|
|
|
function generateRandomName() {
|
|
|
|
const nameLength = Math.floor(Math.random() * 5) + 4;
|
|
|
|
let name = '';
|
|
|
|
for (let i = 0; i < nameLength; i++) {
|
|
|
|
const letterIndex = Math.floor(Math.random() * 26);
|
|
|
|
name += alphabet.charAt(letterIndex);
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
for (let i = 0; i < numNames; i++) {
|
|
|
|
const name = generateRandomName();
|
|
|
|
names.push({title:name});
|
|
|
|
}
|
|
|
|
return names;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|