Skip to content

Commit

Permalink
feat: CheckDelegate animation
Browse files Browse the repository at this point in the history
listview check animation(dci)
  • Loading branch information
kegechen committed Aug 5, 2024
1 parent 3ac175c commit 6f702a2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
25 changes: 21 additions & 4 deletions qt6/src/qml/CheckDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ T.CheckDelegate {
id: control
property Component content
property D.Palette backgroundColor: DS.Style.itemDelegate.checkBackgroundColor
property string indicatorIcon: control.checkState === Qt.Unchecked ? "item_unchecked" : "item_checked"
property bool indicatorVisible: control.checked

implicitWidth: DS.Style.control.implicitWidth(control)
implicitHeight: DS.Style.control.implicitHeight(control)
Expand All @@ -26,15 +28,22 @@ T.CheckDelegate {
indicator: Loader {
x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding
y: control.topPadding + (control.availableHeight - height) / 2
active: control.checked
active: indicatorVisible

sourceComponent: D.DciIcon {
palette: control.D.DTK.makeIconPalette(control.palette)
mode: control.D.ColorSelector.controlState
theme: control.D.ColorSelector.controlTheme
name: "menu_select"
name: indicatorIcon
sourceSize: Qt.size(DS.Style.itemDelegate.checkIndicatorIconSize, DS.Style.itemDelegate.checkIndicatorIconSize)
fallbackToQIcon: false
onNameChanged: {
play(D.DTK.NormalState);
}
Component.onCompleted: {
if (indicatorVisible)
play(D.DTK.NormalState);
}
}
}

Expand All @@ -58,12 +67,12 @@ T.CheckDelegate {
}
}

background: Item {
background: Control {
implicitWidth: DS.Style.itemDelegate.width
implicitHeight: DS.Style.itemDelegate.height
Rectangle {
anchors.fill: parent
visible: !checked
visible: !checked && !control.ListView.view
color: control.D.ColorSelector.backgroundColor
radius: DS.Style.control.radius
}
Expand All @@ -74,4 +83,12 @@ T.CheckDelegate {
radius: DS.Style.control.radius
}
}

onHoveredChanged: {
if (checked || !ListView.view)
return

if (ListView.view)
ListView.view.setHoverItem(control.hovered ? control : null)
}
}
2 changes: 2 additions & 0 deletions src/dtkdeclarative_assets.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
<file alias="built-in-icons/list_delete.dci">icons/bloom/list_delete.dci</file>
<file alias="built-in-icons/menu_arrow.dci">icons/bloom/menu_arrow.dci</file>
<file alias="built-in-icons/menu_select.dci">icons/bloom/menu_select.dci</file>
<file alias="built-in-icons/item_checked.dci">icons/bloom/item_checked.dci</file>
<file alias="built-in-icons/item_unchecked.dci">icons/bloom/item_unchecked.dci</file>
<file alias="built-in-icons/window_sidebar.dci">icons/bloom/window_sidebar.dci</file>
<file alias="built-in-icons/action_add.dci">icons/bloom/action_add.dci</file>
<file alias="built-in-icons/radio_checked.dci">icons/bloom/radio_checked.dci</file>
Expand Down
Binary file added src/icons/bloom/item_checked.dci
Binary file not shown.
Binary file added src/icons/bloom/item_unchecked.dci
Binary file not shown.

0 comments on commit 6f702a2

Please sign in to comment.