mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-24 03:30:59 +08:00
FluRadioButtons 组件支持 disabled、manuallyDisabled选项
disabled: true // 禁用所有FluRadioButton子组件 manuallyDisabled: true // 是否指定每个FluRadioButton上的disabled选项
This commit is contained in:
parent
c36515f19c
commit
9aa6615189
@ -22,18 +22,37 @@ FluScrollablePage{
|
|||||||
|
|
||||||
FluGroupBox {
|
FluGroupBox {
|
||||||
title: qsTr("RadioButton Group")
|
title: qsTr("RadioButton Group")
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: 150
|
||||||
|
Layout.topMargin: 20
|
||||||
FluRadioButtons {
|
FluRadioButtons {
|
||||||
|
anchors{
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
left: parent.left
|
||||||
|
}
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
disabled: radio_button_switch.checked
|
||||||
FluRadioButton { text: qsTr("E-mail") }
|
FluRadioButton { text: qsTr("E-mail") }
|
||||||
FluRadioButton { text: qsTr("Calendar") }
|
FluRadioButton { text: qsTr("Calendar") }
|
||||||
FluRadioButton { text: qsTr("Contacts") }
|
FluRadioButton { text: qsTr("Contacts") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FluToggleSwitch{
|
||||||
|
id: radio_button_switch
|
||||||
|
anchors{
|
||||||
|
right: parent.right
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
text: qsTr("Disabled")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CodeExpander{
|
CodeExpander{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: 4
|
Layout.topMargin: 4
|
||||||
code:'FluGroupBox {
|
code:`
|
||||||
|
FluGroupBox {
|
||||||
title: qsTr("CheckBox Group")
|
title: qsTr("CheckBox Group")
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
spacing: 10
|
spacing: 10
|
||||||
@ -42,7 +61,20 @@ FluScrollablePage{
|
|||||||
FluCheckBox { text: qsTr("Calendar") }
|
FluCheckBox { text: qsTr("Calendar") }
|
||||||
FluCheckBox { text: qsTr("Contacts") }
|
FluCheckBox { text: qsTr("Contacts") }
|
||||||
}
|
}
|
||||||
}'
|
}
|
||||||
|
|
||||||
|
FluGroupBox {
|
||||||
|
title: qsTr("RadioButton Group")
|
||||||
|
FluRadioButtons {
|
||||||
|
spacing: 10
|
||||||
|
disabled: true // 禁用所有FluRadioButton子组件
|
||||||
|
manuallyDisabled: true // 是否指定每个FluRadioButton上的disabled选项
|
||||||
|
FluRadioButton { text: qsTr("E-mail") }
|
||||||
|
FluRadioButton { text: qsTr("Calendar") }
|
||||||
|
FluRadioButton { text: qsTr("Contacts") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import FluentUI 1.0
|
|||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
default property alias buttons: control.data
|
default property alias buttons: control.data
|
||||||
property int currentIndex : -1
|
property int currentIndex : -1
|
||||||
|
property bool disabled: false
|
||||||
|
property bool manuallyDisabled: false
|
||||||
id:control
|
id:control
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
for(var i = 0;i<buttons.length;i++){
|
for(var i = 0;i<buttons.length;i++){
|
||||||
@ -16,6 +18,12 @@ ColumnLayout {
|
|||||||
button.checked = true
|
button.checked = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onDisabledChanged: {
|
||||||
|
refreshButtonStatus()
|
||||||
|
}
|
||||||
|
onManuallyDisabledChanged: {
|
||||||
|
refreshButtonStatus()
|
||||||
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
for(var i = 0;i<buttons.length;i++){
|
for(var i = 0;i<buttons.length;i++){
|
||||||
buttons[i].clickListener = function(){
|
buttons[i].clickListener = function(){
|
||||||
@ -27,6 +35,12 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentIndex = 0
|
refreshButtonStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshButtonStatus() {
|
||||||
|
for(var i = 0;i<buttons.length;i++){
|
||||||
|
if(!manuallyDisabled) buttons[i].enabled = !disabled
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import FluentUI
|
|||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
default property alias buttons: control.data
|
default property alias buttons: control.data
|
||||||
property int currentIndex : -1
|
property int currentIndex : -1
|
||||||
|
property bool disabled: false
|
||||||
|
property bool manuallyDisabled: false
|
||||||
id:control
|
id:control
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
for(var i = 0;i<buttons.length;i++){
|
for(var i = 0;i<buttons.length;i++){
|
||||||
@ -17,6 +19,12 @@ ColumnLayout {
|
|||||||
button.checked = true
|
button.checked = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onDisabledChanged: {
|
||||||
|
refreshButtonStatus()
|
||||||
|
}
|
||||||
|
onManuallyDisabledChanged: {
|
||||||
|
refreshButtonStatus()
|
||||||
|
}
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
for(var i = 0;i<buttons.length;i++){
|
for(var i = 0;i<buttons.length;i++){
|
||||||
buttons[i].clickListener = function(){
|
buttons[i].clickListener = function(){
|
||||||
@ -28,6 +36,12 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentIndex = 0
|
refreshButtonStatus()
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshButtonStatus() {
|
||||||
|
for(var i = 0;i<buttons.length;i++){
|
||||||
|
if(!manuallyDisabled) buttons[i].enabled = !disabled
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user