Skip to content

Commit

Permalink
fix: navigation not update while image rotate
Browse files Browse the repository at this point in the history
fix navigation not update while image rotate.

Log: fix navigation not update while image rotate.
Influence: Animation
  • Loading branch information
rb-union committed Aug 12, 2024
1 parent 4132ce2 commit 9ae9244
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
43 changes: 35 additions & 8 deletions src/qml/NavigationWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,49 @@ Item {
Image {
id: currentImage

function updateMask() {
if (Image.Ready === currentImage.status) {
imgLeft = (currentImage.width - currentImage.paintedWidth) / 2;
imgTop = (currentImage.height - currentImage.paintedHeight) / 2;
imgRight = imgLeft + currentImage.paintedWidth;
imgBottom = imgTop + currentImage.paintedHeight;
refreshNaviMaskImpl();
}
}

function updateSource() {
source = "image://ImageLoad/" + IV.GControl.currentSource + "#frame_" + IV.GControl.currentFrameIndex;
}

anchors.fill: parent
asynchronous: true
cache: false
fillMode: Image.PreserveAspectFit
source: "image://ImageLoad/" + IV.GControl.currentSource + "#frame_" + IV.GControl.currentFrameIndex

// QML6 Image Ready 时 paintedGeometry 不一定更新,调整 onStatusChanged 为 onPaintedGeometryChanged
onPaintedGeometryChanged: {
if (Image.Ready === status) {
imgLeft = (currentImage.width - currentImage.paintedWidth) / 2;
imgTop = (currentImage.height - currentImage.paintedHeight) / 2;
imgRight = imgLeft + currentImage.paintedWidth;
imgBottom = imgTop + currentImage.paintedHeight;
refreshNaviMaskImpl();
}
onPaintedGeometryChanged: updateMask()
onSourceChanged: updateMask()
}

// 旋转图片触发更新导航窗口,重设图片后绑定会失效,因此手动触发图片源更新
Connections {
function onCurrentFrameIndexChanged() {
currentImage.updateSource();
}

function onCurrentRotationChanged() {
var temp = currentImage.source;
currentImage.source = "";
currentImage.source = temp;
currentImage.updateMask();
}

function onCurrentSourceChanged() {
currentImage.updateSource();
}

target: IV.GControl
}
}

Expand Down
1 change: 1 addition & 0 deletions src/src/filecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ QString FileControl::parseCommandlineGetPath()
*/
void FileControl::rotateImageFile(const QString &path, int angle)
{
// TODO: 逻辑有问题,调整缓存文件而不是对原文件处理
angle = angle % 360;
if (0 != angle) {
// 20211019修改:特殊位置不执行写入操作
Expand Down

0 comments on commit 9ae9244

Please sign in to comment.