aseprite/desktop/kde/aseprite_thumb_creator.cpp

40 lines
954 B
C++
Raw Normal View History

2016-04-05 12:49:19 +00:00
// Aseprite Desktop Integration Module
// Copyright (C) 2016 Gabriel Rauter
//
2016-04-05 22:15:40 +00:00
// Licensed under the the MIT License (https://opensource.org/licenses/MIT).
2016-04-05 12:49:19 +00:00
#include "aseprite_thumb_creator.h"
#include <QImage>
#include <QProcess>
#include <QStringList>
#include <QFile>
#include <QCryptographicHash>
#include <cstdio>
extern "C"
{
Q_DECL_EXPORT ThumbCreator *new_creator()
{
return new AsepriteThumbCreator();
}
};
bool AsepriteThumbCreator::create(const QString& path, int width, int height, QImage& img)
{
QProcess process;
QStringList list;
QString tmpFile = QString(QCryptographicHash::hash(path.toLocal8Bit(),QCryptographicHash::Md5).toHex());
list << path << tmpFile;
process.start(QString("aseprite-thumbnailer"), list);
if (!process.waitForFinished()) return false;
img.load(tmpFile);
QFile::remove(tmpFile);
return true;
}
AsepriteThumbCreator::Flags AsepriteThumbCreator::flags() const
{
return DrawFrame;
}