From c5198abcf9f93b6a384e046e78fb248e3940b7ec Mon Sep 17 00:00:00 2001 From: lucy Date: Tue, 23 Dec 2025 14:10:41 +0100 Subject: [PATCH] add files beacuse i forgor --- modules/bar/Workspaces.qml | 4 +- modules/wallpaper/WallSwitcher.qml | 101 +++++++++++++++++++++++++++ modules/wallpaper/WallpaperStore.qml | 31 ++++++++ modules/wallpaper/qmldir | 3 + 4 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 modules/wallpaper/WallSwitcher.qml create mode 100644 modules/wallpaper/WallpaperStore.qml create mode 100644 modules/wallpaper/qmldir diff --git a/modules/bar/Workspaces.qml b/modules/bar/Workspaces.qml index df123dc..a408f74 100644 --- a/modules/bar/Workspaces.qml +++ b/modules/bar/Workspaces.qml @@ -14,8 +14,8 @@ Item { Repeater { id: workspaceRepeater Rectangle { - width: 18 - height: 18 + width: 14 + height: 14 radius: 10 //color: modelData.active ? myPallete.accent : myPallete.window color: modelData.active ? Colors.foreground : "transparent" diff --git a/modules/wallpaper/WallSwitcher.qml b/modules/wallpaper/WallSwitcher.qml new file mode 100644 index 0000000..0b414c0 --- /dev/null +++ b/modules/wallpaper/WallSwitcher.qml @@ -0,0 +1,101 @@ +import QtQuick +import Qt.labs.folderlistmodel 2.15 // <--- The magic file scanner! +import Quickshell +import Quickshell.Hyprland +import Quickshell.Io +import "." +import qs.modules.bar + +FloatingWindow { + id: root + title: "quickshell-WallSwitcher" + visible: false + implicitWidth: 840 + implicitHeight: 640 + + GlobalShortcut { + // This is the "Secret Password" Hyprland will use + name: "toggle-walls" + + onPressed: { + // Toggle visibility! + root.visible = !root.visible; + + console.log("Shortcut pressed! Switcher is now: " + (root.visible ? "Visible" : "Hidden")); + } + } + + // Make it float above everything else + Text { + id: titleText + text: "Wallpapers in " + WallpaperStore.wallDir + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + font.pixelSize: 20 + topPadding: 20 + bottomPadding: 10 + font.family: Appearance.font + color: Colors.foreground + } + + color: Colors.background // Dark background + + // 1. The File Scanner + FolderListModel { + id: folderModel + folder: "file:///home/lucy/.walls/" // <--- Your stash! + nameFilters: ["*.png", "*.jpg", "*.jpeg"] + showDirs: false + } + + // 2. The Grid Display + GridView { + anchors.top: titleText.bottom // Sit below the title! + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.margins: 20 + cellWidth: 200 + cellHeight: 100 + clip: true + + model: folderModel + + delegate: Item { + width: 200 + height: 100 + + Image { + width: 180 + height: 90 + anchors.centerIn: parent + // "fileUrl" is provided by FolderListModel + source: fileUrl + + // IMPORTANT: Downscale the image for the thumbnail! + // If you don't do this, loading 50 4K images will eat your RAM + // faster than Chrome eats memory! 🙀 + sourceSize.width: 140 + sourceSize.height: 90 + + fillMode: Image.PreserveAspectCrop + } + + MouseArea { + Process { + id: generateScheme + property string cleanPath: fileUrl.toString().replace("file://", "") + command: ["wallust", "run", cleanPath] + } + anchors.fill: parent + onClicked: { + let cleanPath = fileUrl.toString().replace("file://", ""); + // Update the Singleton! + WallpaperStore.currentWall = fileUrl.toString(); + generateScheme.startDetached(); + console.log(generateScheme.stdout); + } + } + } + } +} diff --git a/modules/wallpaper/WallpaperStore.qml b/modules/wallpaper/WallpaperStore.qml new file mode 100644 index 0000000..54483bf --- /dev/null +++ b/modules/wallpaper/WallpaperStore.qml @@ -0,0 +1,31 @@ +pragma Singleton +import QtQuick +import Quickshell.Io // <--- Import for FileView and JsonAdapter + +QtObject { + id: store + + // 1. The File Manager + property string wallDir: "~/.walls/" + property var settings: FileView { + path: "/home/lucy/.cache/quickshell_settings.json" + + // Auto-save when properties change + onAdapterUpdated: writeAdapter() + + // Auto-load when the file changes on disk + watchChanges: true + onFileChanged: reload() + + // 2. The Magic Adapter + JsonAdapter { + id: adapter + // This property corresponds to a key in your JSON file! + property string lastWallpaper: "/home/lucy/.walls/frieren_river.jpg" + } + } + + // 3. Create a helper property for the rest of your app to use + // This keeps the "WallpaperStore.currentWall" name working! + property alias currentWall: adapter.lastWallpaper +} diff --git a/modules/wallpaper/qmldir b/modules/wallpaper/qmldir new file mode 100644 index 0000000..4d71e10 --- /dev/null +++ b/modules/wallpaper/qmldir @@ -0,0 +1,3 @@ +singleton WallpaperStore 1.0 WallpaperStore.qml +Wallpaper 1.0 Wallpaper.qml +WallSwitcher 1.0 WallSwitcher.qml