filedialog: better icon filtering
Only thumbnail valid image types Also move wallpaper extensions into separate singleton in utils
This commit is contained in:
parent
f4e9136aee
commit
32ff695d9e
5 changed files with 17 additions and 6 deletions
|
|
@ -66,7 +66,7 @@ Item {
|
||||||
|
|
||||||
title: qsTr("Select a wallpaper")
|
title: qsTr("Select a wallpaper")
|
||||||
filterLabel: qsTr("Image files")
|
filterLabel: qsTr("Image files")
|
||||||
filters: Wallpapers.extensions
|
filters: Images.validImageExtensions
|
||||||
onAccepted: path => Wallpapers.setWallpaper(path)
|
onAccepted: path => Wallpapers.setWallpaper(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ Item {
|
||||||
readonly property FileDialog facePicker: FileDialog {
|
readonly property FileDialog facePicker: FileDialog {
|
||||||
title: qsTr("Select a profile picture")
|
title: qsTr("Select a profile picture")
|
||||||
filterLabel: qsTr("Image files")
|
filterLabel: qsTr("Image files")
|
||||||
filters: Wallpapers.extensions
|
filters: Images.validImageExtensions
|
||||||
onAccepted: path => {
|
onAccepted: path => {
|
||||||
Paths.copy(path, `${Paths.home}/.face`);
|
Paths.copy(path, `${Paths.home}/.face`);
|
||||||
Quickshell.execDetached(["notify-send", "-a", "caelestia-shell", "-u", "low", "-h", `STRING:image-path:${path}`, "Profile picture changed", `Profile picture changed to ${Paths.shortenHome(path)}`]);
|
Quickshell.execDetached(["notify-send", "-a", "caelestia-shell", "-u", "low", "-h", `STRING:image-path:${path}`, "Profile picture changed", `Profile picture changed to ${Paths.shortenHome(path)}`]);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ Searcher {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property string currentNamePath: Paths.strip(`${Paths.state}/wallpaper/path.txt`)
|
readonly property string currentNamePath: Paths.strip(`${Paths.state}/wallpaper/path.txt`)
|
||||||
readonly property list<string> extensions: ["jpg", "jpeg", "png", "webp", "tif", "tiff"]
|
|
||||||
|
|
||||||
property bool showPreview: false
|
property bool showPreview: false
|
||||||
readonly property string current: showPreview ? previewPath : actualCurrent
|
readonly property string current: showPreview ? previewPath : actualCurrent
|
||||||
|
|
@ -89,7 +88,7 @@ Searcher {
|
||||||
running: true
|
running: true
|
||||||
command: ["find", Paths.expandTilde(Config.paths.wallpaperDir), "-type", "d", "-path", '*/.*', "-prune", "-o", "-not", "-name", '.*', "-type", "f", "-print"]
|
command: ["find", Paths.expandTilde(Config.paths.wallpaperDir), "-type", "d", "-path", '*/.*', "-prune", "-o", "-not", "-name", '.*', "-type", "f", "-print"]
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: wallpapers.model = text.trim().split("\n").filter(w => root.extensions.includes(w.slice(w.lastIndexOf(".") + 1))).sort()
|
onStreamFinished: wallpapers.model = text.trim().split("\n").filter(w => Images.isValidImageByName(w)).sort()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +99,7 @@ Searcher {
|
||||||
command: ["inotifywait", "-r", "-e", "close_write,moved_to,create", "-m", Paths.expandTilde(Config.paths.wallpaperDir)]
|
command: ["inotifywait", "-r", "-e", "close_write,moved_to,create", "-m", Paths.expandTilde(Config.paths.wallpaperDir)]
|
||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
onRead: data => {
|
onRead: data => {
|
||||||
if (root.extensions.includes(data.slice(data.lastIndexOf(".") + 1)))
|
if (Images.isValidImageByName(data))
|
||||||
getWallsProc.running = true;
|
getWallsProc.running = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
utils/Images.qml
Normal file
12
utils/Images.qml
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import Quickshell
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
readonly property list<string> validImageTypes: ["jpeg", "png", "webp", "tiff", "svg"]
|
||||||
|
readonly property list<string> validImageExtensions: ["jpg", "jpeg", "png", "webp", "tif", "tiff", "svg"]
|
||||||
|
|
||||||
|
function isValidImageByName(name: string): bool {
|
||||||
|
return validImageTypes.some(t => name.endsWith(`.${t}`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -171,7 +171,7 @@ Item {
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: {
|
onStreamFinished: {
|
||||||
const mime = text.split(";")[0].replace("/", "-");
|
const mime = text.split(";")[0].replace("/", "-");
|
||||||
icon.source = mime.startsWith("image-") ? item.fileUrl : Quickshell.iconPath(mime, "image-missing");
|
icon.source = Images.validImageTypes.some(t => mime === `image-${t}`) ? item.fileUrl : Quickshell.iconPath(mime, "image-missing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue