diff --git a/example/example_en_US.ts b/example/example_en_US.ts index 0545ca0e..7b417a49 100644 --- a/example/example_en_US.ts +++ b/example/example_en_US.ts @@ -1700,22 +1700,30 @@ My only desire is to be permitted to drive out the traitors and restore the Han. - + + + Disabled - + + + Radio Button_1 - + + + Radio Button_2 - + + + Radio Button_3 diff --git a/example/example_zh_CN.ts b/example/example_zh_CN.ts index 4c10312f..e798dfc6 100644 --- a/example/example_zh_CN.ts +++ b/example/example_zh_CN.ts @@ -1808,22 +1808,30 @@ My only desire is to be permitted to drive out the traitors and restore the Han. - + + + Disabled 禁用 - + + + Radio Button_1 - + + + Radio Button_2 - + + + Radio Button_3 diff --git a/example/qml/page/T_RadioButton.qml b/example/qml/page/T_RadioButton.qml index 2f08e329..46fae27b 100644 --- a/example/qml/page/T_RadioButton.qml +++ b/example/qml/page/T_RadioButton.qml @@ -58,6 +58,7 @@ FluScrollablePage{ verticalCenter: parent.verticalCenter left: parent.left } + currentIndex: 1 FluRadioButton{ disabled: radio_button_switch2.checked text: qsTr("Radio Button_1") @@ -97,4 +98,110 @@ FluScrollablePage{ }' } + FluFrame{ + Layout.fillWidth: true + Layout.preferredHeight: 60 + padding: 10 + Layout.topMargin: 20 + FluRadioButtons{ + spacing: 8 + anchors.verticalCenter: parent.verticalCenter + anchors{ + verticalCenter: parent.verticalCenter + left: parent.left + } + orientation: Qt.Horizontal + currentIndex: 1 + FluRadioButton{ + disabled: radio_button_switch3.checked + text: qsTr("Radio Button_1") + } + FluRadioButton{ + disabled: radio_button_switch3.checked + text: qsTr("Radio Button_2") + } + FluRadioButton{ + disabled: radio_button_switch3.checked + text: qsTr("Radio Button_3") + } + } + FluToggleSwitch{ + id: radio_button_switch3 + anchors{ + right: parent.right + verticalCenter: parent.verticalCenter + } + text: qsTr("Disabled") + } + } + CodeExpander{ + Layout.fillWidth: true + Layout.topMargin: -6 + code:'FluRadioButtons{ + spacing: 8 + orientation: Qt.Horizontal + FluRadioButton{ + text:"Radio Button_1" + } + FluRadioButton{ + text:"Radio Button_2" + } + FluRadioButton{ + text:"Radio Button_3" + } +}' + } + + FluFrame{ + Layout.fillWidth: true + Layout.preferredHeight: 100 + padding: 10 + Layout.topMargin: 20 + FluRadioButtons{ + spacing: 8 + anchors.verticalCenter: parent.verticalCenter + anchors{ + verticalCenter: parent.verticalCenter + left: parent.left + } + currentIndex: 1 + FluCheckBox{ + disabled: radio_button_switch4.checked + text: qsTr("Radio Button_1") + } + FluCheckBox{ + disabled: radio_button_switch4.checked + text: qsTr("Radio Button_2") + } + FluCheckBox{ + disabled: radio_button_switch4.checked + text: qsTr("Radio Button_3") + } + } + FluToggleSwitch{ + id: radio_button_switch4 + anchors{ + right: parent.right + verticalCenter: parent.verticalCenter + } + text: qsTr("Disabled") + } + } + CodeExpander{ + Layout.fillWidth: true + Layout.topMargin: -6 + code:'FluRadioButtons{ + spacing: 8 + FluCheckBox{ + text:"Radio Button_1" + } + FluCheckBox{ + text:"Radio Button_2" + } + FluCheckBox{ + text:"Radio Button_3" + } +}' + } + } diff --git a/src/Qt5/imports/FluentUI/Controls/FluRadioButtons.qml b/src/Qt5/imports/FluentUI/Controls/FluRadioButtons.qml index 83060795..2c79e575 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluRadioButtons.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluRadioButtons.qml @@ -3,30 +3,76 @@ import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 import FluentUI 1.0 -ColumnLayout { - default property alias buttons: control.data - property int currentIndex : -1 +Item{ id:control - onCurrentIndexChanged: { - for(var i = 0;i buttons + property int currentIndex : -1 + property int spacing: 8 + property int orientation: Qt.Vertical + QtObject{ + id: d + function updateChecked(){ + if(buttons.length === 0){ + return + } + for(var i = 0;i buttons + property int currentIndex : -1 + property int spacing: 8 + property int orientation: Qt.Vertical + QtObject{ + id: d + function updateChecked(){ + if(buttons.length === 0){ + return + } + for(var i = 0;i