fix: changesMade bool now binding for robustness
C++ / fmt (pull_request) Successful in 5s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 9s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 9s
Python / static (pull_request) Successful in 35s
Rust / build (pull_request) Successful in 48s
Python / verify (pull_request) Successful in 1m39s
Rust / fmt (pull_request) Successful in 27s
Rust / clippy (pull_request) Successful in 48s
C++ / fmt (pull_request) Successful in 5s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 9s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 9s
Python / static (pull_request) Successful in 35s
Rust / build (pull_request) Successful in 48s
Python / verify (pull_request) Successful in 1m39s
Rust / fmt (pull_request) Successful in 27s
Rust / clippy (pull_request) Successful in 48s
This commit is contained in:
@@ -16,8 +16,20 @@ Item {
|
|||||||
readonly property var currentScreen: screens.length > selectedScreenIndex ? screens[selectedScreenIndex] : null
|
readonly property var currentScreen: screens.length > selectedScreenIndex ? screens[selectedScreenIndex] : null
|
||||||
readonly property real maxZoom: 5.0
|
readonly property real maxZoom: 5.0
|
||||||
|
|
||||||
|
readonly property bool changesMade: {
|
||||||
|
cropRevision;
|
||||||
|
|
||||||
|
const r = cropRectLoader.item;
|
||||||
|
if (!r || !currentScreen || scaledImg.status !== Image.Ready)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const t = r.savedTarget();
|
||||||
|
|
||||||
|
return Math.abs(r.x - t.x) > 0.5 || Math.abs(r.y - t.y) > 0.5 || Math.abs(r.zoom - t.zoom) > 0.001;
|
||||||
|
}
|
||||||
|
|
||||||
|
property int cropRevision: 0
|
||||||
property int buttonRowHeight: Tokens.padding.large * 3
|
property int buttonRowHeight: Tokens.padding.large * 3
|
||||||
property bool changesMade: false
|
|
||||||
property var screens: []
|
property var screens: []
|
||||||
property int selectedScreenIndex: 0
|
property int selectedScreenIndex: 0
|
||||||
property bool shouldBeActive: true
|
property bool shouldBeActive: true
|
||||||
@@ -42,6 +54,7 @@ Item {
|
|||||||
const cropHeightPercent = cropRect.height / cropRect.imageH;
|
const cropHeightPercent = cropRect.height / cropRect.imageH;
|
||||||
|
|
||||||
Wallpapers.setCrop(currentScreen.name, Qt.rect(cropXPercent, cropYPercent, cropWidthPercent, cropHeightPercent), cropRect.zoom);
|
Wallpapers.setCrop(currentScreen.name, Qt.rect(cropXPercent, cropYPercent, cropWidthPercent, cropHeightPercent), cropRect.zoom);
|
||||||
|
cropRevision++;
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshScreens(): void {
|
function refreshScreens(): void {
|
||||||
@@ -161,8 +174,6 @@ Item {
|
|||||||
onInteraction: value => {
|
onInteraction: value => {
|
||||||
wrapper.zoomClipRect(wrapper.zoomFromSlider(value));
|
wrapper.zoomClipRect(wrapper.zoomFromSlider(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
onPosChanged: wrapper.changesMade = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonRow {
|
ButtonRow {
|
||||||
@@ -181,7 +192,6 @@ Item {
|
|||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
wrapper.syncCropToScreen();
|
wrapper.syncCropToScreen();
|
||||||
wrapper.changesMade = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +208,6 @@ Item {
|
|||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
wrapper.applyCrop();
|
wrapper.applyCrop();
|
||||||
wrapper.changesMade = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -318,19 +327,33 @@ Item {
|
|||||||
y = Math.max(imageY, Math.min(y, imageY + imageH - height));
|
y = Math.max(imageY, Math.min(y, imageY + imageH - height));
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreFromData() {
|
// Where the rect should be according to saved data (same rules as a restore).
|
||||||
let data = Wallpapers.getCrop(wrapper.currentScreen.name);
|
function savedTarget() {
|
||||||
|
const data = Wallpapers.getCrop(wrapper.currentScreen.name);
|
||||||
|
const hasCrop = data && (Math.abs(data.x) > 0.001 || Math.abs(data.y) > 0.001 || Math.abs(data.width - 1.0) > 0.001 || Math.abs(data.height - 1.0) > 0.001);
|
||||||
|
|
||||||
if (data && (Math.abs(data.x) > 0.001 || Math.abs(data.y) > 0.001 || Math.abs(data.width - 1.0) > 0.001 || Math.abs(data.height - 1.0) > 0.001)) {
|
const z = hasCrop && data.zoom > 0 ? data.zoom : 1.0;
|
||||||
zoom = data.zoom > 0 ? data.zoom : 1.0;
|
const w = Math.round(baseWidth / z);
|
||||||
x = Math.round(imageX + (data.x * imageW));
|
const h = Math.round(baseHeight / z);
|
||||||
y = Math.round(imageY + (data.y * imageH));
|
|
||||||
|
|
||||||
clampToBounds();
|
let tx = hasCrop ? Math.round(imageX + data.x * imageW) : Math.round(imageX + (imageW - w) / 2);
|
||||||
} else {
|
let ty = hasCrop ? Math.round(imageY + data.y * imageH) : Math.round(imageY + (imageH - h) / 2);
|
||||||
zoom = 1.0;
|
|
||||||
centerInImage();
|
tx = Math.max(imageX, Math.min(tx, imageX + imageW - w));
|
||||||
|
ty = Math.max(imageY, Math.min(ty, imageY + imageH - h));
|
||||||
|
|
||||||
|
return {
|
||||||
|
x: tx,
|
||||||
|
y: ty,
|
||||||
|
zoom: z
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function restoreFromData() {
|
||||||
|
const t = savedTarget();
|
||||||
|
zoom = t.zoom;
|
||||||
|
x = t.x;
|
||||||
|
y = t.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
height: Math.round(baseHeight / zoom)
|
height: Math.round(baseHeight / zoom)
|
||||||
@@ -424,7 +447,6 @@ Item {
|
|||||||
onPositionChanged: mouse => {
|
onPositionChanged: mouse => {
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
updateCrop(mouse.x, mouse.y);
|
updateCrop(mouse.x, mouse.y);
|
||||||
wrapper.changesMade = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onPressed: mouse => {
|
onPressed: mouse => {
|
||||||
|
|||||||
Reference in New Issue
Block a user