working ish
This commit is contained in:
1 parent
ba85d9658d
commit
7d58533539
14 files changed
+367
-130
No files matched your search
@@ -0,0 +1,9 @@
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
|
||||
JsonObject {
|
||||
property string name
|
||||
property string image
|
||||
property bool isIcon: false
|
||||
property list<string> exec
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import QtQuick.Layouts
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
required property var theme
|
||||
required property App app
|
||||
required property bool selected
|
||||
|
||||
signal activated()
|
||||
|
||||
width: theme.cardWidth
|
||||
height: theme.cardHeight
|
||||
radius: theme.cornerRadius
|
||||
color: theme.cardBg
|
||||
border.width: selected ? 3 : 1
|
||||
border.color: selected ? theme.selectedBorder : theme.cardBorder
|
||||
clip: true
|
||||
|
||||
ColumnLayout {
|
||||
spacing: 10
|
||||
width: root.theme.cardWidth
|
||||
height: root.theme.cardHeight
|
||||
anchors.fill: parent
|
||||
anchors.margins: root.theme.cardPadding
|
||||
Image {
|
||||
fillMode: Image.PreserveAspectFit
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
source: root.app.isIcon ? Quickshell.iconPath(root.app.image) : root.app.image
|
||||
}
|
||||
Text {
|
||||
id: label
|
||||
elide: Text.ElideRight
|
||||
color: root.theme.textColor
|
||||
text: root.app.name
|
||||
font.pixelSize: root.theme.fontSize
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.activated()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
pragma Singleton
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
|
||||
QtObject {
|
||||
readonly property string appConfigPath: Quickshell.env("SKYG_APP_CAROUSEL")
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
|
||||
PanelWindow {
|
||||
id: root
|
||||
|
||||
required property bool shellOpen
|
||||
required property list<App> apps
|
||||
|
||||
signal requestClose()
|
||||
|
||||
visible: root.shellOpen
|
||||
|
||||
color: "transparent"
|
||||
|
||||
WlrLayershell.namespace: "quickshell:launcher"
|
||||
WlrLayershell.layer: WlrLayer.Overlay
|
||||
WlrLayershell.exclusiveZone: -1
|
||||
WlrLayershell.keyboardFocus: root.visible ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
right: true
|
||||
bottom: true
|
||||
}
|
||||
|
||||
property Theme theme: Theme {}
|
||||
|
||||
property int selectedIndex: 0
|
||||
|
||||
readonly property int centerIndex: root.selectedIndex
|
||||
|
||||
function clampSelection() {
|
||||
if (root.apps.length === 0) return;
|
||||
if (root.selectedIndex >= root.apps.length) root.selectedIndex = root.apps.length - 1;
|
||||
if (root.selectedIndex < 0) root.selectedIndex = 0;
|
||||
}
|
||||
|
||||
function moveSelection(delta) {
|
||||
if (root.apps.length === 0) return;
|
||||
root.selectedIndex = (root.selectedIndex + delta + root.apps.length) % root.apps.length;
|
||||
}
|
||||
|
||||
function activateSelection() {
|
||||
const app = root.apps[root.selectedIndex];
|
||||
if (!app) { root.requestClose(); return; }
|
||||
Quickshell.execDetached(app.exec);
|
||||
root.requestClose();
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (root.visible) {
|
||||
root.selectedIndex = 0;
|
||||
Qt.callLater(() => focusScope.forceActiveFocus());
|
||||
}
|
||||
}
|
||||
|
||||
HyprlandFocusGrab {
|
||||
windows: [root]
|
||||
active: root.visible
|
||||
onCleared: {
|
||||
if (root.visible) root.requestClose();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "#cc0b0e14"
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: root.requestClose()
|
||||
}
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: focusScope
|
||||
anchors.fill: parent
|
||||
focus: root.visible
|
||||
|
||||
Keys.onPressed: event => {
|
||||
switch (event.key) {
|
||||
case Qt.Key_Left:
|
||||
root.moveSelection(-1);
|
||||
break;
|
||||
case Qt.Key_Right:
|
||||
root.moveSelection(1);
|
||||
break;
|
||||
case Qt.Key_Return:
|
||||
case Qt.Key_Enter:
|
||||
root.activateSelection();
|
||||
break;
|
||||
case Qt.Key_Escape:
|
||||
root.requestClose();
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
WheelHandler {
|
||||
id: swipeHandler
|
||||
target: focusScope
|
||||
property real accX: 0
|
||||
|
||||
function step(delta) {
|
||||
root.moveSelection(delta);
|
||||
swipeHandler.accX = 0;
|
||||
}
|
||||
|
||||
onWheel: event => {
|
||||
const px = event.pixelDelta;
|
||||
const ang = event.angleDelta;
|
||||
const dx = px.x !== 0 ? px.x : ang.x;
|
||||
swipeHandler.accX += dx;
|
||||
if (swipeHandler.accX <= -root.theme.swipeThreshold) swipeHandler.step(1);
|
||||
else if (swipeHandler.accX >= root.theme.swipeThreshold) swipeHandler.step(-1);
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
|
||||
Repeater {
|
||||
model: root.apps
|
||||
|
||||
AppButton {
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
theme: root.theme
|
||||
app: modelData
|
||||
selected: index === root.selectedIndex
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.horizontalCenterOffset: (index - root.centerIndex) * root.theme.carouselStepX
|
||||
opacity: 1 - Math.min(Math.abs(index - root.centerIndex) * root.theme.carouselFadeStep, root.theme.carouselMaxFade)
|
||||
scale: 1 - Math.min(Math.abs(index - root.centerIndex) * root.theme.carouselScaleStep, root.theme.carouselMaxScaleReduction)
|
||||
|
||||
Behavior on anchors.horizontalCenterOffset {
|
||||
NumberAnimation { duration: root.theme.carouselDuration; easing.type: Easing.OutCubic }
|
||||
}
|
||||
Behavior on opacity {
|
||||
NumberAnimation { duration: root.theme.carouselDuration }
|
||||
}
|
||||
Behavior on scale {
|
||||
NumberAnimation { duration: root.theme.carouselDuration }
|
||||
}
|
||||
|
||||
onActivated: {
|
||||
root.selectedIndex = index;
|
||||
root.activateSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
readonly property color cardBg: "#332a2e3a"
|
||||
readonly property color cardBorder: "#40ffffff"
|
||||
readonly property color selectedBorder: "#7aa2f7"
|
||||
readonly property color textColor: "#ffffff"
|
||||
readonly property color labelBg: "#99000000"
|
||||
readonly property real cornerRadius: 10
|
||||
readonly property real cardWidth: 240
|
||||
readonly property real cardHeight: 240
|
||||
readonly property real cardPadding: 10
|
||||
readonly property real cardSpacing: 40
|
||||
readonly property real fontSize: 24
|
||||
|
||||
// Carousel layout: fixed step distance between slots, and per-step
|
||||
// falloff for opacity/scale as items recede from the centered (selected)
|
||||
// slot.
|
||||
readonly property real carouselStepX: cardWidth + cardSpacing
|
||||
readonly property real carouselFadeStep: 0.35
|
||||
readonly property real carouselMaxFade: 0.85
|
||||
readonly property real carouselScaleStep: 0.08
|
||||
readonly property real carouselMaxScaleReduction: 0.3
|
||||
readonly property int carouselDuration: 220
|
||||
|
||||
// A two-finger swipe must cross this many pixels (or angleDelta units)
|
||||
// before the selection steps once.
|
||||
readonly property int swipeThreshold: 120
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
singleton Config 1.0 Config.qml
|
||||
App 1.0 App.qml
|
||||
AppButton 1.0 AppButton.qml
|
||||
LauncherWindow 1.0 LauncherWindow.qml
|
||||
Theme 1.0 Theme.qml
|
||||
@@ -0,0 +1,41 @@
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
|
||||
ShellRoot {
|
||||
id: shell
|
||||
|
||||
property bool launcherOpen: true
|
||||
property var appConfig: []
|
||||
|
||||
FileView {
|
||||
id: configFile
|
||||
path: Config.appConfigPath
|
||||
watchChanges: true
|
||||
onFileChanged: reload()
|
||||
onLoaded: {
|
||||
shell.appConfig = JSON.parse(configFile.text());
|
||||
console.log("here", configFile.__data);
|
||||
}
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "launcher"
|
||||
|
||||
function toggle(): void {
|
||||
shell.launcherOpen = !shell.launcherOpen;
|
||||
}
|
||||
function open(): void {
|
||||
shell.launcherOpen = true;
|
||||
}
|
||||
function close(): void {
|
||||
shell.launcherOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
LauncherWindow {
|
||||
shellOpen: shell.launcherOpen
|
||||
onRequestClose: shell.launcherOpen = false
|
||||
apps: shell.appConfig
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user