Skip to content

Commit 2a63902

Browse files
committed
修复部分控件在禁用后错误高亮的问题
涉及控件如下:FluCheckBox、FluCopyableText、FluIcon、FluIconButton、FluRadioButton、FluText、FluToggleSwitch
1 parent d75ecfe commit 2a63902

19 files changed

+215
-27
lines changed

example/example_en_US.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ Updated content:
902902
<location filename="qml/page/T_Buttons.qml" line="199"/>
903903
<location filename="qml/page/T_Buttons.qml" line="320"/>
904904
<location filename="qml/page/T_Buttons.qml" line="368"/>
905-
<location filename="qml/page/T_Buttons.qml" line="421"/>
905+
<location filename="qml/page/T_Buttons.qml" line="419"/>
906906
<source>Disabled</source>
907907
<translation type="unfinished"></translation>
908908
</message>
@@ -1022,12 +1022,12 @@ Updated content:
10221022
<translation type="unfinished"></translation>
10231023
</message>
10241024
<message>
1025-
<location filename="qml/page/T_Buttons.qml" line="408"/>
1025+
<location filename="qml/page/T_Buttons.qml" line="407"/>
10261026
<source>Radio Button_2</source>
10271027
<translation type="unfinished"></translation>
10281028
</message>
10291029
<message>
1030-
<location filename="qml/page/T_Buttons.qml" line="412"/>
1030+
<location filename="qml/page/T_Buttons.qml" line="410"/>
10311031
<source>Radio Button_3</source>
10321032
<translation type="unfinished"></translation>
10331033
</message>
@@ -1421,7 +1421,12 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
14211421
<translation type="unfinished"></translation>
14221422
</message>
14231423
<message>
1424-
<location filename="qml/page/T_Icons.qml" line="51"/>
1424+
<location filename="qml/page/T_Icons.qml" line="28"/>
1425+
<source>Disabled</source>
1426+
<translation type="unfinished"></translation>
1427+
</message>
1428+
<message>
1429+
<location filename="qml/page/T_Icons.qml" line="61"/>
14251430
<source>You Copied </source>
14261431
<translation type="unfinished"></translation>
14271432
</message>
@@ -2185,10 +2190,15 @@ Some contents...</source>
21852190
<translation type="unfinished"></translation>
21862191
</message>
21872192
<message>
2188-
<location filename="qml/page/T_Text.qml" line="18"/>
2193+
<location filename="qml/page/T_Text.qml" line="19"/>
21892194
<source>This is a text that can be copied</source>
21902195
<translation type="unfinished"></translation>
21912196
</message>
2197+
<message>
2198+
<location filename="qml/page/T_Text.qml" line="29"/>
2199+
<source>Disabled</source>
2200+
<translation type="unfinished"></translation>
2201+
</message>
21922202
</context>
21932203
<context>
21942204
<name>T_TextBox</name>

example/example_zh_CN.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ Updated content:
929929
<location filename="qml/page/T_Buttons.qml" line="199"/>
930930
<location filename="qml/page/T_Buttons.qml" line="320"/>
931931
<location filename="qml/page/T_Buttons.qml" line="368"/>
932-
<location filename="qml/page/T_Buttons.qml" line="421"/>
932+
<location filename="qml/page/T_Buttons.qml" line="419"/>
933933
<source>Disabled</source>
934934
<translation type="unfinished">禁用</translation>
935935
</message>
@@ -1049,12 +1049,12 @@ Updated content:
10491049
<translation type="unfinished"></translation>
10501050
</message>
10511051
<message>
1052-
<location filename="qml/page/T_Buttons.qml" line="408"/>
1052+
<location filename="qml/page/T_Buttons.qml" line="407"/>
10531053
<source>Radio Button_2</source>
10541054
<translation type="unfinished"></translation>
10551055
</message>
10561056
<message>
1057-
<location filename="qml/page/T_Buttons.qml" line="412"/>
1057+
<location filename="qml/page/T_Buttons.qml" line="410"/>
10581058
<source>Radio Button_3</source>
10591059
<translation type="unfinished"></translation>
10601060
</message>
@@ -1538,12 +1538,17 @@ My only desire is to be permitted to drive out the traitors and restore the Han.
15381538
<source>Please enter a keyword</source>
15391539
<translation type="unfinished">请输入关键字</translation>
15401540
</message>
1541+
<message>
1542+
<location filename="qml/page/T_Icons.qml" line="28"/>
1543+
<source>Disabled</source>
1544+
<translation type="unfinished">禁用</translation>
1545+
</message>
15411546
<message>
15421547
<source>Search</source>
15431548
<translation type="obsolete">搜索</translation>
15441549
</message>
15451550
<message>
1546-
<location filename="qml/page/T_Icons.qml" line="51"/>
1551+
<location filename="qml/page/T_Icons.qml" line="61"/>
15471552
<source>You Copied </source>
15481553
<translation type="unfinished">您复制</translation>
15491554
</message>
@@ -2367,10 +2372,15 @@ Some contents...</source>
23672372
<translation type="unfinished">文本</translation>
23682373
</message>
23692374
<message>
2370-
<location filename="qml/page/T_Text.qml" line="18"/>
2375+
<location filename="qml/page/T_Text.qml" line="19"/>
23712376
<source>This is a text that can be copied</source>
23722377
<translation type="unfinished">这是一个可以复制的文本</translation>
23732378
</message>
2379+
<message>
2380+
<location filename="qml/page/T_Text.qml" line="29"/>
2381+
<source>Disabled</source>
2382+
<translation type="unfinished">禁用</translation>
2383+
</message>
23742384
</context>
23752385
<context>
23762386
<name>T_TextBox</name>

example/qml/page/T_Buttons.qml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,16 +399,14 @@ FluScrollablePage{
399399
verticalCenter: parent.verticalCenter
400400
left: parent.left
401401
}
402+
disabled: radio_button_switch.checked
402403
FluRadioButton{
403-
disabled:radio_button_switch.checked
404404
text: qsTr("Radio Button_1")
405405
}
406406
FluRadioButton{
407-
disabled:radio_button_switch.checked
408407
text: qsTr("Radio Button_2")
409408
}
410409
FluRadioButton{
411-
disabled:radio_button_switch.checked
412410
text: qsTr("Radio Button_3")
413411
}
414412
}

example/qml/page/T_Icons.qml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ FluContentPage {
1818
grid_view.model = FluApp.iconData(text_box.text)
1919
}
2020
}
21+
FluToggleSwitch{
22+
id: toggle_switch
23+
anchors{
24+
left: text_box.right
25+
verticalCenter: text_box.verticalCenter
26+
leftMargin: 10
27+
}
28+
text: qsTr("Disabled")
29+
}
2130
GridView{
2231
id: grid_view
2332
cellWidth: 110
@@ -45,6 +54,7 @@ FluContentPage {
4554
horizontalPadding: 0
4655
bottomPadding: 30
4756
anchors.fill: parent
57+
disabled: toggle_switch.checked
4858
onClicked: {
4959
var text ="FluentIcons."+modelData.name;
5060
FluTools.clipText(text)
@@ -57,6 +67,7 @@ FluContentPage {
5767
text: modelData.name
5868
anchors.top: parent.top
5969
anchors.topMargin: 60
70+
enabled: !toggle_switch.checked
6071
}
6172
}
6273
}

example/qml/page/T_Text.qml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,19 @@ FluScrollablePage{
1515
padding: 10
1616

1717
FluCopyableText{
18+
enabled: !toggle_switch.checked
1819
text: qsTr("This is a text that can be copied")
1920
anchors.verticalCenter: parent.verticalCenter
2021
}
2122

23+
FluToggleSwitch{
24+
id: toggle_switch
25+
anchors{
26+
right: parent.right
27+
verticalCenter: parent.verticalCenter
28+
}
29+
text: qsTr("Disabled")
30+
}
2231
}
2332
CodeExpander{
2433
Layout.fillWidth: true

src/Qt5/imports/FluentUI/Controls/FluCheckBox.qml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,19 @@ Button {
1919
property color checkedDisableColor: FluTheme.dark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
2020
property color disableColor: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(253/255,253/255,253/255,1)
2121
property real size: 18
22-
property alias textColor: btn_text.textColor
22+
property color textColor: {
23+
if(FluTheme.dark){
24+
if(!enabled){
25+
return Qt.rgba(130/255,130/255,130/255,1)
26+
}
27+
return Qt.rgba(1,1,1,1)
28+
}else{
29+
if(!enabled){
30+
return Qt.rgba(161/255,161/255,161/255,1)
31+
}
32+
return Qt.rgba(0,0,0,1)
33+
}
34+
}
2335
property bool textRight: true
2436
property real textSpacing: 6
2537
property bool animationEnabled: FluTheme.animationEnabled
@@ -127,6 +139,7 @@ Button {
127139
Layout.alignment: Qt.AlignVCenter
128140
visible: text !== ""
129141
font: control.font
142+
color: control.textColor
130143
}
131144
}
132145
}

src/Qt5/imports/FluentUI/Controls/FluCopyableText.qml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,19 @@ import QtQuick.Controls 2.15
33
import FluentUI 1.0
44

55
TextEdit {
6-
property color textColor: FluTheme.dark ? FluColors.White : FluColors.Grey220
6+
property color textColor: {
7+
if(FluTheme.dark){
8+
if(!enabled){
9+
return Qt.rgba(130/255,130/255,130/255,1)
10+
}
11+
return Qt.rgba(1,1,1,1)
12+
}else{
13+
if(!enabled){
14+
return Qt.rgba(161/255,161/255,161/255,1)
15+
}
16+
return Qt.rgba(0,0,0,1)
17+
}
18+
}
719
id:control
820
color: textColor
921
readOnly: true

src/Qt5/imports/FluentUI/Controls/FluIcon.qml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,19 @@ import FluentUI 1.0
55
Text {
66
property int iconSource
77
property int iconSize: 20
8-
property color iconColor: FluTheme.dark ? "#FFFFFF" : "#000000"
8+
property color iconColor: {
9+
if(FluTheme.dark){
10+
if(!enabled){
11+
return Qt.rgba(130/255,130/255,130/255,1)
12+
}
13+
return Qt.rgba(1,1,1,1)
14+
}else{
15+
if(!enabled){
16+
return Qt.rgba(161/255,161/255,161/255,1)
17+
}
18+
return Qt.rgba(0,0,0,1)
19+
}
20+
}
921
id:control
1022
font.family: font_loader.name
1123
font.pixelSize: iconSize

src/Qt5/imports/FluentUI/Controls/FluIconButton.qml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,19 @@ Button {
3737
return Qt.rgba(0,0,0,1)
3838
}
3939
}
40-
property color textColor: FluTheme.fontPrimaryColor
40+
property color textColor: {
41+
if(FluTheme.dark){
42+
if(!enabled){
43+
return Qt.rgba(130/255,130/255,130/255,1)
44+
}
45+
return Qt.rgba(1,1,1,1)
46+
}else{
47+
if(!enabled){
48+
return Qt.rgba(161/255,161/255,161/255,1)
49+
}
50+
return Qt.rgba(0,0,0,1)
51+
}
52+
}
4153
Accessible.role: Accessible.Button
4254
Accessible.name: control.text
4355
Accessible.description: contentDescription

src/Qt5/imports/FluentUI/Controls/FluRadioButton.qml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,19 @@ Button {
1111
property color normalColor: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(1,1,1,1)
1212
property color hoverColor: checked ? FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(1,1,1,1) : FluTheme.dark ? Qt.rgba(43/255,43/255,43/255,1) : Qt.rgba(222/255,222/255,222/255,1)
1313
property color disableColor: checked ? FluTheme.dark ? Qt.rgba(159/255,159/255,159/255,1) : Qt.rgba(159/255,159/255,159/255,1) : FluTheme.dark ? Qt.rgba(43/255,43/255,43/255,1) : Qt.rgba(222/255,222/255,222/255,1)
14-
property alias textColor: btn_text.textColor
14+
property color textColor: {
15+
if(FluTheme.dark){
16+
if(!enabled){
17+
return Qt.rgba(130/255,130/255,130/255,1)
18+
}
19+
return Qt.rgba(1,1,1,1)
20+
}else{
21+
if(!enabled){
22+
return Qt.rgba(161/255,161/255,161/255,1)
23+
}
24+
return Qt.rgba(0,0,0,1)
25+
}
26+
}
1527
property real size: 18
1628
property bool textRight: true
1729
property real textSpacing: 6
@@ -94,6 +106,7 @@ Button {
94106
Layout.alignment: Qt.AlignVCenter
95107
visible: text !== ""
96108
font: control.font
109+
color: control.textColor
97110
}
98111
}
99112
}

src/Qt5/imports/FluentUI/Controls/FluText.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import FluentUI 1.0
55
Text {
66
property color textColor: FluTheme.fontPrimaryColor
77
id:text
8-
color: textColor
8+
color: enabled ? textColor : (FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1))
99
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
1010
font: FluTextStyle.Body
1111
}

src/Qt5/imports/FluentUI/Controls/FluToggleSwitch.qml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,19 @@ Button {
1818
property color dotDisableColor: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(150/255,150/255,150/255,1)
1919
property real textSpacing: 6
2020
property bool textRight: true
21-
property alias textColor: btn_text.textColor
21+
property color textColor: {
22+
if(FluTheme.dark){
23+
if(!enabled){
24+
return Qt.rgba(130/255,130/255,130/255,1)
25+
}
26+
return Qt.rgba(1,1,1,1)
27+
}else{
28+
if(!enabled){
29+
return Qt.rgba(161/255,161/255,161/255,1)
30+
}
31+
return Qt.rgba(0,0,0,1)
32+
}
33+
}
2234
property var clickListener : function(){
2335
checked = !checked
2436
}
@@ -115,6 +127,7 @@ Button {
115127
text: control.text
116128
Layout.alignment: Qt.AlignVCenter
117129
visible: text !== ""
130+
color: control.textColor
118131
}
119132
}
120133
}

src/Qt6/imports/FluentUI/Controls/FluCheckBox.qml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,19 @@ Button {
2020
property color checkedDisableColor: FluTheme.dark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
2121
property color disableColor: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(253/255,253/255,253/255,1)
2222
property real size: 18
23-
property alias textColor: btn_text.textColor
23+
property color textColor: {
24+
if(FluTheme.dark){
25+
if(!enabled){
26+
return Qt.rgba(130/255,130/255,130/255,1)
27+
}
28+
return Qt.rgba(1,1,1,1)
29+
}else{
30+
if(!enabled){
31+
return Qt.rgba(161/255,161/255,161/255,1)
32+
}
33+
return Qt.rgba(0,0,0,1)
34+
}
35+
}
2436
property bool textRight: true
2537
property real textSpacing: 6
2638
property bool animationEnabled: FluTheme.animationEnabled
@@ -129,6 +141,7 @@ Button {
129141
Layout.alignment: Qt.AlignVCenter
130142
visible: text !== ""
131143
font: control.font
144+
color: control.textColor
132145
}
133146
}
134147
}

src/Qt6/imports/FluentUI/Controls/FluCopyableText.qml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,19 @@ import QtQuick.Controls
33
import FluentUI
44

55
TextEdit {
6-
property color textColor: FluTheme.dark ? FluColors.White : FluColors.Grey220
6+
property color textColor: {
7+
if(FluTheme.dark){
8+
if(!enabled){
9+
return Qt.rgba(130/255,130/255,130/255,1)
10+
}
11+
return Qt.rgba(1,1,1,1)
12+
}else{
13+
if(!enabled){
14+
return Qt.rgba(161/255,161/255,161/255,1)
15+
}
16+
return Qt.rgba(0,0,0,1)
17+
}
18+
}
719
id:control
820
color: textColor
921
readOnly: true

0 commit comments

Comments
 (0)