Skip to content

Commit f830d5a

Browse files
author
朱子楚\zhuzi
committed
2 parents 5f6745b + ed49e3f commit f830d5a

File tree

8 files changed

+190
-48
lines changed

8 files changed

+190
-48
lines changed

Diff for: example/qml/page/T_GroupBox.qml

+34-2
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,37 @@ FluScrollablePage{
2222

2323
FluGroupBox {
2424
title: qsTr("RadioButton Group")
25+
Layout.fillWidth: true
26+
Layout.preferredHeight: 150
27+
Layout.topMargin: 20
2528
FluRadioButtons {
29+
anchors{
30+
verticalCenter: parent.verticalCenter
31+
left: parent.left
32+
}
2633
spacing: 10
34+
disabled: radio_button_switch.checked
2735
FluRadioButton { text: qsTr("E-mail") }
2836
FluRadioButton { text: qsTr("Calendar") }
2937
FluRadioButton { text: qsTr("Contacts") }
3038
}
39+
40+
FluToggleSwitch{
41+
id: radio_button_switch
42+
anchors{
43+
right: parent.right
44+
verticalCenter: parent.verticalCenter
45+
}
46+
text: qsTr("Disabled")
47+
}
3148
}
3249

50+
3351
CodeExpander{
3452
Layout.fillWidth: true
3553
Layout.topMargin: 4
36-
code:'FluGroupBox {
54+
code:`
55+
FluGroupBox {
3756
title: qsTr("CheckBox Group")
3857
ColumnLayout {
3958
spacing: 10
@@ -42,7 +61,20 @@ FluScrollablePage{
4261
FluCheckBox { text: qsTr("Calendar") }
4362
FluCheckBox { text: qsTr("Contacts") }
4463
}
45-
}'
64+
}
65+
66+
FluGroupBox {
67+
title: qsTr("RadioButton Group")
68+
FluRadioButtons {
69+
spacing: 10
70+
disabled: true // 禁用所有FluRadioButton子组件
71+
manuallyDisabled: true // 是否指定每个FluRadioButton上的disabled选项
72+
FluRadioButton { text: qsTr("E-mail") }
73+
FluRadioButton { text: qsTr("Calendar") }
74+
FluRadioButton { text: qsTr("Contacts") }
75+
}
76+
}
77+
`
4678
}
4779

4880
}

Diff for: example/qml/page/T_InfoBar.qml

