diff options
| -rw-r--r-- | modules/launcher/ContentList.qml | 35 | ||||
| -rw-r--r-- | services/Wallpapers.qml | 10 | ||||
| -rw-r--r-- | utils/Paths.qml | 8 |
3 files changed, 37 insertions, 16 deletions
diff --git a/modules/launcher/ContentList.qml b/modules/launcher/ContentList.qml index 93bb913..9c10077 100644 --- a/modules/launcher/ContentList.qml +++ b/modules/launcher/ContentList.qml @@ -3,6 +3,7 @@ pragma ComponentBehavior: Bound import "root:/widgets" import "root:/services" import "root:/config" +import "root:/utils" import Quickshell import QtQuick import QtQuick.Controls @@ -45,7 +46,7 @@ Item { PropertyChanges { root.currentList: wallpaperList.item - root.implicitWidth: Math.max(Config.launcher.sizes.itemWidth, wallpaperList.implicitWidth) + root.implicitWidth: Math.max(Config.launcher.sizes.itemWidth * 1.2, wallpaperList.implicitWidth) root.implicitHeight: Config.launcher.sizes.wallpaperHeight wallpaperList.active: true } @@ -107,39 +108,41 @@ Item { } } - Item { + Row { id: empty opacity: root.currentList?.count === 0 ? 1 : 0 scale: root.currentList?.count === 0 ? 1 : 0.5 - implicitWidth: icon.width + text.width + Appearance.spacing.small - implicitHeight: icon.height + spacing: Appearance.spacing.normal + padding: Appearance.padding.large anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter MaterialIcon { - id: icon - - text: "manage_search" + text: root.state === "wallpapers" ? "wallpaper_slideshow" : "manage_search" color: Colours.palette.m3onSurfaceVariant font.pointSize: Appearance.font.size.extraLarge anchors.verticalCenter: parent.verticalCenter } - StyledText { - id: text - - anchors.left: icon.right - anchors.leftMargin: Appearance.spacing.small + Column { anchors.verticalCenter: parent.verticalCenter - text: qsTr("No results") - color: Colours.palette.m3onSurfaceVariant - font.pointSize: Appearance.font.size.larger - font.weight: 500 + StyledText { + text: root.state === "wallpapers" ? qsTr("No wallpapers found") : qsTr("No results") + color: Colours.palette.m3onSurfaceVariant + font.pointSize: Appearance.font.size.larger + font.weight: 500 + } + + StyledText { + text: root.state === "wallpapers" && Wallpapers.list.length === 0 ? qsTr("Try putting some wallpapers in %1").arg(Paths.shortenHome(Config.paths.wallpaperDir)) : qsTr("Try searching for something else") + color: Colours.palette.m3onSurfaceVariant + font.pointSize: Appearance.font.size.normal + } } Behavior on opacity { diff --git a/services/Wallpapers.qml b/services/Wallpapers.qml index 1470648..15424b7 100644 --- a/services/Wallpapers.qml +++ b/services/Wallpapers.qml @@ -92,6 +92,8 @@ Singleton { } Process { + id: getWallsProc + running: true command: ["find", Config.paths.wallpaperDir, "-type", "d", "-path", '*/.*', "-prune", "-o", "-not", "-name", '.*', "-type", "f", "-print"] stdout: StdioCollector { @@ -99,6 +101,14 @@ Singleton { } } + Connections { + target: Config.paths + + function onWallpaperDirChanged(): void { + getWallsProc.running = true; + } + } + Variants { id: wallpapers diff --git a/utils/Paths.qml b/utils/Paths.qml index cc8c712..ac95e80 100644 --- a/utils/Paths.qml +++ b/utils/Paths.qml @@ -16,6 +16,14 @@ Singleton { readonly property url imagecache: `${cache}/imagecache` + function expandTilde(path: string): string { + return strip(path.replace("~", root.home.toString())); + } + + function shortenHome(path: string): string { + return path.replace(strip(root.home.toString()), "~"); + } + function strip(path: url): string { return path.toString().replace("file://", ""); } |