Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch animations #408

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

kegechen
Copy link
Contributor

@kegechen kegechen commented Oct 21, 2024

add DTK.hasAnimation property and DQMLGlobalObject::hasAnimation()

@deepin-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: kegechen

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

deepin-ci-robot added a commit to linuxdeepin/dtk6declarative that referenced this pull request Oct 21, 2024
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#408
qt6/src/qml/Switch.qml Outdated Show resolved Hide resolved
src/private/dquickdciiconimage.cpp Outdated Show resolved Hide resolved
src/private/dqmlglobalobject_p.h Show resolved Hide resolved
deepin-ci-robot added a commit to linuxdeepin/dtk6declarative that referenced this pull request Oct 21, 2024
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#408
deepin-ci-robot added a commit to linuxdeepin/dtk6declarative that referenced this pull request Oct 21, 2024
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#408
DTK.hasAnimation and DQMLGlobalObject::hasAnimation()
hasAnimation to turn on/off animations
support DTK.hasAnimation
deepin-ci-robot added a commit to linuxdeepin/dtk6declarative that referenced this pull request Oct 22, 2024
Synchronize source files from linuxdeepin/dtkdeclarative.

Source-pull-request: linuxdeepin/dtkdeclarative#408
@@ -94,18 +99,32 @@ T.ToolButton {
NumberAnimation { properties: "scale"; easing.type: Easing.InOutQuad }
}

onHoveredChanged: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

background可能被调用者重写,不能在外面用id的方式访问,否则可能访问无效,
buttonPanel.visible = 这种,直接赋值会中断绑定,尽量用属性绑定的方式

visible: control.state === "hovered"
scale : 0.9
id: buttonPanel
property var customColor: D.Palette {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接用属性绑定的方式给color1和color2赋值,

Comment on lines +125 to +127
buttonPanel.scale = 0.9
buttonPanel.color1 = buttonPanel.customColor
buttonPanel.color2 = buttonPanel.customColor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该少这种函数式的写法,直接用属性绑定方式,另外,为什么这里,有动画的时候scale需要设置为0.9呀,在上面不是1.0么,这个时机只有在初始化完成的时候做一次么?

Comment on lines +13 to +18
property D.Palette textColor: {
if (D.DTK.hasAnimation)
return checked ? DS.Style.highlightedButton.text : (highlighted ? DS.Style.highlightedButton.text : DS.Style.button.text)

return checked ? DS.Style.checkedButton.text : (highlighted ? DS.Style.highlightedButton.text : DS.Style.button.text)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

它们之间的差别是 checked的时候,有动画取highlightedButton.text,没动画取checkedButton.text?
这是设计上的区别么?

}

indicator: D.DTK.hasAnimation ? dciIcon.createObject(control) : rect.createObject(control)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该可以直接用Loader去实现,它可以自己去管理创建的对象,用createObject的话靠的是set indicator方法了,比较隐晦,

handle.play(D.DTK.NormalState)
toggletimer.start();
Component {
id: dciIcon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

组件名字尽量取有意义的,animationIndicatorCom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants