diff --git a/qmlUiKirigami/ImageViewer.qml b/qmlUiKirigami/ImageViewer.qml --- a/qmlUiKirigami/ImageViewer.qml +++ b/qmlUiKirigami/ImageViewer.qml @@ -297,13 +297,14 @@ } } - KQA.QImageItem { + 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 - image: imageDoc.visualImage + source: imageObject Timer { id: doubleClickTimer interval: 150 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -66,12 +66,14 @@ 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 NOTIFY visualImageChanged) + Q_PROPERTY(QImage visualImage READ visualImage WRITE setVisualImage NOTIFY visualImageChanged) Q_PROPERTY(bool edited READ edited WRITE setEdited NOTIFY editedChanged) public: ImageDocument(); @@ -36,6 +36,7 @@ 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,6 +57,12 @@ return *m_image; } +void ImageDocument::setVisualImage(QImage& image) +{ + m_image = ℑ + emit visualImageChanged(); +} + bool ImageDocument::edited() { return m_edited; diff --git a/src/imageprovider.h b/src/imageprovider.h new file mode 100644 --- /dev/null +++ b/src/imageprovider.h @@ -0,0 +1,33 @@ +/* + * 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. + */ + +#ifndef IMAGE_PROVIDER_H +#define IMAGE_PROVIDER_H + +#include + +class ImageProvider: public QQuickImageProvider +{ +public: + explicit ImageProvider(); + + virtual QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize); +}; + +#endif diff --git a/src/imageprovider.cpp b/src/imageprovider.cpp new file mode 100644 --- /dev/null +++ b/src/imageprovider.cpp @@ -0,0 +1,34 @@ +/* + * 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,6 +23,7 @@ #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,11 +32,13 @@ #include "types.h" #include "roles.h" #include "imagedocument.h" +#include "imageprovider.h" #include -void QmlPlugins::initializeEngine(QQmlEngine *, const char *) +void QmlPlugins::initializeEngine(QQmlEngine *engine, const char *) { + engine->addImageProvider("imageprovider", new ImageProvider()); } void QmlPlugins::registerTypes(const char *uri)