From 84670c1337258f9552c57eff4c5d0f494b8bb7a2 Mon Sep 17 00:00:00 2001 From: YeShanShan Date: Thu, 30 Nov 2023 13:12:32 +0800 Subject: [PATCH] fix: DciIcon can't load icon by source Fallback to QQuickIconImage when `name` is empty, it will try to load icon by fallbackSource. --- qt6/src/qml/CheckDelegate.qml | 23 +++++++++++++---------- src/private/dquickdciiconimage.cpp | 3 +-- src/qml/CheckDelegate.qml | 23 +++++++++++++---------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/qt6/src/qml/CheckDelegate.qml b/qt6/src/qml/CheckDelegate.qml index 932da37f..8db95ae2 100644 --- a/qt6/src/qml/CheckDelegate.qml +++ b/qt6/src/qml/CheckDelegate.qml @@ -10,9 +10,7 @@ import org.deepin.dtk.style 1.0 as DS T.CheckDelegate { id: control - property Component content: Label { - text: control.text - } + property Component content property D.Palette backgroundColor: DS.Style.itemDelegate.checkBackgroundColor implicitWidth: DS.Style.control.implicitWidth(control) @@ -41,15 +39,20 @@ T.CheckDelegate { } contentItem: RowLayout { - spacing: control.spacing - D.DciIcon { - palette: D.DTK.makeIconPalette(control.palette) - mode: control.D.ColorSelector.controlState - theme: control.D.ColorSelector.controlTheme - name: control.icon.name - sourceSize: Qt.size(control.icon.width, control.icon.height) + D.IconLabel { + spacing: control.spacing + mirrored: control.mirrored + display: control.display + alignment: control.display === D.IconLabel.IconOnly || control.display === D.IconLabel.TextUnderIcon + ? Qt.AlignCenter : Qt.AlignLeft | Qt.AlignVCenter + text: control.text + font: control.font + color: control.palette.windowText + icon: D.DTK.makeIcon(control.icon, control.D.DciIcon) + Layout.fillWidth: !control.content } Loader { + active: control.content sourceComponent: control.content Layout.fillWidth: true } diff --git a/src/private/dquickdciiconimage.cpp b/src/private/dquickdciiconimage.cpp index c1450b84..9e5cc13e 100644 --- a/src/private/dquickdciiconimage.cpp +++ b/src/private/dquickdciiconimage.cpp @@ -28,8 +28,7 @@ void DQuickDciIconImageItemPrivate::maybeUpdateUrl() { Q_Q(DQuickIconImage); if (parentPriv->name.isEmpty()) { - q->setSource(QUrl()); - return; + return DQuickIconImagePrivate::maybeUpdateUrl(); } QUrl url; diff --git a/src/qml/CheckDelegate.qml b/src/qml/CheckDelegate.qml index 1fc3fdb8..c5a67fdf 100644 --- a/src/qml/CheckDelegate.qml +++ b/src/qml/CheckDelegate.qml @@ -10,9 +10,7 @@ import org.deepin.dtk.style 1.0 as DS T.CheckDelegate { id: control - property Component content: Label { - text: control.text - } + property Component content property D.Palette backgroundColor: DS.Style.itemDelegate.checkBackgroundColor implicitWidth: DS.Style.control.implicitWidth(control) @@ -41,15 +39,20 @@ T.CheckDelegate { } contentItem: RowLayout { - spacing: control.spacing - D.DciIcon { - palette: D.DTK.makeIconPalette(control.palette) - mode: control.D.ColorSelector.controlState - theme: control.D.ColorSelector.controlTheme - name: control.icon.name - sourceSize: Qt.size(control.icon.width, control.icon.height) + D.IconLabel { + spacing: control.spacing + mirrored: control.mirrored + display: control.display + alignment: control.display === D.IconLabel.IconOnly || control.display === D.IconLabel.TextUnderIcon + ? Qt.AlignCenter : Qt.AlignLeft | Qt.AlignVCenter + text: control.text + font: control.font + color: control.palette.windowText + icon: D.DTK.makeIcon(control.icon, control.D.DciIcon) + Layout.fillWidth: !control.content } Loader { + active: control.content sourceComponent: control.content Layout.fillWidth: true }