launcher: better empty text
Also reload wallpapers when path changes
This commit is contained in:
parent
65b4b1a050
commit
e4d2226dd0
3 changed files with 37 additions and 16 deletions
|
|
@ -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,41 +108,43 @@ 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")
|
||||
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 {
|
||||
NumberAnimation {
|
||||
duration: Appearance.anim.durations.normal
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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://", "");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue