diff --git a/src/imageprovider.h b/qmlUiKirigami/EditorView.qml rename from src/imageprovider.h rename to qmlUiKirigami/EditorView.qml --- a/src/imageprovider.h +++ b/qmlUiKirigami/EditorView.qml @@ -17,17 +17,34 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef IMAGE_PROVIDER_H -#define IMAGE_PROVIDER_H +import QtQuick 2.7 +import QtQuick.Controls 2.1 as Controls +import org.kde.kirigami 2.0 as Kirigami +import org.kde.kquickcontrolsaddons 2.0 as KQA +import org.kde.koko 0.1 as Koko -#include - -class ImageProvider: public QQuickImageProvider -{ -public: - explicit ImageProvider(); +Kirigami.Page { + id: rootEditorView + title: i18n("Edit") + leftPadding: 0 + rightPadding: 0 - virtual QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize); -}; - -#endif + property string imagePath + + Koko.ImageDocument { + id: imageDoc + path: imagePath + } + + contentItem: Flickable { + width: rootEditorView.width + height: rootEditorView.height + KQA.QImageItem { + id: editImage + width: rootEditorView.width + height: rootEditorView.height + image: imageDoc.visualImage + } + } + +} diff --git a/qmlUiKirigami/ImageViewer.qml b/qmlUiKirigami/ImageViewer.qml --- a/qmlUiKirigami/ImageViewer.qml +++ b/qmlUiKirigami/ImageViewer.qml @@ -47,21 +47,12 @@ id: mimeDB } - Koko.ImageDocument { - id: imageDoc - path: listView.currentItem.currentImageSource - onResetHandle: { - brightnessSlider.value = 0.5 - listView.forceActiveFocus(); - } - } - Kirigami.ContextDrawer { id: contextDrawer title: i18n("Edit image") handleVisible: true } - + actions { left: Kirigami.Action { id: backAction @@ -81,67 +72,12 @@ } } } - contextualActions: [ - Kirigami.Action { - iconName: "image-rotate-left-symbolic" - text: i18n("Rotate left") - tooltip: i18n("Rotate the image to the left") - onTriggered: { - imageDoc.rotate(270) - } - }, - Kirigami.Action { - iconName: "image-rotate-right-symbolic" - text: i18n("Rotate right") - tooltip: i18n("Rotate the image to the right") - onTriggered: { - imageDoc.rotate(90) - } - } - ] - } - - ColumnLayout { - anchors.top: root.top - width: root.width - z: listView.z + 1 - - Controls.Slider { - id: brightnessSlider - property real previousValue: 0.5 - Layout.fillWidth: true - visible: applicationWindow().controlsVisible - from: 0 - to: 1.0 - value: 0.5 - stepSize: 0.1 - z: listView.z + 1 - snapMode: Controls.Slider.SnapAlways - hoverEnabled: true - Controls.ToolTip { - parent: brightnessSlider - visible: brightnessSlider.hovered - text: i18n("Brightness Controller") - } - onValueChanged: { - imageDoc.edited = true - } - } - - RowLayout { - Layout.fillWidth: true - visible: imageDoc.edited - Controls.Button { - Layout.fillWidth: true - text: i18n("Save") - onClicked: { - listView.currentItem.image.modifiedImage.grabToImage( function( result) { imageDoc.save( result.image)}) - } - } - Controls.Button { - Layout.fillWidth: true - text: i18n("Cancel") - onClicked: imageDoc.cancel() + right: Kirigami.Action { + id: editingAction + iconName: "edit-entry" + tooltip: i18n("Edit Image") + onTriggered: { + applicationWindow().pageStack.layers.push(editorComponent) } } } @@ -301,12 +237,10 @@ Image { id: image - property alias modifiedImage: brightnessContrast - property string imageObject: "image://imageprovider/"+ (model.imageurl).slice(7) width: flick.contentWidth height: flick.contentHeight fillMode: Image.PreserveAspectFit - source: imageObject + source: currentImageSource Timer { id: doubleClickTimer interval: 150 @@ -360,14 +294,6 @@ } } } - - Effects.GammaAdjust { - id: brightnessContrast - source: image - anchors.fill: image - gamma: brightnessSlider.value + 0.5 - } - } } } @@ -393,4 +319,14 @@ } } } + + Component { + id: editorComponent + EditorView { + width: root.imageWidth + height: root.imageHeight + imagePath: listView.currentItem.currentImageSource + } + } + } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -66,14 +66,12 @@ types.cpp roles.cpp imagedocument.cpp - imageprovider.cpp ) add_library (kokoqmlplugin SHARED ${qml_plugin_SRCS}) target_link_libraries (kokoqmlplugin Qt5::Qml - Qt5::Quick KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets diff --git a/src/imagedocument.h b/src/imagedocument.h --- a/src/imagedocument.h +++ b/src/imagedocument.h @@ -26,7 +26,7 @@ { Q_OBJECT Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) - Q_PROPERTY(QImage visualImage READ visualImage WRITE setVisualImage NOTIFY visualImageChanged) + Q_PROPERTY(QImage visualImage READ visualImage NOTIFY visualImageChanged) Q_PROPERTY(bool edited READ edited WRITE setEdited NOTIFY editedChanged) public: ImageDocument(); @@ -36,7 +36,6 @@ void setPath( QString &url); QImage visualImage(); - void setVisualImage( QImage& image); bool edited(); void setEdited( bool value); diff --git a/src/imagedocument.cpp b/src/imagedocument.cpp --- a/src/imagedocument.cpp +++ b/src/imagedocument.cpp @@ -57,12 +57,6 @@ return *m_image; } -void ImageDocument::setVisualImage(QImage& image) -{ - m_image = ℑ - emit visualImageChanged(); -} - bool ImageDocument::edited() { return m_edited; diff --git a/src/imageprovider.cpp b/src/imageprovider.cpp deleted file mode 100644 --- a/src/imageprovider.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2017 by Atul Sharma - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "imageprovider.h" - -ImageProvider::ImageProvider() - : QQuickImageProvider(QQuickImageProvider::Image) -{ -} - -QImage ImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize) -{ - Q_UNUSED(size) - Q_UNUSED(requestedSize) - return QImage(id); -} - -#include "moc_imageprovider.cpp" diff --git a/src/qmlplugins.h b/src/qmlplugins.h --- a/src/qmlplugins.h +++ b/src/qmlplugins.h @@ -23,7 +23,6 @@ #define _QML_PLUGINS_H #include -#include class QmlPlugins : public QQmlExtensionPlugin { diff --git a/src/qmlplugins.cpp b/src/qmlplugins.cpp --- a/src/qmlplugins.cpp +++ b/src/qmlplugins.cpp @@ -32,13 +32,11 @@ #include "types.h" #include "roles.h" #include "imagedocument.h" -#include "imageprovider.h" #include -void QmlPlugins::initializeEngine(QQmlEngine *engine, const char *) +void QmlPlugins::initializeEngine(QQmlEngine *, const char *) { - engine->addImageProvider("imageprovider", new ImageProvider()); } void QmlPlugins::registerTypes(const char *uri)