102 lines
2.7 KiB
QML
102 lines
2.7 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import Quickshell
|
|
import Quickshell.Hyprland
|
|
import Quickshell.Wayland
|
|
import QtQuick
|
|
import qs.widgets.theme
|
|
|
|
// Primary application launcher (variant 8). The full-screen layer-shell adapter
|
|
// owns focus, DesktopEntries and execution; ApplicationLauncherContent remains
|
|
// an Item so the complete visual state can be rendered headlessly.
|
|
Scope {
|
|
id: root
|
|
|
|
property bool active: false
|
|
|
|
function toggle() { root.active = !root.active; }
|
|
|
|
GlobalShortcut {
|
|
name: "launcher8"
|
|
description: "Toggle dense application command index"
|
|
onPressed: root.toggle()
|
|
}
|
|
|
|
PanelWindow {
|
|
id: win
|
|
|
|
visible: root.active
|
|
WlrLayershell.layer: WlrLayer.Overlay
|
|
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
|
|
exclusionMode: ExclusionMode.Ignore
|
|
color: Theme.textAlpha(0)
|
|
|
|
anchors {
|
|
top: true
|
|
left: true
|
|
right: true
|
|
bottom: true
|
|
}
|
|
|
|
property int selectedIndex: 0
|
|
|
|
function clampSelection(index) {
|
|
if (model.apps.length === 0)
|
|
return 0;
|
|
return Math.max(0, Math.min(model.apps.length - 1, index));
|
|
}
|
|
|
|
function move(delta) {
|
|
const count = model.apps.length;
|
|
if (count === 0)
|
|
return;
|
|
selectedIndex = ((selectedIndex + delta) % count + count) % count;
|
|
}
|
|
|
|
function launch(index) {
|
|
if (model.launch(index))
|
|
root.active = false;
|
|
}
|
|
|
|
onVisibleChanged: {
|
|
if (visible) {
|
|
content.clearSearch();
|
|
selectedIndex = 0;
|
|
content.focusSearch();
|
|
}
|
|
}
|
|
|
|
AppModel {
|
|
id: model
|
|
search: content.query
|
|
}
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
color: Theme.surface
|
|
opacity: 0.72
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: root.active = false
|
|
}
|
|
}
|
|
|
|
ApplicationLauncherContent {
|
|
id: content
|
|
anchors.centerIn: parent
|
|
width: 1080
|
|
height: 620
|
|
scale: Math.min(1, (parent.width - 64) / width, (parent.height - 64) / height)
|
|
transformOrigin: Item.Center
|
|
apps: model.apps
|
|
selectedIndex: win.selectedIndex
|
|
|
|
onSelectionRequested: index => win.selectedIndex = win.clampSelection(index)
|
|
onMoveRequested: delta => win.move(delta)
|
|
onLaunchRequested: index => win.launch(index)
|
|
onDismissRequested: root.active = false
|
|
}
|
|
}
|
|
}
|