diff --git a/modules/ipc/Ipc.qml b/modules/ipc/Ipc.qml index 26f016a..8c2ddf8 100644 --- a/modules/ipc/Ipc.qml +++ b/modules/ipc/Ipc.qml @@ -20,9 +20,4 @@ Item { Settings.config.generateScheme = toggle; } } - Process { - id: wallustRunner - property string cmd: "matugen image " + Settings.config.currentWall + " -t scheme-fidelity" - command: ["sh", "-c", cmd] - } } diff --git a/modules/widgets/wallswitcher/WallSwitcher.qml b/modules/widgets/wallswitcher/WallSwitcher.qml new file mode 100644 index 0000000..15b4298 --- /dev/null +++ b/modules/widgets/wallswitcher/WallSwitcher.qml @@ -0,0 +1,82 @@ +pragma ComponentBehavior: Bound +import Quickshell +import qs.settings +import QtQuick +import Quickshell.Widgets +import qs.reusables +import Qt.labs.folderlistmodel 2.10 +import Quickshell.Io + +FloatingWindow { + id: wallswitcherWindow + implicitHeight: 1200 + implicitWidth: 1800 + title: "qs-wallswitcher" + color: "green" + WrapperItem { + id: innerWindowWrapper + anchors.centerIn: parent + anchors.fill: parent + margin: 20 + child: Rectangle { + id: innerWindow + anchors.fill: parent + anchors.centerIn: parent + implicitWidth: parent.implicitWidth + implicitHeight: parent.implicitHeight + GridView { + id: gridRoot + cellWidth: 140 + cellHeight: 100 + topMargin: innerWindowText.implicitHeight + innerWindowText.topPadding + anchors.fill: parent + anchors.horizontalCenter: parent.horizontalCenter + leftMargin: 20 + rightMargin: 20 + + FolderListModel { + id: folderModel + folder: Settings.config.wallDir + nameFilters: ["*.png", "*.jpg"] + } + + Component { + id: fileDelegate + Image { + required property string filePath + source: filePath + width: 120 + height: 80 + MouseArea { + id: wallpaperSetter + Process { + id: wallustRunner + property string cmd: "matugen image " + Settings.config.currentWall + " -t scheme-fidelity" + command: ["sh", "-c", cmd] + } + acceptedButtons: Qt.LeftButton + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onClicked: { + Settings.config.currentWall = parent.filePath; + wallustRunner.startDetached(); + } + } + } + } + + model: folderModel + delegate: fileDelegate + } + + radius: 24 + color: "black" + CustomText { + id: innerWindowText + topPadding: 10 + text: "Hello, world!" + anchors.horizontalCenter: parent.horizontalCenter + } + } + } +} diff --git a/settings/Settings.qml b/settings/Settings.qml index 99a0467..cd7808f 100644 --- a/settings/Settings.qml +++ b/settings/Settings.qml @@ -5,20 +5,20 @@ import Quickshell import Quickshell.Io Singleton { - id: settings + id: root property alias config: settingsAdapter + property alias currentWall: settingsAdapter.currentWall onConfigChanged: { console.log('config change detected, writing adapter'); settingsView.writeAdapter(); } + FileView { id: settingsView onAdapterUpdated: writeAdapter() - onFileChanged: reload() - path: "/home/lucy/.config/quickshell/settings/config.json" - watchChanges: true + watchChanges: false adapter: JsonAdapter { id: settingsAdapter @@ -28,7 +28,7 @@ Singleton { property var font: "Google Sans" property var fontSize: 14 property var rounding: 10 - property var wallDir: "/home/lucy/.walls" + property var wallDir: "file:///home/lucy/.walls/" property bool floating: true property int paddingTop: 10 property int paddingSides: 10 diff --git a/shell.qml b/shell.qml index 261ae8c..160a80a 100644 --- a/shell.qml +++ b/shell.qml @@ -5,6 +5,7 @@ import qs.modules.ipc import qs.modules.bar import qs.modules.overlays import qs.modules.notifications +import qs.modules.widgets.wallswitcher ShellRoot { id: root @@ -12,4 +13,5 @@ ShellRoot { Bar {} Notification {} Wallpaper {} + WallSwitcher {} }