blob: fc0dc3d14cdd5f66ac1f1c668f4dfdbde611c68c (
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import Quickshell.Wayland
PanelWindow {
id: root
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.namespace: "launcher"
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
WlrLayershell.exclusiveZone: -1
exclusionMode: ExclusionMode.Ignore
// Centering logic
anchors {
top: true
}
margins.top: 200
implicitWidth: 600
implicitHeight: 400
color: "transparent"
visible: GlobalState.activePopup === "Launcher"
onVisibleChanged: {
if (visible) {
searchInput.forceActiveFocus()
searchInput.text = ""
}
}
Scope {
id: internal
function filterApps(searchText) {
const search = searchText.toLowerCase()
const apps = DesktopEntries.applications.values
return apps.filter(app => {
if (app.noDisplay) return false
if (!search) return true
return app.name.toLowerCase().includes(search) ||
(app.comment && app.comment.toLowerCase().includes(search))
})
}
}
FocusScope {
anchors.fill: parent
focus: true
Squircle {
id: launcherContent
anchors.fill: parent
cornerRadius: 12
fillColor: Theme.barBg
strokeColor: Theme.border
strokeWidth: 1
// Capture Escape to close
Keys.onEscapePressed: GlobalState.close()
ColumnLayout {
anchors.fill: parent
anchors.margins: 12
spacing: 8
// Search Header
RowLayout {
Layout.fillWidth: true
spacing: 12
Image {
width: 24; height: 24
source: Quickshell.iconPath("system-search-symbolic")
sourceSize: Qt.size(24, 24)
smooth: true
mipmap: true
opacity: 0.7
}
TextInput {
id: searchInput
Layout.fillWidth: true
font {
family: Theme.mainFont
pixelSize: 20
}
color: Theme.text
clip: true
focus: true
cursorVisible: true
selectByMouse: true
inputMethodHints: Qt.ImhNoPredictiveText
Text {
visible: searchInput.text === ""
text: "Search Applications..."
color: Theme.text
opacity: 0.3
font: searchInput.font
}
onTextChanged: resultsList.currentIndex = 0
Keys.onPressed: event => {
if (event.key === Qt.Key_Down) {
resultsList.incrementCurrentIndex()
event.accepted = true
} else if (event.key === Qt.Key_Up) {
resultsList.decrementCurrentIndex()
event.accepted = true
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
if (resultsList.count > 0 && resultsList.currentIndex >= 0) {
if (resultsList.currentItem) {
resultsList.currentItem.launch()
}
}
event.accepted = true
}
}
}
}
Rectangle {
Layout.fillWidth: true
height: 1
color: Theme.border
}
ListView {
id: resultsList
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
boundsBehavior: Flickable.StopAtBounds
highlightFollowsCurrentItem: true
highlightMoveDuration: 150
highlightResizeDuration: 0
highlight: Squircle {
width: resultsList.width
height: 44
cornerRadius: 8
fillColor: Theme.surface
z: 1
}
model: internal.filterApps(searchInput.text)
delegate: Squircle {
id: delegateRoot
required property var modelData
required property int index
height: 44
width: resultsList.width
cornerRadius: 8
fillColor: "transparent"
z: 5
function launch() {
if (modelData && modelData.execute) {
modelData.execute()
GlobalState.close()
}
}
RowLayout {
anchors.fill: parent
anchors.leftMargin: 12
anchors.rightMargin: 12
spacing: 12
Image {
width: 24; height: 24
source: Quickshell.iconPath(modelData.icon)
sourceSize: Qt.size(32, 32)
smooth: true
mipmap: true
}
Column {
Layout.fillWidth: true
Text {
text: delegateRoot.modelData.name
color: Theme.text
font {
family: Theme.mainFont
pixelSize: 14
weight: Font.Medium
}
}
Text {
visible: delegateRoot.modelData.comment !== ""
text: delegateRoot.modelData.comment
color: Theme.textMuted
font {
family: Theme.mainFont
pixelSize: 11
}
elide: Text.ElideRight
width: parent.width
}
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: resultsList.currentIndex = index
onClicked: delegateRoot.launch()
}
}
ScrollBar.vertical: ScrollBar {}
}
}
}
}
}
|