feat: wallpaper and colour preview
This commit is contained in:
parent
9a813f827f
commit
97ea9d4992
4 changed files with 38 additions and 7 deletions
|
|
@ -42,7 +42,7 @@ Item {
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
opacity: 0
|
opacity: 0
|
||||||
scale: 0.8
|
scale: Wallpapers.showPreview ? 1 : 0.8
|
||||||
|
|
||||||
onStatusChanged: {
|
onStatusChanged: {
|
||||||
if (status === Image.Ready)
|
if (status === Image.Ready)
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,12 @@ PathView {
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: currentIndex = Wallpapers.list.findIndex(w => w.path === Wallpapers.current)
|
Component.onCompleted: currentIndex = Wallpapers.list.findIndex(w => w.path === Wallpapers.current)
|
||||||
|
Component.onDestruction: Wallpapers.stopPreview()
|
||||||
|
|
||||||
|
onCurrentItemChanged: {
|
||||||
|
if (currentItem)
|
||||||
|
Wallpapers.preview(currentItem.modelData.path);
|
||||||
|
}
|
||||||
|
|
||||||
implicitWidth: Math.min(LauncherConfig.maxWallpapers, count) * (LauncherConfig.sizes.wallpaperWidth * 0.8 + Appearance.padding.larger * 2)
|
implicitWidth: Math.min(LauncherConfig.maxWallpapers, count) * (LauncherConfig.sizes.wallpaperWidth * 0.8 + Appearance.padding.larger * 2)
|
||||||
pathItemCount: LauncherConfig.maxWallpapers
|
pathItemCount: LauncherConfig.maxWallpapers
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ Singleton {
|
||||||
return Qt.hsla(c.hslHue, c.hslSaturation, 0.2, 1);
|
return Qt.hsla(c.hslHue, c.hslSaturation, 0.2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function load(data: string, preview: bool): void {
|
function load(data: string, isPreview: bool): void {
|
||||||
const colours = preview ? preview : current;
|
const colours = isPreview ? preview : current;
|
||||||
for (const line of data.trim().split("\n")) {
|
for (const line of data.trim().split("\n")) {
|
||||||
let [name, colour] = line.split(" ");
|
let [name, colour] = line.split(" ");
|
||||||
name = name.trim();
|
name = name.trim();
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,13 @@ import Qt.labs.platform
|
||||||
Singleton {
|
Singleton {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property string currentPath: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/caelestia/wallpaper/last.txt`.slice(7)
|
readonly property string currentNamePath: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/caelestia/wallpaper/last.txt`.slice(7)
|
||||||
readonly property string path: `${StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]}/Wallpapers`.slice(7)
|
readonly property string path: `${StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]}/Wallpapers`.slice(7)
|
||||||
|
|
||||||
property list<Wallpaper> list
|
property list<Wallpaper> list
|
||||||
property bool showPreview: false
|
property bool showPreview: false
|
||||||
readonly property string current: showPreview ? preview : actualCurrent
|
readonly property string current: showPreview ? previewPath : actualCurrent
|
||||||
property string preview
|
property string previewPath
|
||||||
property string actualCurrent
|
property string actualCurrent
|
||||||
|
|
||||||
readonly property list<var> preppedWalls: list.map(w => ({
|
readonly property list<var> preppedWalls: list.map(w => ({
|
||||||
|
|
@ -33,19 +33,44 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setWallpaper(path: string): void {
|
function setWallpaper(path: string): void {
|
||||||
|
actualCurrent = path;
|
||||||
setWall.path = path;
|
setWall.path = path;
|
||||||
setWall.startDetached();
|
setWall.startDetached();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function preview(path: string): void {
|
||||||
|
previewPath = path;
|
||||||
|
showPreview = true;
|
||||||
|
getPreviewColoursProc.running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopPreview(): void {
|
||||||
|
showPreview = false;
|
||||||
|
Colours.showPreview = false;
|
||||||
|
}
|
||||||
|
|
||||||
reloadableId: "wallpapers"
|
reloadableId: "wallpapers"
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
path: root.currentPath
|
path: root.currentNamePath
|
||||||
watchChanges: true
|
watchChanges: true
|
||||||
onFileChanged: reload()
|
onFileChanged: reload()
|
||||||
onLoaded: root.actualCurrent = text().trim()
|
onLoaded: root.actualCurrent = text().trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: getPreviewColoursProc
|
||||||
|
|
||||||
|
command: ["caelestia", "scheme", "print", root.previewPath]
|
||||||
|
stdout: SplitParser {
|
||||||
|
splitMarker: ""
|
||||||
|
onRead: data => {
|
||||||
|
Colours.load(data, true);
|
||||||
|
Colours.showPreview = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: setWall
|
id: setWall
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue