From 9494ec4ac6d807c03ba924c6f1863c8778fb40e0 Mon Sep 17 00:00:00 2001 From: zhuzihcu Date: Mon, 24 Apr 2023 17:48:12 +0800 Subject: [PATCH] update --- example/qml/page/T_TableView.qml | 8 ++++---- src/controls/FluAutoSuggestBox.qml | 8 -------- src/controls/FluButton.qml | 1 - src/controls/FluDropDownButton.qml | 1 - src/controls/FluMenu.qml | 8 ++++---- src/controls/FluMenuItem.qml | 19 ++++++++++++------- src/controls/FluTextBoxMenu.qml | 14 ++++++++++++-- 7 files changed, 32 insertions(+), 27 deletions(-) diff --git a/example/qml/page/T_TableView.qml b/example/qml/page/T_TableView.qml index eb26ac6..20b143c 100644 --- a/example/qml/page/T_TableView.qml +++ b/example/qml/page/T_TableView.qml @@ -68,8 +68,8 @@ FluScrollablePage{ text:"编辑" topPadding:3 bottomPadding:3 - leftPadding:3 - rightPadding:3 + leftPadding:6 + rightPadding:6 onClicked:{ console.debug(dataModel.index) showSuccess(JSON.stringify(dataObject)) @@ -79,8 +79,8 @@ FluScrollablePage{ text:"删除" topPadding:3 bottomPadding:3 - leftPadding:3 - rightPadding:3 + leftPadding:6 + rightPadding:6 onClicked:{ showError(JSON.stringify(dataObject)) } diff --git a/src/controls/FluAutoSuggestBox.qml b/src/controls/FluAutoSuggestBox.qml index 5194cf3..d19c592 100644 --- a/src/controls/FluAutoSuggestBox.qml +++ b/src/controls/FluAutoSuggestBox.qml @@ -126,14 +126,6 @@ FluTextBox{ control_popup.visible = true } } - TapHandler { - acceptedButtons: Qt.RightButton - onTapped: control.echoMode !== TextInput.Password && menu.popup() - } - FluTextBoxMenu{ - id:menu - inputItem: control - } function handleClick(modelData){ control_popup.visible = false diff --git a/src/controls/FluButton.qml b/src/controls/FluButton.qml index 925e8f8..a15fcf1 100644 --- a/src/controls/FluButton.qml +++ b/src/controls/FluButton.qml @@ -17,7 +17,6 @@ Button { rightPadding:15 enabled: !disabled focusPolicy:Qt.TabFocus - Keys.onSpacePressed: control.visualFocus&&clicked() background: Rectangle{ diff --git a/src/controls/FluDropDownButton.qml b/src/controls/FluDropDownButton.qml index f1816b4..19f1ecb 100644 --- a/src/controls/FluDropDownButton.qml +++ b/src/controls/FluDropDownButton.qml @@ -91,7 +91,6 @@ Button { FluMenu{ id:menu width: control.width - animEnabled: true } } diff --git a/src/controls/FluMenu.qml b/src/controls/FluMenu.qml index 7068318..adf0adc 100644 --- a/src/controls/FluMenu.qml +++ b/src/controls/FluMenu.qml @@ -5,7 +5,7 @@ import QtQuick.Controls Menu { default property alias content: container.data - property bool animEnabled: false + property bool enableAnimation: true id: popup width: 140 height: container.height @@ -17,7 +17,7 @@ Menu { property: "opacity" from:0 to:1 - duration: 83 + duration: enableAnimation ? 83 : 0 } } @@ -26,7 +26,7 @@ Menu { property: "opacity" from:1 to:0 - duration: 83 + duration: enableAnimation ? 83 : 0 } } @@ -39,7 +39,7 @@ Menu { clip: true Rectangle{ anchors.fill: parent - color:FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,0.97) : Qt.rgba(237/255,237/255,237/255,0.97) + color:FluTheme.dark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(249/255,249/255,249/255,1) radius: 5 } Column{ diff --git a/src/controls/FluMenuItem.qml b/src/controls/FluMenuItem.qml index 3358857..7ea3d30 100644 --- a/src/controls/FluMenuItem.qml +++ b/src/controls/FluMenuItem.qml @@ -4,12 +4,13 @@ import QtQuick.Controls Item { property string text: "MenuItem" + property var onClickFunc signal clicked - id:root + id:control width: { - if(root.parent){ - return root.parent.width + if(control.parent){ + return control.parent.width } return 140 } @@ -18,7 +19,7 @@ Item { Rectangle{ anchors.centerIn: parent - width: root.width-40 + width: control.width-40 height: 32 radius: 4 color:{ @@ -36,7 +37,7 @@ Item { } FluText{ - text: root.text + text: control.text anchors.centerIn: parent } @@ -45,8 +46,12 @@ Item { hoverEnabled: true anchors.fill: parent onClicked: { - root.clicked() - root.parent.closePopup() + if(control.onClickFunc){ + control.onClickFunc() + return + } + control.parent.closePopup() + control.clicked() } } } diff --git a/src/controls/FluTextBoxMenu.qml b/src/controls/FluTextBoxMenu.qml index 8ff1e31..4355547 100644 --- a/src/controls/FluTextBoxMenu.qml +++ b/src/controls/FluTextBoxMenu.qml @@ -11,14 +11,24 @@ FluMenu{ property var inputItem id:menu - focus: false + focus:false + enableAnimation:false + + Connections{ + target: inputItem + function onTextChanged() { + menu.close() + } + } + FluMenuItem{ text: cutText - visible: inputItem.text !== "" && !inputItem.readOnly + visible: inputItem.selectedText !== "" && !inputItem.readOnly onClicked: { inputItem.cut() } } + FluMenuItem{ text: copyText visible: inputItem.selectedText !== ""