blob: ef1245794d74dcf76a883831cbd240411511d975 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Wayland
import Quickshell.Widgets
import qs.components
import qs.config
// TODO use a item wrapping loader for opacity Behavior
IRect {
id: root
// hyprland toplevel isn't shown immediately...
property var toplevel: ToplevelManager.activeToplevel
property var icon: Quickshell.iconPath(AppSearch.guessIcon(toplevel?.appId), "image-missing")
property var activated: toplevel?.activated || false
implicitWidth: activated ? rowLayout.implicitWidth + General.rectMargin * 4 : 0
implicitHeight: rowLayout.implicitHeight + General.rectMargin * 2
anchors.centerIn: parent
color: Qt.rgba(Colors.background3.r, Colors.background3.g, Colors.background3.b, Bar.bgTransparency)
// according to docs, null could happen but doesn't seem to happen in practice so..
// hypr toplevel.activated is always true and doesn't change either so..
opacity: activated ? 1 : 0
radius: Style.rounding.smaller
function strip(s) {
var out = s;
Bar.windowStrip.forEach(function (w) {
out = out?.replace(new RegExp(w, "g"), "");
});
return out?.trim() || s;
}
RowLayout {
id: rowLayout
anchors.centerIn: parent
spacing: Bar.resourceIconTextSpacing
IconImage {
id: icon
source: root.icon
implicitWidth: Bar.appIconSize
implicitHeight: Bar.appIconSize
// sync animation
opacity: root.activated ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: General.animateDuration / 4
}
}
}
IText {
animate: true
font.pixelSize: General.fontSize
text: strip(root?.toplevel?.title) || ""
// sync animation
opacity: root.activated ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: General.animateDuration / 4
}
}
}
}
onIconChanged: fadeIcon.start()
Behavior on opacity {
NumberAnimation {
duration: General.animateDuration / 4
}
}
Behavior on implicitWidth {
ISpringAnimation {
spring: General.springAnimationSpring * 2
damping: General.springAnimationDamping * 1.3
}
}
SequentialAnimation {
id: fadeIcon
running: false
PropertyAnimation {
target: icon
property: "opacity"
to: 0
duration: General.animateDuration / 4
}
ScriptAction {
script: icon.source = root.icon
}
PropertyAnimation {
target: icon
property: "opacity"
to: 1
duration: General.animateDuration / 4
}
ScriptAction {
script: icon.source = root.icon
}
}
}
|