MauiKit File Browsing

FavButton.qml
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import org.mauikit.controls as Maui
6import org.mauikit.filebrowsing as FB
7
8ToolButton
9{
10 id: control
11
12 property string url
13
14 readonly property alias isFav : _private.isFav
15
16 checked: isFav
17
18 icon.name: "love"
19 icon.color: mcolor
20 property color mcolor : (control.checked ? "white" : (control.pressed || control.down || control.highlighted || control.hovered ) ?Maui.Theme.highlitedTextColor : Maui.Theme.textColor)
21
22 Behavior on mcolor
23 {
24 Maui.ColorTransition{}
25 }
26
27 QtObject
28 {
29 id: _private
30 property bool isFav
31
32 Binding on isFav
33 {
34 value: control.url.length > 0 ? FB.Tagging.isFav(control.url) : false
35 restoreMode: Binding.RestoreBindingOrValue
36 delayed: true
37 }
38 }
39
40 onClicked:
41 {
42 if(!checked)
43 xAnim.restart()
44
45 FB.Tagging.toggleFav(control.url)
46 _private.isFav = FB.Tagging.isFav(control.url)
47 }
48
49 SequentialAnimation on scale
50 {
51 id: xAnim
52 // Animations on properties start running by default
53 running: false
54 loops: 3
55 NumberAnimation { from: 1; to: 0.95; duration: 100; easing.type: Easing.InBack }
56 NumberAnimation { from: 0.95; to: 1; duration: 100; easing.type: Easing.InBack }
57 PauseAnimation { duration: 40 } // This puts a bit of time between the loop
58 }
59
60 background: Rectangle
61 {
62 radius: Maui.Style.radiusV
63
64 color: control.pressed || control.down || control.highlighted || control.hovered ? Maui.Theme.hoverColor : "transparent"
65
66 Rectangle
67 {
68 anchors.fill: parent
69 color: "#f84172"
70 // visible: control.checked
71 scale: control.checked ? 1 : 0
72 radius: control.checked ? Maui.Style.radiusV : control.height
73 opacity: control.checked ? 1 : 0
74 Behavior on radius
75 {
76 NumberAnimation
77 {
78 duration: Maui.Style.units.longDuration
79 easing.type: Easing.InQuad
80 }
81 }
82
83 Behavior on scale
84 {
85 NumberAnimation
86 {
87 duration: Maui.Style.units.longDuration
88 easing.type: Easing.InQuad
89 }
90 }
91
92 Behavior on opacity
93 {
94 NumberAnimation
95 {
96 duration: Maui.Style.units.shortDuration
97 easing.type: Easing.InQuad
98 }
99 }
100 }
101
102
103 }
104}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:02 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.