+57-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ FluScrollablePage{
99

1010
title: qsTr("InfoBar")
1111

12+
property var info1
13+
property var info2
14+
property var info3
15+
1216
FluFrame{
1317
Layout.fillWidth: true
14-
Layout.preferredHeight: 270
18+
Layout.preferredHeight: 350
1519
padding: 10
1620
ColumnLayout{
1721
spacing: 14
@@ -49,6 +53,51 @@ FluScrollablePage{
4953
showInfo(qsTr("This is an InfoBar in the Info Style"),0,qsTr("Manual shutdown is supported"))
5054
}
5155
}
56+
FluText{
57+
wrapMode: Text.WrapAnywhere
58+
width: parent.width
59+
text: qsTr("Manually close the info message box")
60+
}
61+
Row{
62+
spacing: 5
63+
FluButton{
64+
text: (info1 ? qsTr("close '%1'") : qsTr("show '%1")).arg("info1")
65+
onClicked: {
66+
if(info1) {
67+
info1.close()
68+
return
69+
}
70+
info1 = showInfo(qsTr("This is an '%1'").arg("info1"), 0)
71+
}
72+
}
73+
FluButton{
74+
text: (info2 ? qsTr("close '%1'") : qsTr("show '%1")).arg("info2")
75+
onClicked: {
76+
if(info2) {
77+
info2.close()
78+
return
79+
}
80+
info2 = showInfo(qsTr("This is an '%1'").arg("info2"), 0)
81+
}
82+
}
83+
FluButton{
84+
text: (info3 ? qsTr("close '%1'") : qsTr("show '%1")).arg("info3")
85+
onClicked: {
86+
if(info3) {
87+
info3.close()
88+
return
89+
}
90+
info3 = showInfo(qsTr("This is an '%1'").arg("info3"), 0)
91+
}
92+
}
93+
FluButton{
94+
text: qsTr("clear all info")
95+
onClicked: {
96+
clearAllInfo()
97+
}
98+
}
99+
}
100+
52101
FluButton{
53102
text:"Loading"
54103
onClicked: {
@@ -60,12 +109,17 @@ FluScrollablePage{
60109
CodeExpander{
61110
Layout.fillWidth: true
62111
Layout.topMargin: -6
63-
code:'showInfo(qsTr("This is an InfoBar in the Info Style"))
112+
code:`
113+
showInfo(qsTr("This is an InfoBar in the Info Style"))
64114
65115
showWarning(qsTr("This is an InfoBar in the Warning Style"))
66116
67117
showError(qsTr("This is an InfoBar in the Error Style"))
68118
69-
showSuccess(qsTr("This is an InfoBar in the Success Style"))'
119+
showSuccess(qsTr("This is an InfoBar in the Success Style"))
120+
121+
var info1 = showInfo(qsTr("This is an 'Info1'"), 0)
122+
info1.close()
123+
`
70124
}
71125
}

Diff for: src/Qt5/imports/FluentUI/Controls/FluInfoBar.qml

+26-15
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,23 @@ FluObject {
1818
if(screenLayout){
1919
var last = screenLayout.getLastloader();
2020
if(last.type === type && last.text === text && moremsg === last.moremsg){
21-
last.restart();
22-
return;
21+
last.duration = duration
22+
if (duration > 0) last.restart();
23+
return last;
2324
}
2425
}
2526
initScreenLayout();
26-
contentComponent.createObject(screenLayout,{
27-
type:type,
28-
text:text,
29-
duration:duration,
30-
moremsg:moremsg,
31-
});
27+
return contentComponent.createObject(screenLayout,{
28+
type:type,
29+
text:text,
30+
duration:duration,
31+
moremsg:moremsg,
32+
});
3233
}
3334
function createCustom(itemcomponent,duration){
3435
initScreenLayout();
3536
if(itemcomponent){
36-
contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration});
37+
return contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration});
3738
}
3839
}
3940
function initScreenLayout(){
@@ -85,7 +86,9 @@ FluObject {
8586
}
8687
Timer {
8788
id:delayTimer
88-
interval: duration; running: duration > 0; repeat: duration > 0
89+
interval: duration;
90+
running: duration > 0;
91+
repeat: duration > 0
8992
onTriggered: content.close();
9093
}
9194
FluLoader{
@@ -235,18 +238,26 @@ FluObject {
235238
}
236239
}
237240
function showSuccess(text,duration=1000,moremsg){
238-
mcontrol.create(mcontrol.const_success,text,duration,moremsg ? moremsg : "");
241+
return mcontrol.create(mcontrol.const_success,text,duration,moremsg ? moremsg : "");
239242
}
240243
function showInfo(text,duration=1000,moremsg){
241-
mcontrol.create(mcontrol.const_info,text,duration,moremsg ? moremsg : "");
244+
return mcontrol.create(mcontrol.const_info,text,duration,moremsg ? moremsg : "");
242245
}
243246
function showWarning(text,duration=1000,moremsg){
244-
mcontrol.create(mcontrol.const_warning,text,duration,moremsg ? moremsg : "");
247+
return mcontrol.create(mcontrol.const_warning,text,duration,moremsg ? moremsg : "");
245248
}
246249
function showError(text,duration=1000,moremsg){
247-
mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "");
250+
return mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "");
248251
}
249252
function showCustom(itemcomponent,duration=1000){
250-
mcontrol.createCustom(itemcomponent,duration);
253+
return mcontrol.createCustom(itemcomponent,duration);
254+
}
255+
function clearAllInfo(){
256+
if(mcontrol.screenLayout != null) {
257+
mcontrol.screenLayout.destroy()
258+
mcontrol.screenLayout = null
259+
}
260+
261+
return true
251262
}
252263
}

Diff for: src/Qt5/imports/FluentUI/Controls/FluRadioButtons.qml

+15-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import FluentUI 1.0
66
ColumnLayout {
77
default property alias buttons: control.data
88
property int currentIndex : -1
9+
property bool disabled: false
10+
property bool manuallyDisabled: false
911
id:control
1012
onCurrentIndexChanged: {
1113
for(var i = 0;i<buttons.length;i++){
@@ -16,6 +18,12 @@ ColumnLayout {
1618
button.checked = true
1719
}
1820
}
21+
onDisabledChanged: {
22+
refreshButtonStatus()
23+
}
24+
onManuallyDisabledChanged: {
25+
refreshButtonStatus()
26+
}
1927
Component.onCompleted: {
2028
for(var i = 0;i<buttons.length;i++){
2129
buttons[i].clickListener = function(){
@@ -27,6 +35,12 @@ ColumnLayout {
2735
}
2836
}
2937
}
30-
currentIndex = 0
38+
refreshButtonStatus()
39+
}
40+
41+
function refreshButtonStatus() {
42+
for(var i = 0;i<buttons.length;i++){
43+
if(!manuallyDisabled) buttons[i].enabled = !disabled
44+
}
3145
}
3246
}

Diff for: src/Qt5/imports/FluentUI/Controls/FluWindow.qml

+7-4
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,19 @@ Window {
289289
loader_loading.sourceComponent = undefined
290290
}
291291
function showSuccess(text,duration,moremsg){
292-
info_bar.showSuccess(text,duration,moremsg)
292+
return info_bar.showSuccess(text,duration,moremsg)
293293
}
294294
function showInfo(text,duration,moremsg){
295-
info_bar.showInfo(text,duration,moremsg)
295+
return info_bar.showInfo(text,duration,moremsg)
296296
}
297297
function showWarning(text,duration,moremsg){
298-
info_bar.showWarning(text,duration,moremsg)
298+
return info_bar.showWarning(text,duration,moremsg)
299299
}
300300
function showError(text,duration,moremsg){
301-
info_bar.showError(text,duration,moremsg)
301+
return info_bar.showError(text,duration,moremsg)
302+
}
303+
function clearAllInfo(){
304+
return info_bar.clearAllInfo()
302305
}
303306
function moveWindowToDesktopCenter(){
304307
screen = Qt.application.screens[FluTools.cursorScreenIndex()]

Diff for: src/Qt6/imports/FluentUI/Controls/FluInfoBar.qml

+29-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import QtQuick
2-
import QtQuick.Controls
3-
import FluentUI
1+
import QtQuick 2.15
2+
import QtQuick.Controls 2.15
3+
import FluentUI 1.0
44

55
FluObject {
66
property var root;
@@ -18,22 +18,23 @@ FluObject {
1818
if(screenLayout){
1919
var last = screenLayout.getLastloader();
2020
if(last.type === type && last.text === text && moremsg === last.moremsg){
21-
last.restart();
22-
return;
21+
last.duration = duration
22+
if (duration > 0) last.restart();
23+
return last;
2324
}
2425
}
2526
initScreenLayout();
26-
contentComponent.createObject(screenLayout,{
27-
type:type,
28-
text:text,
29-
duration:duration,
30-
moremsg:moremsg,
31-
});
27+
return contentComponent.createObject(screenLayout,{
28+
type:type,
29+
text:text,
30+
duration:duration,
31+
moremsg:moremsg,
32+
});
3233
}
3334
function createCustom(itemcomponent,duration){
3435
initScreenLayout();
3536
if(itemcomponent){
36-
contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration});
37+
return contentComponent.createObject(screenLayout,{itemcomponent:itemcomponent,duration:duration});
3738
}
3839
}
3940
function initScreenLayout(){
@@ -85,7 +86,9 @@ FluObject {
8586
}
8687
Timer {
8788
id:delayTimer
88-
interval: duration; running: duration > 0; repeat: duration > 0
89+
interval: duration;
90+
running: duration > 0;
91+
repeat: duration > 0
8992
onTriggered: content.close();
9093
}
9194
FluLoader{
@@ -235,18 +238,26 @@ FluObject {
235238
}
236239
}
237240
function showSuccess(text,duration=1000,moremsg){
238-
mcontrol.create(mcontrol.const_success,text,duration,moremsg ? moremsg : "");
241+
return mcontrol.create(mcontrol.const_success,text,duration,moremsg ? moremsg : "");
239242
}
240243
function showInfo(text,duration=1000,moremsg){
241-
mcontrol.create(mcontrol.const_info,text,duration,moremsg ? moremsg : "");
244+
return mcontrol.create(mcontrol.const_info,text,duration,moremsg ? moremsg : "");
242245
}
243246
function showWarning(text,duration=1000,moremsg){
244-
mcontrol.create(mcontrol.const_warning,text,duration,moremsg ? moremsg : "");
247+
return mcontrol.create(mcontrol.const_warning,text,duration,moremsg ? moremsg : "");
245248
}
246249
function showError(text,duration=1000,moremsg){
247-
mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "");
250+
return mcontrol.create(mcontrol.const_error,text,duration,moremsg ? moremsg : "");
248251
}
249252
function showCustom(itemcomponent,duration=1000){
250-
mcontrol.createCustom(itemcomponent,duration);
253+
return mcontrol.createCustom(itemcomponent,duration);
254+
}
255+
function clearAllInfo(){
256+
if(mcontrol.screenLayout != null) {
257+
mcontrol.screenLayout.destroy()
258+
mcontrol.screenLayout = null
259+
}
260+
261+
return true
251262
}
252263
}

0 commit comments

Comments
 (0)