Commit dab6acd5 authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

manage raw file loading

parent 4cc7a4d2
......@@ -47,6 +47,16 @@
#include <kicon.h>
#include <kvbox.h>
// libKdcraw includes
#include <libkdcraw/kdcraw.h>
// Local includes
#include "kpmetadata.h"
using namespace KDcrawIface;
namespace KIPIPlugins
{
......@@ -384,10 +394,10 @@ public:
enum
{
NONE,
LOOKAROUND,
DRAWSELECTION,
EXPANDORSHRINK,
NONE,
LOOKAROUND,
DRAWSELECTION,
EXPANDORSHRINK,
MOVESELECTION
}
mouseDragAction;
......@@ -541,7 +551,17 @@ void KPPreviewImage::enableSelectionArea(bool b)
bool KPPreviewImage::load(const QString& file) const
{
QImage image(file);
QImage image;
if (KPMetadata::isRawFile(file))
{
KDcraw::loadDcrawPreview(image, file);
}
else
{
image.load(file);
}
bool ret = setImage(image);
if (ret && d->enableSelection)
{
......
......@@ -86,7 +86,7 @@ public:
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget);
private:
void updateAnchors();
private:
......
......@@ -141,7 +141,7 @@ KPPreviewManager::~KPPreviewManager()
void KPPreviewManager::slotLoad(const KUrl& url)
{
load(url.path());
load(url.toLocalFile());
}
void KPPreviewManager::setImage(const QImage& img, bool fit)
......@@ -161,14 +161,14 @@ void KPPreviewManager::setImage(const QImage& img, bool fit)
}
}
void KPPreviewManager::load(const QString& file, bool fit)
bool KPPreviewManager::load(const QString& file, bool fit)
{
setBusy(false);
if (!d->preview->load(file))
{
setText(i18n( "Failed to load image" ));
return;
return false;
}
setCurrentIndex(PreviewMode);
......@@ -176,6 +176,7 @@ void KPPreviewManager::load(const QString& file, bool fit)
{
d->preview->slotZoom2Fit();
}
return true;
}
void KPPreviewManager::setThumbnail(const QPixmap& thumbnail)
......
......@@ -60,7 +60,7 @@ public:
KPPreviewManager(QWidget* const parent);
~KPPreviewManager();
void load(const QString& file, bool fit = true);
bool load(const QString& file, bool fit = true);
void setImage(const QImage& img, bool fit = true);
void setText(const QString& text, const QColor& color=Qt::white);
void setBusy(bool b, const QString& text=QString());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment