better crop region handling, but coordinate math is wrong
This commit is contained in:
@@ -6,7 +6,21 @@ import Quickshell.Services.UPower
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
readonly property real batteryPercent: UPower.displayDevice.percentage
|
||||
readonly property list<UPowerDevice> devices: UPower.devices.values
|
||||
readonly property UPowerDevice displayDevice: UPower.displayDevice
|
||||
readonly property bool onBattery: UPower.onBattery
|
||||
// property bool toastShown
|
||||
//
|
||||
// Connections {
|
||||
// target: UPower
|
||||
//
|
||||
// function onPercentageChanged(): {
|
||||
// if (root.batteryPercent >= 0.2 && toastShown)
|
||||
// return;
|
||||
//
|
||||
// root.toastShown = true;
|
||||
// Toaster.toast(qsTr("Battery "))
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
import ZShell.Models
|
||||
import qs.Config
|
||||
import qs.Modules
|
||||
@@ -12,11 +14,17 @@ Searcher {
|
||||
id: root
|
||||
|
||||
property string actualCurrent: WallpaperPath.currentWallpaperPath
|
||||
property alias crops: adapter.monitorCrops
|
||||
readonly property string current: showPreview ? previewPath : actualCurrent
|
||||
property alias monitorCrops: monitorCrops
|
||||
property string previewPath
|
||||
property bool recentlyChanged
|
||||
property bool showPreview: false
|
||||
|
||||
function getCrop(screen: string): var {
|
||||
return root.crops[screen];
|
||||
}
|
||||
|
||||
function preview(path: string): void {
|
||||
previewPath = path;
|
||||
if (Config.general.color.schemeGeneration)
|
||||
@@ -24,9 +32,26 @@ Searcher {
|
||||
showPreview = true;
|
||||
}
|
||||
|
||||
function setCrop(screen: string, rect: rect, zoom: real): void {
|
||||
let updated = Object.assign({}, root.crops);
|
||||
|
||||
updated[screen] = {
|
||||
x: rect.x,
|
||||
y: rect.y,
|
||||
width: rect.width,
|
||||
height: rect.height,
|
||||
zoom: zoom
|
||||
};
|
||||
|
||||
root.crops = updated;
|
||||
monitorCrops.writeAdapter();
|
||||
monitorCrops.reload();
|
||||
}
|
||||
|
||||
function setWallpaper(path: string): void {
|
||||
actualCurrent = path;
|
||||
WallpaperPath.currentWallpaperPath = path;
|
||||
Quickshell.screens.forEach(n => setCrop(n.name, Qt.rect(0, 0, 0, 0), 1.0));
|
||||
Quickshell.execDetached(["zshell-cli", "wallpaper", "lockscreen", "--input-image", `${root.actualCurrent}`, "--output-path", `${Paths.state}/lockscreen_bg.png`, "--blur-amount", `${Config.lock.blurAmount}`]);
|
||||
if (Config.general.color.schemeGeneration)
|
||||
Quickshell.execDetached(["zshell-cli", "scheme", "generate", "--image-path", `${root.actualCurrent}`, "--scheme", `${Config.colors.schemeType}`, "--mode", `${Config.general.color.mode}`]);
|
||||
@@ -53,6 +78,22 @@ Searcher {
|
||||
target: "wallpaper"
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: monitorCrops
|
||||
|
||||
path: `${Paths.state}/wallpaper-crops.json`
|
||||
watchChanges: true
|
||||
|
||||
onAdapterUpdated: writeAdapter()
|
||||
onFileChanged: reload()
|
||||
|
||||
JsonAdapter {
|
||||
id: adapter
|
||||
|
||||
property var monitorCrops: ({})
|
||||
}
|
||||
}
|
||||
|
||||
FileSystemModel {
|
||||
id: wallpapers
|
||||
|
||||
|
||||
Reference in New Issue
Block a user