From 56188cfa51cc69ce79ebdfac197fbe8ff60f7287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Sun, 23 Jul 2023 21:06:46 +0800 Subject: [PATCH] update --- example/qml/page/T_TextBox.qml | 67 +++++--------------- src/imports/FluentUI/Controls/FluSpinBox.qml | 2 +- src/imports/FluentUI/Controls/FluTextBox.qml | 8 ++- 3 files changed, 23 insertions(+), 54 deletions(-) diff --git a/example/qml/page/T_TextBox.qml b/example/qml/page/T_TextBox.qml index dc76def0..8b3159ca 100644 --- a/example/qml/page/T_TextBox.qml +++ b/example/qml/page/T_TextBox.qml @@ -17,27 +17,22 @@ FluScrollablePage{ Layout.topMargin: 20 FluTextBox{ - Layout.topMargin: 20 placeholderText: "单行输入框" - Layout.preferredWidth: 300 disabled:text_box_switch.checked + cleanEnabled: true anchors{ verticalCenter: parent.verticalCenter left: parent.left } } - Row{ - spacing: 5 + FluToggleSwitch{ + id:text_box_switch anchors{ verticalCenter: parent.verticalCenter right: parent.right } - FluToggleSwitch{ - id:text_box_switch - Layout.alignment: Qt.AlignRight - text:"Disabled" - } + text:"Disabled" } } CodeExpander{ @@ -55,27 +50,20 @@ FluScrollablePage{ Layout.topMargin: 20 FluPasswordBox{ - Layout.topMargin: 20 placeholderText: "请输入密码" - Layout.preferredWidth: 300 disabled:password_box_switch.checked anchors{ verticalCenter: parent.verticalCenter left: parent.left } } - - Row{ - spacing: 5 + FluToggleSwitch{ + id:password_box_switch anchors{ verticalCenter: parent.verticalCenter right: parent.right } - FluToggleSwitch{ - id:password_box_switch - Layout.alignment: Qt.AlignRight - text:"Disabled" - } + text:"Disabled" } } CodeExpander{ @@ -95,9 +83,7 @@ FluScrollablePage{ FluMultilineTextBox{ id:multiine_textbox - Layout.topMargin: 20 placeholderText: "多行输入框" - Layout.preferredWidth: 300 disabled:text_box_multi_switch.checked anchors{ verticalCenter: parent.verticalCenter @@ -105,17 +91,13 @@ FluScrollablePage{ } } - Row{ - spacing: 5 + FluToggleSwitch{ + id:text_box_multi_switch anchors{ verticalCenter: parent.verticalCenter right: parent.right } - FluToggleSwitch{ - id:text_box_multi_switch - Layout.alignment: Qt.AlignRight - text:"Disabled" - } + text:"Disabled" } } CodeExpander{ @@ -126,17 +108,13 @@ FluScrollablePage{ }' } - FluArea{ Layout.fillWidth: true height: 68 paddings: 10 Layout.topMargin: 20 - FluAutoSuggestBox{ - Layout.topMargin: 20 placeholderText: "AutoSuggestBox" - Layout.preferredWidth: 300 items:generateRandomNames(100) disabled:text_box_suggest_switch.checked anchors{ @@ -144,18 +122,13 @@ FluScrollablePage{ left: parent.left } } - - Row{ - spacing: 5 + FluToggleSwitch{ + id:text_box_suggest_switch anchors{ verticalCenter: parent.verticalCenter right: parent.right } - FluToggleSwitch{ - id:text_box_suggest_switch - Layout.alignment: Qt.AlignRight - text:"Disabled" - } + text:"Disabled" } } CodeExpander{ @@ -171,34 +144,26 @@ FluScrollablePage{ height: 68 paddings: 10 Layout.topMargin: 20 - FluSpinBox{ - Layout.topMargin: 20 disabled: spin_box_switch.checked anchors{ verticalCenter: parent.verticalCenter left: parent.left } } - - Row{ - spacing: 5 + FluToggleSwitch{ + id:spin_box_switch anchors{ verticalCenter: parent.verticalCenter right: parent.right } - FluToggleSwitch{ - id:spin_box_switch - Layout.alignment: Qt.AlignRight - text:"Disabled" - } + text:"Disabled" } } CodeExpander{ Layout.fillWidth: true Layout.topMargin: -1 code:'FluSpinBox{ - }' } diff --git a/src/imports/FluentUI/Controls/FluSpinBox.qml b/src/imports/FluentUI/Controls/FluSpinBox.qml index 4e7a8ff0..0e9c64cf 100644 --- a/src/imports/FluentUI/Controls/FluSpinBox.qml +++ b/src/imports/FluentUI/Controls/FluSpinBox.qml @@ -27,7 +27,7 @@ Rectangle{ id:com_edit FluTextBox{ rightPadding: 80 - closeRightMargin: 55 + iconRightMargin: 55 disabled: control.disabled validator: control.validator text: d._displayText diff --git a/src/imports/FluentUI/Controls/FluTextBox.qml b/src/imports/FluentUI/Controls/FluTextBox.qml index 5438023a..0d19c843 100644 --- a/src/imports/FluentUI/Controls/FluTextBox.qml +++ b/src/imports/FluentUI/Controls/FluTextBox.qml @@ -12,7 +12,8 @@ TextField{ property color placeholderNormalColor: FluTheme.dark ? Qt.rgba(210/255,210/255,210/255,1) : Qt.rgba(96/255,96/255,96/255,1) property color placeholderFocusColor: FluTheme.dark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1) property color placeholderDisableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1) - property int closeRightMargin: icon_end.visible ? 25 : 5 + property int iconRightMargin: icon_end.visible ? 25 : 5 + property bool cleanEnabled: false id:control width: 300 padding: 8 @@ -74,6 +75,9 @@ TextField{ width: 20 height: 20 visible: { + if(control.cleanEnabled === false){ + return false + } if(control.readOnly) return false return control.text !== "" @@ -81,7 +85,7 @@ TextField{ anchors{ verticalCenter: parent.verticalCenter right: parent.right - rightMargin: closeRightMargin + rightMargin: control.iconRightMargin } contentDescription:"清空" onClicked:{