Files
darmanandClaude Opus 5.5 896368ef56 feat(terra): launcher most-used sort, power buttons, SUPER opens rail
- Launcher sorts by launch count by default (persisted in quickshell's
  state dir); Ctrl+S or the sort chip toggles A–Z.
- Logout/Reboot/Shutdown in the footer, each needing a confirming click.
- SUPER now opens the launcher with the rail expanded; closing the
  launcher collapses the rail again unless it was already open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 01:26:44 +02:00

142 lines
4.6 KiB
QML

pragma ComponentBehavior: Bound
import Quickshell
import Quickshell.Hyprland
import Quickshell.Wayland
import QtQuick
import qs.HyprChrome.Theme
// Primary application launcher — the one on SUPER_L (via HyprChromeShell).
//
// Migrated from widgets/launcher/ApplicationLauncher.qml. Two things changed in
// the move, both because HyprChromeShell now owns the state its surfaces share:
//
// * no scrim of its own. The shell raises the single ChromeBackdrop for any
// of its causes — expanded rail, polkit prompt, this — so opening the
// launcher over an already-expanded rail reuses the scrim that is there
// rather than laying a second dim on top of it.
// * `active` is read by the shell, which uses it to raise that scrim, to
// place this on the focused monitor, and to decide who gets the keyboard.
//
// The full-screen layer-shell adapter owns focus, DesktopEntries and execution;
// AppLauncherContent stays an Item so the whole visual state can be rendered
// headlessly (tests/AppLauncherHeadless.qml).
Scope {
id: root
property bool active: false
// Which output to appear on. Driven by the shell, which puts it on the
// focused monitor — a launcher belongs where the user is looking, which is
// not necessarily where the rail lives.
property var screen: null
function toggle() { root.active = !root.active; }
function close() { root.active = false; }
// Launcher alone, on SUPER CTRL 8. SUPER_L goes through the shell's
// `command` shortcut instead, which also expands the rail.
GlobalShortcut {
name: "launcher8"
description: "Toggle dense application command index"
onPressed: root.toggle()
}
PanelWindow {
id: win
screen: root.screen
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;
}
// Hyprland runs a Lua config, which rejects a bare `dispatch exit`.
readonly property var powerCommands: ({
logout: ["hyprctl", "dispatch", "hl.dsp.exit()"],
reboot: ["systemctl", "reboot"],
shutdown: ["systemctl", "poweroff"]
})
function power(action) {
root.active = false;
Quickshell.execDetached(win.powerCommands[action]);
}
onVisibleChanged: {
if (visible) {
content.clearSearch();
content.disarmPower();
selectedIndex = 0;
content.focusSearch();
}
}
AppModel {
id: model
search: content.query
}
// Click-off dismissal. The scrim itself belongs to the shell and takes
// no input (its mask is empty), so the catcher lives here: a
// transparent full-surface MouseArea UNDER the content, which is what
// keeps clicks on the launcher itself from closing it.
MouseArea {
anchors.fill: parent
onClicked: root.close()
}
AppLauncherContent {
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
sortMode: model.sortMode
onSelectionRequested: index => win.selectedIndex = win.clampSelection(index)
onMoveRequested: delta => win.move(delta)
onLaunchRequested: index => win.launch(index)
onDismissRequested: root.close()
onSortToggleRequested: {
model.toggleSort();
win.selectedIndex = 0;
}
onPowerRequested: action => win.power(action)
}
}
}