mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-10-31 00:07:36 +08:00
update
This commit is contained in:
parent
efd21a5f55
commit
6ea873f75c
@ -27,48 +27,38 @@ FluObject{
|
||||
}
|
||||
navigationView.push("qrc:/example/qml/page/T_Home.qml")
|
||||
}
|
||||
rightMenu: FluMenu{
|
||||
property string renameText : "重命名"
|
||||
editDelegate: FluTextBox{
|
||||
text:item_home.title
|
||||
}
|
||||
menuDelegate: FluMenu{
|
||||
id:nav_item_right_menu
|
||||
enableAnimation: false
|
||||
width: 120
|
||||
|
||||
FluMenuItem{
|
||||
text: nav_item_right_menu.renameText
|
||||
text: "重命名"
|
||||
visible: true
|
||||
onClicked: {
|
||||
item_home.editable = true;
|
||||
|
||||
item_home.showEdit = true
|
||||
}
|
||||
}
|
||||
}
|
||||
onTitleEdited:function(newText){
|
||||
rename(item_home,newText)
|
||||
}
|
||||
}
|
||||
|
||||
FluPaneItemExpander{
|
||||
id:item_expander_basic_input
|
||||
title:lang.basic_input
|
||||
icon:FluentIcons.CheckboxComposite
|
||||
|
||||
rightMenu: FluMenu{
|
||||
property string renameText : "重命名"
|
||||
id:nav_item_expander_right_menu
|
||||
enableAnimation: false
|
||||
width: 120
|
||||
|
||||
editDelegate: FluTextBox{
|
||||
text:item_expander_basic_input.title
|
||||
}
|
||||
menuDelegate: FluMenu{
|
||||
FluMenuItem{
|
||||
text: nav_item_expander_right_menu.renameText
|
||||
text: "重命名"
|
||||
visible: true
|
||||
onClicked: {
|
||||
item_expander_basic_input.editable = true;
|
||||
|
||||
item_expander_basic_input.showEdit = true
|
||||
}
|
||||
}
|
||||
}
|
||||
onTitleEdited:function(newText){ rename(item_expander_basic_input,newText)}
|
||||
|
||||
FluPaneItem{
|
||||
id:item_buttons
|
||||
count: 99
|
||||
|
@ -6,7 +6,7 @@ import QtQuick.Templates as T
|
||||
|
||||
ComboBox {
|
||||
id: control
|
||||
signal commit
|
||||
signal commit(string text)
|
||||
property bool disabled: false
|
||||
property color normalColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1)
|
||||
property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
|
||||
@ -71,7 +71,7 @@ ComboBox {
|
||||
Keys.onEnterPressed: (event)=> handleCommit(event)
|
||||
Keys.onReturnPressed:(event)=> handleCommit(event)
|
||||
function handleCommit(event){
|
||||
control.commit()
|
||||
control.commit(control.editText)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,91 +0,0 @@
|
||||
import QtQuick
|
||||
import FluentUI
|
||||
Item {
|
||||
id:root
|
||||
property bool editable: false
|
||||
property string text: ""
|
||||
property int elide
|
||||
property color color
|
||||
property color editBgColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(255/255,255/255,255/255,1)
|
||||
property color editTextColor: FluTheme.dark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
||||
|
||||
property alias editBgRect : editBackgroundComponent
|
||||
property alias normalText :normalTextComponent
|
||||
property alias editableText :editableTextComponent
|
||||
|
||||
|
||||
signal fluTextEdited(var newText)
|
||||
signal fluLostFocus(bool isActiveFocus)
|
||||
|
||||
|
||||
height:24
|
||||
|
||||
function setEditable(value){
|
||||
editable = value;
|
||||
}
|
||||
|
||||
Keys.onPressed:function(event) {
|
||||
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
|
||||
if(editableTextComponent.text !== "" && editableTextComponent.text !== root.text){
|
||||
fluTextEdited(editableTextComponent.text)
|
||||
}
|
||||
|
||||
fluLostFocus(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//property alias anchors:normalText.anchors
|
||||
FluText{
|
||||
id:normalTextComponent
|
||||
text: root.text
|
||||
elide:root.elide
|
||||
color:root.color
|
||||
visible: !editable
|
||||
anchors.fill: parent
|
||||
lineHeight: height
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
id:editBackgroundComponent
|
||||
width: Math.max(editableText.implicitWidth,20)
|
||||
height:parent.height
|
||||
radius: 5
|
||||
|
||||
|
||||
color:editable? editBgColor:"transparent"
|
||||
visible: editable
|
||||
TextInput{
|
||||
id:editableTextComponent
|
||||
anchors.fill: parent
|
||||
|
||||
text:root.text
|
||||
color:editTextColor
|
||||
visible: editable
|
||||
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
|
||||
font: FluTextStyle.Body
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
//focus: editable
|
||||
|
||||
onActiveFocusChanged: {
|
||||
if(editableTextComponent.text !== "" && editableTextComponent.text !== root.text){
|
||||
fluTextEdited(text)
|
||||
}
|
||||
fluLostFocus(activeFocus);
|
||||
}
|
||||
}
|
||||
}
|
||||
onEditableChanged: {
|
||||
if(editable){
|
||||
editableTextComponent.forceActiveFocus()
|
||||
editableTextComponent.selectAll()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -4,7 +4,7 @@ import QtQuick.Controls.Basic
|
||||
import FluentUI
|
||||
|
||||
TextArea{
|
||||
signal commit
|
||||
signal commit(string text)
|
||||
property bool disabled: false
|
||||
property color normalColor: FluTheme.dark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
||||
property color disableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
|
||||
@ -50,7 +50,7 @@ TextArea{
|
||||
insert(control.cursorPosition, "\n")
|
||||
return
|
||||
}
|
||||
control.commit()
|
||||
control.commit(control.text)
|
||||
}
|
||||
}
|
||||
MouseArea{
|
||||
|
@ -163,23 +163,14 @@ Item {
|
||||
leftMargin: 6
|
||||
rightMargin: 6
|
||||
}
|
||||
|
||||
Loader{
|
||||
id:navItemRightMenuLoader
|
||||
//anchors.centerIn: parent
|
||||
sourceComponent: model.rightMenu
|
||||
}
|
||||
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
onClicked: function(mouse){
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
if(model.rightMenu){
|
||||
var rightMenuComponent = model.rightMenu.createObject(navItemRightMenuLoader); // navItemRightMenuLoader 是你要将菜单附加到的父级项
|
||||
if (rightMenuComponent !== null) {
|
||||
rightMenuComponent.popup();
|
||||
}
|
||||
if(model.menuDelegate){
|
||||
loader_item_menu.sourceComponent = model.menuDelegate
|
||||
loader_item_menu.item.popup()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -208,7 +199,6 @@ Item {
|
||||
}
|
||||
visible: {
|
||||
if(!model.isExpand){
|
||||
|
||||
for(var i=0;i<model.children.length;i++){
|
||||
var item = model.children[i]
|
||||
if(item.infoBadge && item.count !==0){
|
||||
@ -314,17 +304,15 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
FluEditableText{
|
||||
FluText{
|
||||
id:item_title
|
||||
text:model.title
|
||||
editable: model.editable
|
||||
visible: {
|
||||
if(d.isCompactAndNotPanel){
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
elide: Text.ElideRight
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
left:item_icon.right
|
||||
@ -336,15 +324,34 @@ Item {
|
||||
}
|
||||
return FluTheme.dark ? FluColors.White : FluColors.Grey220
|
||||
}
|
||||
onFluTextEdited:function(newText) {
|
||||
if(model.onTitleEdited)
|
||||
model.onTitleEdited(newText)
|
||||
}
|
||||
onFluLostFocus:function(isActiveFocus){
|
||||
if(!isActiveFocus){
|
||||
model.editable = false
|
||||
if(model.onTitleEdited)
|
||||
model.onTitleEdited(item_title.text)
|
||||
Loader{
|
||||
id:item_edit_loader
|
||||
anchors{
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
left: item_title.left
|
||||
right: item_title.right
|
||||
rightMargin: 8
|
||||
}
|
||||
sourceComponent: model.showEdit ? model.editDelegate : undefined
|
||||
onStatusChanged: {
|
||||
if(status === Loader.Ready){
|
||||
item.forceActiveFocus()
|
||||
item_connection_edit_focus.target = item
|
||||
}
|
||||
}
|
||||
Connections{
|
||||
id:item_connection_edit_focus
|
||||
ignoreUnknownSignals:true
|
||||
function onActiveFocusChanged(focus){
|
||||
if(focus === false){
|
||||
model.showEdit = false
|
||||
}
|
||||
}
|
||||
function onCommit(text){
|
||||
model.title = text
|
||||
model.showEdit = false
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -387,28 +394,19 @@ Item {
|
||||
leftMargin: 6
|
||||
rightMargin: 6
|
||||
}
|
||||
|
||||
Loader{
|
||||
id:loader_auto_suggest_boxsssssdd
|
||||
sourceComponent: model.rightMenu
|
||||
}
|
||||
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
onClicked: function(mouse){
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
if(model.rightMenu){
|
||||
var rightMenuComponent = model.rightMenu.createObject(loader_auto_suggest_boxsssssdd); // loader_auto_suggest_boxsssssdd 是你要将菜单附加到的父级项
|
||||
if (rightMenuComponent !== null) {
|
||||
rightMenuComponent.popup();
|
||||
}
|
||||
if(model.menuDelegate){
|
||||
loader_item_menu.sourceComponent = model.menuDelegate
|
||||
loader_item_menu.item.popup();
|
||||
}
|
||||
}
|
||||
}
|
||||
z:-100
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
if(type === 0){
|
||||
if(model.tapFunc){
|
||||
@ -499,17 +497,15 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
FluEditableText{
|
||||
FluText{
|
||||
id:item_title
|
||||
text:model.title
|
||||
editable: model.editable
|
||||
visible: {
|
||||
if(d.isCompactAndNotPanel){
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
elide: Text.ElideRight
|
||||
color:{
|
||||
if(item_control.pressed){
|
||||
return FluTheme.dark ? FluColors.Grey80 : FluColors.Grey120
|
||||
@ -521,16 +517,34 @@ Item {
|
||||
left:item_icon.right
|
||||
right: item_dot_loader.left
|
||||
}
|
||||
onFluTextEdited:function(newText) {
|
||||
if(model.onTitleEdited)
|
||||
model.onTitleEdited(newText)
|
||||
}
|
||||
onFluLostFocus:function(isActiveFocus){
|
||||
if(!isActiveFocus){
|
||||
model.editable = false
|
||||
if(model.onTitleEdited){
|
||||
model.onTitleEdited(item_title.text)
|
||||
Loader{
|
||||
id:item_edit_loader
|
||||
anchors{
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
left: item_title.left
|
||||
right: item_title.right
|
||||
rightMargin: 8
|
||||
}
|
||||
sourceComponent: model.showEdit ? model.editDelegate : undefined
|
||||
onStatusChanged: {
|
||||
if(status === Loader.Ready){
|
||||
item.forceActiveFocus()
|
||||
item_connection_edit_focus.target = item
|
||||
}
|
||||
}
|
||||
Connections{
|
||||
id:item_connection_edit_focus
|
||||
ignoreUnknownSignals:true
|
||||
function onActiveFocusChanged(focus){
|
||||
if(focus === false){
|
||||
model.showEdit = false
|
||||
}
|
||||
}
|
||||
function onCommit(text){
|
||||
model.title = text
|
||||
model.showEdit = false
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1050,6 +1064,9 @@ Item {
|
||||
control_popup.open()
|
||||
}
|
||||
}
|
||||
Loader{
|
||||
id:loader_item_menu
|
||||
}
|
||||
Component{
|
||||
id:com_placeholder
|
||||
Item{
|
||||
|
@ -19,7 +19,7 @@ QtObject {
|
||||
property int count: 0
|
||||
signal tap
|
||||
property var tapFunc
|
||||
property Component rightMenu
|
||||
property bool editable
|
||||
property var onTitleEdited:null
|
||||
property Component menuDelegate
|
||||
property Component editDelegate
|
||||
property bool showEdit
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ FluObject {
|
||||
property Component cusIcon
|
||||
property bool isExpand: false
|
||||
property var parent
|
||||
property Component rightMenu
|
||||
property bool editable
|
||||
property var onTitleEdited:null
|
||||
property Component menuDelegate
|
||||
property Component editDelegate
|
||||
property bool showEdit
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import QtQuick.Controls.Basic
|
||||
import FluentUI
|
||||
|
||||
TextField{
|
||||
signal commit
|
||||
signal commit(string text)
|
||||
property bool disabled: false
|
||||
property int iconSource: 0
|
||||
property color normalColor: FluTheme.dark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
||||
@ -59,7 +59,7 @@ TextField{
|
||||
QtObject{
|
||||
id:d
|
||||
function handleCommit(event){
|
||||
control.commit()
|
||||
control.commit(control.text)
|
||||
}
|
||||
}
|
||||
FluIconButton{
|
||||
|
@ -4,7 +4,7 @@ import QtQuick.Controls.Basic
|
||||
import FluentUI
|
||||
|
||||
TextField{
|
||||
signal commit
|
||||
signal commit(string text)
|
||||
property bool disabled: false
|
||||
property int iconSource: 0
|
||||
property color normalColor: FluTheme.dark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
||||
@ -60,7 +60,7 @@ TextField{
|
||||
QtObject{
|
||||
id:d
|
||||
function handleCommit(event){
|
||||
control.commit()
|
||||
control.commit(control.text)
|
||||
}
|
||||
}
|
||||
MouseArea{
|
||||
|
Loading…
Reference in New Issue
Block a user