launcher: better empty text

Also reload wallpapers when path changes
This commit is contained in:
2 * r + 2 * t 2025-06-19 20:18:04 +10:00
parent 65b4b1a050
commit e4d2226dd0
3 changed files with 37 additions and 16 deletions

View file

@ -3,6 +3,7 @@ pragma ComponentBehavior: Bound
import "root:/widgets" import "root:/widgets"
import "root:/services" import "root:/services"
import "root:/config" import "root:/config"
import "root:/utils"
import Quickshell import Quickshell
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
@ -45,7 +46,7 @@ Item {
PropertyChanges { PropertyChanges {
root.currentList: wallpaperList.item 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 root.implicitHeight: Config.launcher.sizes.wallpaperHeight
wallpaperList.active: true wallpaperList.active: true
} }
@ -107,41 +108,43 @@ Item {
} }
} }
Item { Row {
id: empty id: empty
opacity: root.currentList?.count === 0 ? 1 : 0 opacity: root.currentList?.count === 0 ? 1 : 0
scale: root.currentList?.count === 0 ? 1 : 0.5 scale: root.currentList?.count === 0 ? 1 : 0.5
implicitWidth: icon.width + text.width + Appearance.spacing.small spacing: Appearance.spacing.normal
implicitHeight: icon.height padding: Appearance.padding.large
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
MaterialIcon { MaterialIcon {
id: icon text: root.state === "wallpapers" ? "wallpaper_slideshow" : "manage_search"
text: "manage_search"
color: Colours.palette.m3onSurfaceVariant color: Colours.palette.m3onSurfaceVariant
font.pointSize: Appearance.font.size.extraLarge font.pointSize: Appearance.font.size.extraLarge
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
StyledText { Column {
id: text
anchors.left: icon.right
anchors.leftMargin: Appearance.spacing.small
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
text: qsTr("No results") StyledText {
text: root.state === "wallpapers" ? qsTr("No wallpapers found") : qsTr("No results")
color: Colours.palette.m3onSurfaceVariant color: Colours.palette.m3onSurfaceVariant
font.pointSize: Appearance.font.size.larger font.pointSize: Appearance.font.size.larger
font.weight: 500 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 { Behavior on opacity {
NumberAnimation { NumberAnimation {
duration: Appearance.anim.durations.normal duration: Appearance.anim.durations.normal

View file

@ -92,6 +92,8 @@ Singleton {
} }
Process { Process {
id: getWallsProc
running: true running: true
command: ["find", Config.paths.wallpaperDir, "-type", "d", "-path", '*/.*', "-prune", "-o", "-not", "-name", '.*', "-type", "f", "-print"] command: ["find", Config.paths.wallpaperDir, "-type", "d", "-path", '*/.*', "-prune", "-o", "-not", "-name", '.*', "-type", "f", "-print"]
stdout: StdioCollector { stdout: StdioCollector {
@ -99,6 +101,14 @@ Singleton {
} }
} }
Connections {
target: Config.paths
function onWallpaperDirChanged(): void {
getWallsProc.running = true;
}
}
Variants { Variants {
id: wallpapers id: wallpapers

View file

@ -16,6 +16,14 @@ Singleton {
readonly property url imagecache: `${cache}/imagecache` 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 { function strip(path: url): string {
return path.toString().replace("file://", ""); return path.toString().replace("file://", "");
} }