This commit is contained in:
Zacharias-Brohn
2026-03-12 10:04:27 +01:00
parent 401ccef90c
commit 851b78f0ff
17 changed files with 1347 additions and 64 deletions
@@ -0,0 +1,150 @@
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Widgets
import Quickshell.Hyprland
import qs.Components
import qs.Config
import qs.Paths
Item {
id: root
anchors.fill: parent
z: 998
visible: false
property real menuX: 0
property real menuY: 0
MouseArea {
anchors.fill: parent
onClicked: root.close()
}
CustomClippingRect {
id: popupBackground
readonly property real padding: 4
x: root.menuX
y: root.menuY
color: DynamicColors.tPalette.m3surface
radius: Appearance.rounding.normal
implicitWidth: menuLayout.implicitWidth + padding * 2
implicitHeight: menuLayout.implicitHeight + padding * 2
Behavior on opacity { Anim {} }
opacity: root.visible ? 1 : 0
ColumnLayout {
id: menuLayout
anchors.fill: parent
anchors.margins: popupBackground.padding
spacing: 0
StateLayer {
Layout.fillWidth: true
contentItem: RowLayout {
spacing: 8
anchors.fill: parent
anchors.margins: 12
MaterialIcon { text: "terminal"; font.pointSize: 20 }
CustomText { text: "Open terminal"; Layout.fillWidth: true }
}
onClicked: {
Quickshell.execDetached([Config.general.apps.terminal, "--working-directory", FileUtils.trimFileProtocol(Paths.desktop)])
root.close()
}
}
CustomRect {
Layout.fillWidth: true
implicitHeight: 1
color: DynamicColors.palette.m3outlineVariant
Layout.topMargin: 4
Layout.bottomMargin: 4
}
StateLayer {
Layout.fillWidth: true
contentItem: RowLayout {
spacing: 8
anchors.fill: parent
anchors.margins: 12
MaterialIcon { text: "settings"; font.pointSize: 20 }
CustomText { text: "Sleex settings"; Layout.fillWidth: true }
}
onClicked: {
Quickshell.execDetached(["qs", "-p", "/usr/share/sleex/settings.qml"])
root.close()
}
}
CustomRect {
Layout.fillWidth: true
implicitHeight: 1
color: Appearance.m3colors.m3outlineVariant
Layout.topMargin: 4
Layout.bottomMargin: 4
}
StateLayer {
Layout.fillWidth: true
contentItem: RowLayout {
spacing: 8
anchors.fill: parent
anchors.margins: 12
MaterialIcon { text: "logout"; font.pointSize: 20 }
CustomText { text: "Logout"; Layout.fillWidth: true }
}
onClicked: {
Hyprland.dispatch("global quickshell:sessionOpen")
root.close()
}
}
CustomRect {
Layout.fillWidth: true
implicitHeight: 1
color: Appearance.m3colors.m3outlineVariant
Layout.topMargin: 4
Layout.bottomMargin: 4
}
StateLayer {
Layout.fillWidth: true
contentItem: RowLayout {
spacing: 8
anchors.fill: parent
anchors.margins: 12
MaterialIcon { text: Config.options.background.showDesktopIcons ? "visibility_off" : "visibility"; font.pointSize: 20 }
CustomText { text: Config.options.background.showDesktopIcons ? "Hide icons" : "Show icons"; Layout.fillWidth: true }
}
onClicked: {
Config.options.background.showDesktopIcons = !Config.options.background.showDesktopIcons
root.close()
}
}
}
}
function openAt(mouseX, mouseY, parentW, parentH) {
menuX = Math.min(mouseX, parentW - popupBackground.implicitWidth)
menuY = Math.min(mouseY, parentH - popupBackground.implicitHeight)
visible = true
}
function close() {
visible = false
}
}
@@ -0,0 +1,193 @@
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Widgets
import qs.Components
import qs.Config
Item {
id: contextMenu
anchors.fill: parent
z: 999
visible: false
property string targetFilePath: ""
property bool targetIsDir: false
property var targetAppEntry: null
property var targetPaths: []
signal openFileRequested(string path, bool isDir)
signal renameRequested(string path)
property real menuX: 0
property real menuY: 0
MouseArea {
anchors.fill: parent
onClicked: contextMenu.close()
}
CustomClippingRect {
id: popupBackground
readonly property real padding: 4
x: contextMenu.menuX
y: contextMenu.menuY
color: DynamicColors.tPalette.m3surface
radius: Appearance.rounding.normal
implicitWidth: menuLayout.implicitWidth + padding * 2
implicitHeight: menuLayout.implicitHeight + padding * 2
Behavior on opacity { Anim {} }
opacity: contextMenu.visible ? 1 : 0
ColumnLayout {
id: menuLayout
anchors.fill: parent
anchors.margins: popupBackground.padding
spacing: 0
StateLayer {
Layout.fillWidth: true
contentItem: RowLayout {
spacing: 8
anchors.fill: parent
anchors.margins: 12
MaterialIcon { text: "open_in_new"; font.pointSize: 20 }
CustomText { text: "Open"; Layout.fillWidth: true }
}
onClicked: {
for (let i = 0; i < contextMenu.targetPaths.length; i++) {
let p = contextMenu.targetPaths[i];
if (p === contextMenu.targetFilePath) {
if (p.endsWith(".desktop") && contextMenu.targetAppEntry) contextMenu.targetAppEntry.execute()
else contextMenu.openFileRequested(p, contextMenu.targetIsDir)
} else {
Quickshell.execDetached(["xdg-open", p])
}
}
contextMenu.close()
}
}
StateLayer {
Layout.fillWidth: true
contentItem: RowLayout {
spacing: 8
anchors.fill: parent
anchors.margins: 12
MaterialIcon { text: contextMenu.targetIsDir ? "terminal" : "apps"; font.pointSize: 20 }
CustomText { text: contextMenu.targetIsDir ? "Open in terminal" : "Open with..."; Layout.fillWidth: true }
}
onClicked: {
Quickshell.execDetached(["xdg-open", contextMenu.targetFilePath])
contextMenu.close()
}
}
CustomRect {
Layout.fillWidth: true
implicitHeight: 1
color: DynamicColors.palette.m3outlineVariant
Layout.topMargin: 4
Layout.bottomMargin: 4
}
StateLayer {
Layout.fillWidth: true
contentItem: RowLayout {
spacing: 8
anchors.fill: parent
anchors.margins: 12
MaterialIcon { text: "content_copy"; font.pointSize: 20 }
CustomText { text: "Copy path"; Layout.fillWidth: true }
}
onClicked: {
Quickshell.execDetached(["wl-copy", contextMenu.targetPaths.join("\n")])
contextMenu.close()
}
}
StateLayer {
Layout.fillWidth: true
visible: contextMenu.targetPaths.length === 1
contentItem: RowLayout {
spacing: 8
anchors.fill: parent
anchors.margins: 12
MaterialIcon { text: "edit"; font.pointSize: 20 }
CustomText { text: "Rename"; Layout.fillWidth: true }
}
onClicked: {
contextMenu.renameRequested(contextMenu.targetFilePath)
contextMenu.close()
}
}
Rectangle {
Layout.fillWidth: true
implicitHeight: 1
color: Appearance.m3colors.m3outlineVariant
Layout.topMargin: 4
Layout.bottomMargin: 4
}
StateLayer {
id: deleteButton
Layout.fillWidth: true
colBackgroundHover: Appearance.colors.colError
contentItem: RowLayout {
spacing: 8
anchors.fill: parent
anchors.margins: 12
MaterialIcon {
text: "delete";
font.pointSize: 20;
color: deleteButton.hovered ? Appearance.colors.colOnError : Appearance.colors.colError
}
CustomText {
text: "Move to trash";
Layout.fillWidth: true;
color: deleteButton.hovered ? Appearance.colors.colOnError : Appearance.colors.colError
}
}
onClicked: {
let cmd = ["gio", "trash"].concat(contextMenu.targetPaths)
Quickshell.execDetached(cmd)
contextMenu.close()
}
}
}
}
function openAt(mouseX, mouseY, path, isDir, appEnt, parentW, parentH, selectionArray) {
targetFilePath = path
targetIsDir = isDir
targetAppEntry = appEnt
targetPaths = (selectionArray && selectionArray.length > 0) ? selectionArray : [path]
menuX = Math.min(mouseX, parentW - popupBackground.implicitWidth)
menuY = Math.min(mouseY, parentH - popupBackground.implicitHeight)
visible = true
}
function close() {
visible = false
}
}
@@ -0,0 +1,273 @@
import QtQuick
import Quickshell
import Quickshell.Widgets
import qs.Config
import qs.Components
import qs.Helpers
Item {
id: delegateRoot
property var appEntry: fileName.endsWith(".desktop") ? DesktopEntries.byId(DesktopUtils.getAppId(fileName)) : null
property bool fileIsDir: model.isDir
property string fileName: model.fileName
property string filePath: model.filePath
property int gridX: model.gridX
property int gridY: model.gridY
property bool isSnapping: snapAnimX.running || snapAnimY.running
property string resolvedIcon: {
if (fileName.endsWith(".desktop")) {
if (appEntry && appEntry.icon && appEntry.icon !== "")
return appEntry.icon;
return AppSearch.guessIcon(DesktopUtils.getAppId(fileName));
} else if (DesktopUtils.getFileType(fileName, fileIsDir) === "image") {
return "file://" + filePath;
} else {
return DesktopUtils.getIconName(fileName, fileIsDir);
}
}
function compensateAndSnap(absVisX, absVisY) {
dragContainer.x = absVisX - delegateRoot.x;
dragContainer.y = absVisY - delegateRoot.y;
snapAnimX.start();
snapAnimY.start();
}
function getDragX() {
return dragContainer.x;
}
function getDragY() {
return dragContainer.y;
}
height: root.cellHeight
width: root.cellWidth
x: gridX * root.cellWidth
y: gridY * root.cellHeight
Behavior on x {
enabled: !mouseArea.drag.active && !isSnapping && !root.selectedIcons.includes(filePath)
Anim {
}
}
Behavior on y {
enabled: !mouseArea.drag.active && !isSnapping && !root.selectedIcons.includes(filePath)
Anim {
}
}
Item {
id: dragContainer
height: parent.height
width: parent.width
states: State {
when: mouseArea.drag.active
PropertyChanges {
opacity: 0.8
scale: 1.1
target: dragContainer
z: 100
}
}
transform: Translate {
x: (root.selectedIcons.includes(filePath) && root.dragLeader !== "" && root.dragLeader !== filePath) ? root.groupDragX : 0
y: (root.selectedIcons.includes(filePath) && root.dragLeader !== "" && root.dragLeader !== filePath) ? root.groupDragY : 0
}
transitions: Transition {
Anim {
}
}
onXChanged: {
if (mouseArea.drag.active) {
root.dragLeader = filePath;
root.groupDragX = x;
}
}
onYChanged: {
if (mouseArea.drag.active) {
root.dragLeader = filePath;
root.groupDragY = y;
}
}
PropertyAnimation {
id: snapAnimX
duration: 250
easing.type: Easing.OutCubic
property: "x"
target: dragContainer
to: 0
}
PropertyAnimation {
id: snapAnimY
duration: 250
easing.type: Easing.OutCubic
property: "y"
target: dragContainer
to: 0
}
Column {
anchors.centerIn: parent
spacing: 6
IconImage {
anchors.horizontalCenter: parent.horizontalCenter
implicitSize: 48
source: {
if (delegateRoot.resolvedIcon.startsWith("file://") || delegateRoot.resolvedIcon.startsWith("/")) {
return delegateRoot.resolvedIcon;
} else {
return Quickshell.iconPath(delegateRoot.resolvedIcon, fileIsDir ? "folder" : "text-x-generic");
}
}
}
Item {
height: 40
width: 88
CustomText {
anchors.fill: parent
color: "white"
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
maximumLineCount: 2
style: Text.Outline
styleColor: "black"
text: (appEntry && appEntry.name !== "") ? appEntry.name : fileName
visible: !renameLoader.active
wrapMode: Text.Wrap
}
Loader {
id: renameLoader
active: root.editingFilePath === filePath
anchors.centerIn: parent
height: 24
width: 110
sourceComponent: CustomTextInput {
anchors.fill: parent
anchors.margins: 2
color: "white"
horizontalAlignment: Text.AlignHCenter
text: fileName
wrapMode: Text.Wrap
Component.onCompleted: {
forceActiveFocus();
selectAll();
}
Keys.onPressed: function (event) {
if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
if (text.trim() !== "" && text !== fileName) {
let newName = text.trim();
let newPath = filePath.substring(0, filePath.lastIndexOf('/') + 1) + newName;
Quickshell.execDetached(["mv", filePath, newPath]);
}
root.editingFilePath = "";
event.accepted = true;
} else if (event.key === Qt.Key_Escape) {
root.editingFilePath = "";
event.accepted = true;
}
}
onActiveFocusChanged: {
if (!activeFocus && root.editingFilePath === filePath) {
root.editingFilePath = "";
}
}
}
}
}
}
CustomRect {
anchors.fill: parent
anchors.margins: 4
color: "white"
opacity: root.selectedIcons.includes(filePath) ? 0.2 : 0.0
radius: 8
Behavior on opacity {
Anim {
}
}
}
MouseArea {
id: mouseArea
acceptedButtons: Qt.LeftButton | Qt.RightButton
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
drag.target: dragContainer
hoverEnabled: true
onClicked: mouse => {
root.forceActiveFocus();
if (mouse.button === Qt.RightButton) {
if (!root.selectedIcons.includes(filePath)) {
root.selectedIcons = [filePath];
}
let pos = mapToItem(root, mouse.x, mouse.y);
root.contextMenu.openAt(pos.x, pos.y, filePath, fileIsDir, appEntry, root.width, root.height, root.selectedIcons);
} else {
root.selectedIcons = [filePath];
root.contextMenu.close();
}
}
onDoubleClicked: mouse => {
if (mouse.button === Qt.LeftButton) {
if (filePath.endsWith(".desktop") && appEntry)
appEntry.execute();
else
root.exec(filePath, fileIsDir);
}
}
onPressed: mouse => {
if (mouse.button === Qt.LeftButton && !root.selectedIcons.includes(filePath)) {
root.selectedIcons = [filePath];
}
}
onReleased: {
if (drag.active) {
let absoluteX = delegateRoot.x + dragContainer.x;
let absoluteY = delegateRoot.y + dragContainer.y;
let snapX = Math.max(0, Math.round(absoluteX / root.cellWidth));
let snapY = Math.max(0, Math.round(absoluteY / root.cellHeight));
root.performMassDrop(filePath, snapX, snapY);
}
}
CustomRect {
anchors.fill: parent
anchors.margins: 4
color: "white"
opacity: parent.containsMouse ? 0.1 : 0.0
radius: 8
Behavior on opacity {
Anim {
}
}
}
}
}
}
+162
View File
@@ -0,0 +1,162 @@
import QtQuick
import Quickshell
import qs.Modules
import qs.Helpers
import qs.Paths
import ZShell.Services
Item {
id: root
property int cellHeight: 110
property int cellWidth: 100
property var contextMenu: desktopMenu
property string dragLeader: ""
property string editingFilePath: ""
property real groupDragX: 0
property real groupDragY: 0
property var selectedIcons: []
property real startX: 0
property real startY: 0
function exec(filePath, isDir) {
const cmd = ["xdg-open", filePath];
Quickshell.execDetached(cmd);
}
function performMassDrop(leaderPath, targetX, targetY) {
let maxCol = Math.max(0, Math.floor(gridArea.width / cellWidth) - 1);
let maxRow = Math.max(0, Math.floor(gridArea.height / cellHeight) - 1);
let visuals = [];
for (let i = 0; i < gridArea.children.length; i++) {
let child = gridArea.children[i];
if (child.filePath && root.selectedIcons.includes(child.filePath)) {
let isLeader = (root.dragLeader === child.filePath);
let offsetX = isLeader ? child.getDragX() : root.groupDragX;
let offsetY = isLeader ? child.getDragY() : root.groupDragY;
visuals.push({
childRef: child,
absX: child.x + offsetX,
absY: child.y + offsetY
});
}
}
desktopModel.massMove(root.selectedIcons, leaderPath, targetX, targetY, maxCol, maxRow);
for (let i = 0; i < visuals.length; i++) {
visuals[i].childRef.compensateAndSnap(visuals[i].absX, visuals[i].absY);
}
root.dragLeader = "";
root.groupDragX = 0;
root.groupDragY = 0;
}
anchors.fill: parent
focus: true
Keys.onPressed: event => {
if (event.key === Qt.Key_F2 && selectedIcons.length > 0)
editingFilePath = selectedIcons[0];
}
DesktopModel {
id: desktopModel
Component.onCompleted: loadDirectory(FileUtils.trimFileProtocol(Paths.desktop))
}
Rectangle {
id: lasso
border.color: Appearance.colors.colPrimary
border.width: 1
color: DynamicColors.tPalette.m3primary
radius: Appearance.rounding.small
visible: false
z: 99
}
MouseArea {
acceptedButtons: Qt.LeftButton | Qt.RightButton
anchors.fill: parent
onPositionChanged: mouse => {
if (lasso.visible) {
lasso.x = Math.min(mouse.x, root.startX);
lasso.y = Math.min(mouse.y, root.startY);
lasso.width = Math.abs(mouse.x - root.startX);
lasso.height = Math.abs(mouse.y - root.startY);
let minCol = Math.floor((lasso.x - gridArea.x) / cellWidth);
let maxCol = Math.floor((lasso.x + lasso.width - gridArea.x) / cellWidth);
let minRow = Math.floor((lasso.y - gridArea.y) / cellHeight);
let maxRow = Math.floor((lasso.y + lasso.height - gridArea.y) / cellHeight);
let newSelection = [];
for (let i = 0; i < gridArea.children.length; i++) {
let child = gridArea.children[i];
if (child.filePath !== undefined && child.gridX >= minCol && child.gridX <= maxCol && child.gridY >= minRow && child.gridY <= maxRow) {
newSelection.push(child.filePath);
}
}
root.selectedIcons = newSelection;
}
}
onPressed: mouse => {
root.editingFilePath = "";
desktopMenu.close();
if (mouse.button === Qt.RightButton) {
root.selectedIcons = [];
bgContextMenu.openAt(mouse.x, mouse.y, root.width, root.height);
} else {
bgContextMenu.close();
root.selectedIcons = [];
root.startX = mouse.x;
root.startY = mouse.y;
lasso.x = mouse.x;
lasso.y = mouse.y;
lasso.width = 0;
lasso.height = 0;
lasso.visible = true;
}
}
onReleased: {
lasso.visible = false;
}
}
Item {
id: gridArea
anchors.fill: parent
anchors.margins: 20
anchors.topMargin: 40
visible: true
Repeater {
model: desktopModel
delegate: DesktopIconDelegate {
property int itemIndex: index
}
}
}
DesktopIconContextMenu {
id: desktopMenu
onOpenFileRequested: (path, isDir) => root.exec(path, isDir)
onRenameRequested: path => {
root.editingFilePath = path;
}
}
BackgroundContextMenu {
id: bgContextMenu
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ CustomRect {
MaterialIcon {
animate: true
color: Players.active?.isPlaying ? DynamicColors.palette.m3primary : DynamicColors.palette.m3onSurface
font.pointSize: Appearance.font.size.normal
font.pointSize: Appearance.font.size.larger
text: Players.active?.isPlaying ? "music_note" : "music_off"
}
+18 -62
View File
@@ -19,91 +19,47 @@ RowLayout {
property bool warning: percentage * 100 >= warningThreshold
property int warningThreshold: 80
clip: true
percentage: 0
Behavior on animatedPercentage {
Anim {
duration: Appearance.anim.durations.large
}
}
Component.onCompleted: animatedPercentage = percentage
onPercentageChanged: animatedPercentage = percentage
onPercentageChanged: {
const next = percentage;
// Canvas {
// id: gaugeCanvas
//
// anchors.centerIn: parent
// height: width
// width: Math.min(parent.width, parent.height)
//
// Component.onCompleted: requestPaint()
// onPaint: {
// const ctx = getContext("2d");
// ctx.reset();
// const cx = width / 2;
// const cy = (height / 2) + 1;
// const radius = (Math.min(width, height) - 12) / 2;
// const lineWidth = 3;
// ctx.beginPath();
// ctx.arc(cx, cy, radius, root.arcStartAngle, root.arcStartAngle + root.arcSweep);
// ctx.lineWidth = lineWidth;
// ctx.lineCap = "round";
// ctx.strokeStyle = DynamicColors.layer(DynamicColors.palette.m3surfaceContainerHigh, 2);
// ctx.stroke();
// if (root.animatedPercentage > 0) {
// ctx.beginPath();
// ctx.arc(cx, cy, radius, root.arcStartAngle, root.arcStartAngle + root.arcSweep * root.animatedPercentage);
// ctx.lineWidth = lineWidth;
// ctx.lineCap = "round";
// ctx.strokeStyle = root.accentColor;
// ctx.stroke();
// }
// }
//
// Connections {
// function onAnimatedPercentageChanged() {
// gaugeCanvas.requestPaint();
// }
//
// target: root
// }
//
// Connections {
// function onPaletteChanged() {
// gaugeCanvas.requestPaint();
// }
//
// target: DynamicColors
// }
// }
if (Math.abs(next - animatedPercentage) >= 0.05)
animatedPercentage = next;
}
MaterialIcon {
id: icon
color: DynamicColors.palette.m3onSurface
font.pointSize: 12
font.pointSize: Appearance.font.size.larger
text: root.icon
}
CustomClippingRect {
Layout.preferredHeight: root.height
Layout.preferredWidth: 5
Layout.preferredHeight: root.height - Appearance.padding.small
Layout.preferredWidth: 4
color: DynamicColors.layer(DynamicColors.palette.m3surfaceContainerHigh, 2)
radius: Appearance.rounding.full
CustomRect {
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
color: root.mainColor
implicitHeight: root.percentage * parent.height
radius: implicitHeight / 2
id: fill
Behavior on implicitHeight {
Anim {
}
anchors.fill: parent
antialiasing: false
color: root.mainColor
implicitHeight: Math.ceil(root.percentage * parent.height)
radius: Appearance.rounding.full
transform: Scale {
origin.y: fill.height
yScale: Math.max(0.001, root.animatedPercentage)
}
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ CustomRect {
spacing: Appearance.spacing.small
MaterialIcon {
font.pointSize: Appearance.font.size.normal
font.pointSize: Appearance.font.size.larger
text: "package_2"
}
+4
View File
@@ -2,6 +2,7 @@ import Quickshell
import QtQuick
import Quickshell.Wayland
import qs.Config
import qs.Modules.DesktopIcons
Loader {
active: Config.background.enabled
@@ -30,6 +31,9 @@ Loader {
WallBackground {
}
DesktopIcons {
}
}
}
}