diff --git a/qmlUiKirigami/ImageViewer.qml b/qmlUiKirigami/ImageViewer.qml --- a/qmlUiKirigami/ImageViewer.qml +++ b/qmlUiKirigami/ImageViewer.qml @@ -81,15 +81,15 @@ text: i18n("Rotate left") tooltip: i18n("Rotate the image to the left") onTriggered: { - listView.currentItem.image.rotation -= 90 + imageDoc.rotate(270) } }, Kirigami.Action { iconName: "image-rotate-right-symbolic" text: i18n("Rotate right") tooltip: i18n("Rotate the image to the right") onTriggered: { - listView.currentItem.image.rotation += 90 + imageDoc.rotate(90) } } ] diff --git a/src/imagedocument.h b/src/imagedocument.h --- a/src/imagedocument.h +++ b/src/imagedocument.h @@ -36,6 +36,8 @@ QImage visualImage(); + Q_INVOKABLE void rotate( int angle); + signals: void pathChanged(const QString &url); void visualImageChanged(); diff --git a/src/imagedocument.cpp b/src/imagedocument.cpp --- a/src/imagedocument.cpp +++ b/src/imagedocument.cpp @@ -18,7 +18,7 @@ */ #include "imagedocument.h" -#include +#include #include ImageDocument::ImageDocument() @@ -55,4 +55,12 @@ return *m_image; } +void ImageDocument::rotate(int angle) +{ + QMatrix matrix; + matrix.rotate( angle); + *m_image = m_image->transformed( matrix); + emit visualImageChanged(); +} + #include "moc_imagedocument.cpp"