Skip to content

Commit

Permalink
fix: DciIcon can't load icon by source
Browse files Browse the repository at this point in the history
  Fallback to QQuickIconImage when `name` is empty, it will try to
load icon by fallbackSource.
  • Loading branch information
18202781743 committed Dec 11, 2023
1 parent ca277ef commit 84670c1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
23 changes: 13 additions & 10 deletions qt6/src/qml/CheckDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions src/private/dquickdciiconimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ void DQuickDciIconImageItemPrivate::maybeUpdateUrl()
{
Q_Q(DQuickIconImage);
if (parentPriv->name.isEmpty()) {
q->setSource(QUrl());
return;
return DQuickIconImagePrivate::maybeUpdateUrl();
}

QUrl url;
Expand Down
23 changes: 13 additions & 10 deletions src/qml/CheckDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 84670c1

Please sign in to comment.