Skip to content

Commit 7497524

Browse files
committed
feat: option to animate propery changes
1 parent 604cf2e commit 7497524

File tree

4 files changed

+185
-1
lines changed

4 files changed

+185
-1
lines changed

package/contents/config/main.xml

+10
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,15 @@
8282
type="Int">
8383
<default>250</default>
8484
</entry>
85+
<entry
86+
name="animatePropertyChanges"
87+
type="Bool">
88+
<default>false</default>
89+
</entry>
90+
<entry
91+
name="animationDuration"
92+
type="Int">
93+
<default>250</default>
94+
</entry>
8595
</group>
8696
</kcfg>

package/contents/ui/code/globals.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,7 @@ const ignoredConfigs = [
269269
"enableDBusService",
270270
"dBusPollingRate",
271271
"pythonExecutable",
272-
"forceForegroundColor"
272+
"forceForegroundColor",
273+
"animatePropertyChanges",
274+
"animationDuration"
273275
]

package/contents/ui/configGeneral.qml

+28
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ KCM.SimpleKCM {
1919
property alias cfg_enableDBusService: enableDBusService.checked
2020
property alias cfg_pythonExecutable: pythonExecutable.text
2121
property alias cfg_dBusPollingRate: dBusPollingRate.value
22+
property alias cfg_animatePropertyChanges: animatePropertyChanges.checked
23+
property alias cfg_animationDuration: animationDuration.value
2224

2325
property string presetsDir: StandardPaths.writableLocation(
2426
StandardPaths.HomeLocation).toString().substring(7) + "/.config/panel-colorizer/presets"
@@ -52,6 +54,27 @@ KCM.SimpleKCM {
5254
text: i18n("Show debugging information")
5355
}
5456

57+
Kirigami.Separator {
58+
Kirigami.FormData.isSection: true
59+
Kirigami.FormData.label: i18n("Property change animations")
60+
Layout.fillWidth: true
61+
}
62+
63+
CheckBox {
64+
Kirigami.FormData.label: i18n("Enabled:")
65+
id: animatePropertyChanges
66+
onCheckedChanged: cfg_animatePropertyChanges = checked
67+
}
68+
69+
SpinBox {
70+
Kirigami.FormData.label: i18n("Duration:")
71+
from: 0
72+
to: 9999
73+
stepSize: 50
74+
id: animationDuration
75+
enabled: animatePropertyChanges.checked
76+
}
77+
5578
Kirigami.Separator {
5679
Kirigami.FormData.isSection: true
5780
Kirigami.FormData.label: i18n("D-Bus Service")
@@ -93,6 +116,7 @@ KCM.SimpleKCM {
93116
to: 9999
94117
stepSize: 100
95118
id: dBusPollingRate
119+
enabled: enableDBusService.checked
96120
}
97121

98122
Label {
@@ -113,6 +137,7 @@ KCM.SimpleKCM {
113137
readOnly: true
114138
wrapMode: Text.WordWrap
115139
Layout.preferredWidth: 400
140+
enabled: enableDBusService.checked
116141
}
117142

118143
Label {
@@ -124,6 +149,7 @@ KCM.SimpleKCM {
124149
readOnly: true
125150
wrapMode: Text.WordWrap
126151
Layout.preferredWidth: 400
152+
enabled: enableDBusService.checked
127153
}
128154

129155

@@ -136,6 +162,7 @@ KCM.SimpleKCM {
136162
readOnly: true
137163
wrapMode: Text.WordWrap
138164
Layout.preferredWidth: 400
165+
enabled: enableDBusService.checked
139166
}
140167

141168
Label {
@@ -147,6 +174,7 @@ KCM.SimpleKCM {
147174
readOnly: true
148175
wrapMode: Text.WordWrap
149176
Layout.preferredWidth: 400
177+
enabled: enableDBusService.checked
150178
}
151179
}
152180
}

package/contents/ui/main.qml

+144
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pragma ComponentBehavior: Bound
2+
13
import QtCore
24
import QtQuick
35
import QtQuick.Controls
@@ -67,6 +69,9 @@ PlasmoidItem {
6769
property Item trayWidgetBgItem
6870
property string lastPreset
6971
property var presetContent: ""
72+
property bool animatePropertyChanges: plasmoid.configuration.animatePropertyChanges
73+
property int animationDuration: plasmoid.configuration.animationDuration
74+
property int animationEasingType: Easing.OutCubic
7075
property var panelState: {
7176
"fullscreenWindow": tasksModel.fullscreenExists,
7277
"maximized": tasksModel.maximizedExists,
@@ -461,6 +466,35 @@ PlasmoidItem {
461466
bottomRightRadius: bottomRightRadius
462467
}
463468

469+
Behavior on topLeftRadius {
470+
enabled: animatePropertyChanges
471+
NumberAnimation {
472+
duration: main.animationDuration
473+
easing.type: main.animationEasingType
474+
}
475+
}
476+
Behavior on topRightRadius {
477+
enabled: animatePropertyChanges
478+
NumberAnimation {
479+
duration: main.animationDuration
480+
easing.type: main.animationEasingType
481+
}
482+
}
483+
Behavior on bottomLeftRadius {
484+
enabled: animatePropertyChanges
485+
NumberAnimation {
486+
duration: main.animationDuration
487+
easing.type: main.animationEasingType
488+
}
489+
}
490+
Behavior on bottomRightRadius {
491+
enabled: animatePropertyChanges
492+
NumberAnimation {
493+
duration: main.animationDuration
494+
easing.type: main.animationEasingType
495+
}
496+
}
497+
464498
color: {
465499
if (bgEnabled) {
466500
return getColor(bgColorCfg, targetIndex, null, itemType, bgColorHolder)
@@ -469,6 +503,14 @@ PlasmoidItem {
469503
}
470504
}
471505

506+
Behavior on color {
507+
enabled: animatePropertyChanges
508+
ColorAnimation {
509+
duration: main.animationDuration
510+
easing.type: main.animationEasingType
511+
}
512+
}
513+
472514
property int targetChildren: target.children.length
473515
onTargetChildrenChanged: {
474516
// console.error("CHILDREN CHANGED", targetChildren, target)
@@ -531,6 +573,20 @@ PlasmoidItem {
531573

532574
height: isTray ? target.height : parent.height
533575
width: isTray ? target.width : parent.width
576+
Behavior on height {
577+
enabled: animatePropertyChanges
578+
NumberAnimation {
579+
duration: main.animationDuration
580+
easing.type: main.animationEasingType
581+
}
582+
}
583+
Behavior on width {
584+
enabled: animatePropertyChanges
585+
NumberAnimation {
586+
duration: main.animationDuration
587+
easing.type: main.animationEasingType
588+
}
589+
}
534590
anchors.centerIn: (isTray || isTrayArrow) ? parent : undefined
535591
anchors.fill: (isPanel ||isTray || isTrayArrow) ? parent : undefined
536592

@@ -551,6 +607,21 @@ PlasmoidItem {
551607
+ extraBSpacing
552608
property int verticalWidth: marginTop + marginBottom
553609

610+
Behavior on horizontalWidth {
611+
enabled: animatePropertyChanges
612+
NumberAnimation {
613+
duration: main.animationDuration
614+
easing.type: main.animationEasingType
615+
}
616+
}
617+
Behavior on verticalWidth {
618+
enabled: animatePropertyChanges
619+
NumberAnimation {
620+
duration: main.animationDuration
621+
easing.type: main.animationEasingType
622+
}
623+
}
624+
554625
Binding {
555626
target: rect
556627
property: "x"
@@ -727,6 +798,14 @@ PlasmoidItem {
727798
return getColor(borderColorCfg, targetIndex, rect.color, itemType, borderRec)
728799
}
729800

801+
Behavior on borderColor {
802+
enabled: animatePropertyChanges
803+
ColorAnimation {
804+
duration: main.animationDuration
805+
easing.type: main.animationEasingType
806+
}
807+
}
808+
730809
Rectangle {
731810
id: customBorderTop
732811
width: parent.width
@@ -846,6 +925,35 @@ PlasmoidItem {
846925
}
847926
xOffset: bgShadow.xOffset
848927
yOffset: bgShadow.yOffset
928+
929+
Behavior on size {
930+
enabled: animatePropertyChanges
931+
NumberAnimation {
932+
duration: main.animationDuration
933+
easing.type: main.animationEasingType
934+
}
935+
}
936+
Behavior on xOffset {
937+
enabled: animatePropertyChanges
938+
NumberAnimation {
939+
duration: main.animationDuration
940+
easing.type: main.animationEasingType
941+
}
942+
}
943+
Behavior on yOffset {
944+
enabled: animatePropertyChanges
945+
NumberAnimation {
946+
duration: main.animationDuration
947+
easing.type: main.animationEasingType
948+
}
949+
}
950+
Behavior on color {
951+
enabled: animatePropertyChanges
952+
ColorAnimation {
953+
duration: main.animationDuration
954+
easing.type: main.animationEasingType
955+
}
956+
}
849957
}
850958

851959
// paddingRect to hide the shadow in one or two sides Qt.rect(left,top,right,bottom)
@@ -890,6 +998,34 @@ PlasmoidItem {
890998
}
891999
source: target.applet
8921000
visible: fgShadowEnabled
1001+
Behavior on color {
1002+
enabled: animatePropertyChanges
1003+
ColorAnimation {
1004+
duration: main.animationDuration
1005+
easing.type: main.animationEasingType
1006+
}
1007+
}
1008+
Behavior on radius {
1009+
enabled: animatePropertyChanges
1010+
NumberAnimation {
1011+
duration: main.animationDuration
1012+
easing.type: main.animationEasingType
1013+
}
1014+
}
1015+
Behavior on horizontalOffset {
1016+
enabled: animatePropertyChanges
1017+
NumberAnimation {
1018+
duration: main.animationDuration
1019+
easing.type: main.animationEasingType
1020+
}
1021+
}
1022+
Behavior on verticalOffset {
1023+
enabled: animatePropertyChanges
1024+
NumberAnimation {
1025+
duration: main.animationDuration
1026+
easing.type: main.animationEasingType
1027+
}
1028+
}
8931029
}
8941030

8951031
property real blurMaskX: {
@@ -1195,6 +1331,14 @@ PlasmoidItem {
11951331
Utils.panelOpacity(panelElement, isEnabled, nativePanelBackgroundOpacity)
11961332
}
11971333

1334+
Behavior on nativePanelBackgroundOpacity {
1335+
enabled: animatePropertyChanges
1336+
NumberAnimation {
1337+
duration: main.animationDuration
1338+
easing.type: main.animationEasingType
1339+
}
1340+
}
1341+
11981342
onNativePanelBackgroundEnabledChanged: {
11991343
if(!containmentItem) return
12001344
Utils.toggleTransparency(containmentItem, nativePanelBackgroundEnabled)

0 commit comments

Comments
 (0)