From 875bba2bd6a4d3c1a09c8c5c904a07036f927043 Mon Sep 17 00:00:00 2001
From: ToMoree <270523346@qq.com>
Date: Wed, 6 Nov 2024 10:13:07 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dicon=E6=8C=89=E9=92=AE?=
=?UTF-8?q?=EF=BC=8C=E5=8D=95=E9=80=89=E6=8C=89=E9=92=AE=E7=AD=89=E6=8E=A7?=
=?UTF-8?q?=E4=BB=B6disable=E5=90=8E=EF=BC=8C=E6=8E=A7=E4=BB=B6=E6=96=87?=
=?UTF-8?q?=E6=9C=AC=E4=BB=8D=E7=84=B6=E9=AB=98=E4=BA=AE=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
为flutext 和 fluicon增加disable时的alpha值,简化其他控件中对text的disable时颜色的独立控制
---
example/example_en_US.ts | 8 ++++----
example/example_zh_CN.ts | 8 ++++----
example/qml/page/T_Buttons.qml | 5 +++--
src/Qt5/imports/FluentUI/Controls/FluButton.qml | 10 ++--------
src/Qt5/imports/FluentUI/Controls/FluIcon.qml | 5 +++--
src/Qt5/imports/FluentUI/Controls/FluIconButton.qml | 12 +++---------
src/Qt5/imports/FluentUI/Controls/FluImage.qml | 3 ++-
.../imports/FluentUI/Controls/FluLoadingButton.qml | 4 ++--
src/Qt5/imports/FluentUI/Controls/FluText.qml | 4 ++--
9 files changed, 25 insertions(+), 34 deletions(-)
diff --git a/example/example_en_US.ts b/example/example_en_US.ts
index e22c8eda..e00c5884 100644
--- a/example/example_en_US.ts
+++ b/example/example_en_US.ts
@@ -902,7 +902,7 @@ Updated content:
-
+
@@ -1017,17 +1017,17 @@ Updated content:
-
+
-
+
-
+
diff --git a/example/example_zh_CN.ts b/example/example_zh_CN.ts
index 71fd7ad2..4a696065 100644
--- a/example/example_zh_CN.ts
+++ b/example/example_zh_CN.ts
@@ -929,7 +929,7 @@ Updated content:
-
+
禁用
@@ -1044,17 +1044,17 @@ Updated content:
-
+
-
+
-
+
diff --git a/example/qml/page/T_Buttons.qml b/example/qml/page/T_Buttons.qml
index eee6ee32..2344ec12 100644
--- a/example/qml/page/T_Buttons.qml
+++ b/example/qml/page/T_Buttons.qml
@@ -1,4 +1,4 @@
-import QtQuick 2.15
+import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
@@ -265,7 +265,7 @@ FluScrollablePage{
}
FluIconButton{
disabled: icon_button_switch.checked
- iconDelegate: Image{ sourceSize: Qt.size(40,40) ; width: 20; height: 20; source: "qrc:/example/res/image/ic_home_github.png" }
+ iconDelegate: FluImage{ sourceSize: Qt.size(40,40) ; width: 20; height: 20; source: "qrc:/example/res/image/ic_home_github.png" }
onClicked:{
showSuccess(qsTr("Click IconButton"))
}
@@ -395,6 +395,7 @@ FluScrollablePage{
Layout.topMargin: 20
FluRadioButtons{
spacing: 8
+ disabled: radio_button_switch.checked
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
diff --git a/src/Qt5/imports/FluentUI/Controls/FluButton.qml b/src/Qt5/imports/FluentUI/Controls/FluButton.qml
index 499ed8be..15ddc3d8 100644
--- a/src/Qt5/imports/FluentUI/Controls/FluButton.qml
+++ b/src/Qt5/imports/FluentUI/Controls/FluButton.qml
@@ -1,4 +1,4 @@
-import QtQuick 2.15
+import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
@@ -11,17 +11,11 @@ Button {
property color dividerColor: FluTheme.dark ? Qt.rgba(80/255,80/255,80/255,1) : Qt.rgba(233/255,233/255,233/255,1)
property color textColor: {
if(FluTheme.dark){
- if(!enabled){
- return Qt.rgba(131/255,131/255,131/255,1)
- }
if(pressed){
return Qt.rgba(162/255,162/255,162/255,1)
}
return Qt.rgba(1,1,1,1)
}else{
- if(!enabled){
- return Qt.rgba(160/255,160/255,160/255,1)
- }
if(pressed){
return Qt.rgba(96/255,96/255,96/255,1)
}
@@ -59,6 +53,6 @@ Button {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font: control.font
- color: control.textColor
+ textColor: control.textColor
}
}
diff --git a/src/Qt5/imports/FluentUI/Controls/FluIcon.qml b/src/Qt5/imports/FluentUI/Controls/FluIcon.qml
index 7b1f6098..2561fe5d 100644
--- a/src/Qt5/imports/FluentUI/Controls/FluIcon.qml
+++ b/src/Qt5/imports/FluentUI/Controls/FluIcon.qml
@@ -1,4 +1,4 @@
-import QtQuick 2.15
+import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
@@ -11,7 +11,8 @@ Text {
font.pixelSize: iconSize
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
- color: iconColor
+ color: enabled ? iconColor : Qt.rgba(iconColor.r, iconColor.g, iconColor.b, iconColor.a * 0.5)
+
text: (String.fromCharCode(iconSource).toString(16))
opacity: iconSource>0
FontLoader{
diff --git a/src/Qt5/imports/FluentUI/Controls/FluIconButton.qml b/src/Qt5/imports/FluentUI/Controls/FluIconButton.qml
index f76e3c82..734f7bf3 100644
--- a/src/Qt5/imports/FluentUI/Controls/FluIconButton.qml
+++ b/src/Qt5/imports/FluentUI/Controls/FluIconButton.qml
@@ -1,4 +1,4 @@
-import QtQuick 2.15
+import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import FluentUI 1.0
@@ -26,14 +26,8 @@ Button {
}
property color iconColor: {
if(FluTheme.dark){
- if(!enabled){
- return Qt.rgba(130/255,130/255,130/255,1)
- }
return Qt.rgba(1,1,1,1)
}else{
- if(!enabled){
- return Qt.rgba(161/255,161/255,161/255,1)
- }
return Qt.rgba(0,0,0,1)
}
}
@@ -82,7 +76,7 @@ Button {
text:control.text
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
visible: display !== Button.IconOnly
- color: control.textColor
+ textColor: control.textColor
font: control.font
}
}
@@ -99,7 +93,7 @@ Button {
text:control.text
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
visible: display !== Button.IconOnly
- color: control.textColor
+ textColor: control.textColor
font: control.font
}
}
diff --git a/src/Qt5/imports/FluentUI/Controls/FluImage.qml b/src/Qt5/imports/FluentUI/Controls/FluImage.qml
index ca9ad8be..62a86aa8 100644
--- a/src/Qt5/imports/FluentUI/Controls/FluImage.qml
+++ b/src/Qt5/imports/FluentUI/Controls/FluImage.qml
@@ -1,4 +1,4 @@
-import QtQuick 2.15
+import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
@@ -11,6 +11,7 @@ Image {
property Component errorItem : com_error
property Component loadingItem: com_loading
id: control
+ opacity: enabled ? 1 : 0.5
FluLoader{
anchors.fill: parent
sourceComponent: {
diff --git a/src/Qt5/imports/FluentUI/Controls/FluLoadingButton.qml b/src/Qt5/imports/FluentUI/Controls/FluLoadingButton.qml
index e8318f25..371badd3 100644
--- a/src/Qt5/imports/FluentUI/Controls/FluLoadingButton.qml
+++ b/src/Qt5/imports/FluentUI/Controls/FluLoadingButton.qml
@@ -1,4 +1,4 @@
-import QtQuick 2.15
+import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
@@ -13,7 +13,7 @@ FluButton {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
font: control.font
- color: control.textColor
+ textColor: control.textColor
anchors.verticalCenter: parent.verticalCenter
}
Item{
diff --git a/src/Qt5/imports/FluentUI/Controls/FluText.qml b/src/Qt5/imports/FluentUI/Controls/FluText.qml
index 029c6d2d..5358efcb 100644
--- a/src/Qt5/imports/FluentUI/Controls/FluText.qml
+++ b/src/Qt5/imports/FluentUI/Controls/FluText.qml
@@ -1,11 +1,11 @@
-import QtQuick 2.15
+import QtQuick 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
Text {
property color textColor: FluTheme.fontPrimaryColor
id:text
- color: textColor
+ color: enabled ? textColor : Qt.rgba(textColor.r, textColor.g, textColor.b, textColor.a * 0.7)
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
font: FluTextStyle.Body
}