diff --git a/CMakeLists.txt b/CMakeLists.txt index be2b3497b..1bbacb93d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,9 @@ option(WITH_WEBP_SUPPORT "Enable support to load/save .webp files" off) option(WITH_GTK_FILE_DIALOG_SUPPORT "Enable support for the experimental native GTK File Dialog" off) option(WITH_DEPRECATED_GLIB_SUPPORT "Enable support for older glib versions" off) +option(WITH_DESKTOP_INTEGRATION "Enable desktop integration modules" on) +option(WITH_QT_THUMBNAILER "Enable kde5/qt5 thumnailer" off) + option(USE_STATIC_LIBC "Use static version of C and C++ runtimes" off) option(USE_SHARED_CURL "Use your installed copy of curl" off) option(USE_SHARED_GIFLIB "Use your installed copy of giflib" off) @@ -410,6 +413,10 @@ if(APPLE) endif(COMPILER_GCC) endif(APPLE) +if(WITH_DESKTOP_INTEGRATION) + add_subdirectory(desktop) +endif() + ###################################################################### # Main ASE targets diff --git a/desktop/CMakeLists.txt b/desktop/CMakeLists.txt new file mode 100644 index 000000000..b348e45f7 --- /dev/null +++ b/desktop/CMakeLists.txt @@ -0,0 +1,16 @@ +# Aseprite Desktop Integration Module +# Copyright (C) 2016 Gabriel Rauter +# +# Licensed under the the MIT License (https://opensource.org/licenses/MIT). + +if(UNIX AND NOT APPLE) + install(FILES mime/aseprite.xml + DESTINATION share/mime/packages) + install(PROGRAMS aseprite-thumbnailer + DESTINATION bin) + install(FILES gnome/aseprite.thumbnailer + DESTINATION share/thumbnailers) + if(WITH_QT_THUMBNAILER) + add_subdirectory(kde) + endif() +endif() diff --git a/desktop/aseprite-thumbnailer b/desktop/aseprite-thumbnailer new file mode 100755 index 000000000..74277ea08 --- /dev/null +++ b/desktop/aseprite-thumbnailer @@ -0,0 +1,19 @@ +#!/usr/bin/sh + +# Aseprite Desktop Integration Module +# Copyright (C) 2016 Gabriel Rauter +# +# Licensed under the the MIT License (https://opensource.org/licenses/MIT). + +if [ $# -ge 2 -a $# -lt 4 ]; then + mkdir -p /tmp/Aseprite + filename=${1//\//.}$RANDOM + if [ $# -eq 2 ]; then + aseprite -b --frame-range "0,0" $1 --sheet /tmp/Aseprite/$filename.png + elif [ $# -eq 3 ]; then + aseprite -b --frame-range "0,0" $1 --shrink-to "$3,$3" --sheet /tmp/Aseprite/$filename.png + fi + mkdir -p $(dirname "$2"); mv /tmp/Aseprite/$filename.png $2; +else +echo "Parameters for aseprite thumbnailer are: inputfile outputfile [size]" +fi diff --git a/desktop/gnome/aseprite.thumbnailer b/desktop/gnome/aseprite.thumbnailer new file mode 100644 index 000000000..f991c34c3 --- /dev/null +++ b/desktop/gnome/aseprite.thumbnailer @@ -0,0 +1,4 @@ +[Thumbnailer Entry] +TryExec=aseprite-thumbnailer +Exec=aseprite-thumbnailer %i %o %s +MimeType=image/bmp;image/gif;image/jpeg;image/png;image/x-pcx;image/x-tga;image/vnd.microsoft.icon;video/x-flic;image/webp;image/x-aseprite; diff --git a/desktop/kde/CMakeLists.txt b/desktop/kde/CMakeLists.txt new file mode 100644 index 000000000..0b0ccd076 --- /dev/null +++ b/desktop/kde/CMakeLists.txt @@ -0,0 +1,23 @@ +# Aseprite Desktop Integration Module +# Copyright (C) 2016 Gabriel Rauter +# +# Licensed under the the MIT License (https://opensource.org/licenses/MIT). + +cmake_minimum_required(VERSION 2.8.12) +set(QT_MIN_VERSION "5.2.0") +project(asepritethumbnail) +find_package(ECM REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) +set(KDE_INSTALL_DIRS_NO_DEPRECATED, TRUE) +include(FeatureSummary) +include(WriteBasicConfigVersionFile) +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings) +find_package(KF5 REQUIRED COMPONENTS KIO) +add_definitions(${QT_DEFINITIONS} -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS) +set(KDE_INSTALL_USE_QT_SYS_PATHS) +add_library(asepritethumbnail MODULE aseprite_thumb_creator.cpp) +target_link_libraries(asepritethumbnail KF5::KIOWidgets) +install(TARGETS asepritethumbnail DESTINATION ${PLUGIN_INSTALL_DIR}) +install(FILES asepritethumbnail.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/desktop/kde/aseprite_thumb_creator.cpp b/desktop/kde/aseprite_thumb_creator.cpp new file mode 100644 index 000000000..c5f1a6553 --- /dev/null +++ b/desktop/kde/aseprite_thumb_creator.cpp @@ -0,0 +1,38 @@ +// Aseprite Desktop Integration Module +// Copyright (C) 2016 Gabriel Rauter +// +// Licensed under the the MIT License (https://opensource.org/licenses/MIT). + +#include "aseprite_thumb_creator.h" + +#include +#include +#include +#include +#include +#include + +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; +} diff --git a/desktop/kde/aseprite_thumb_creator.h b/desktop/kde/aseprite_thumb_creator.h new file mode 100644 index 000000000..bc1e80089 --- /dev/null +++ b/desktop/kde/aseprite_thumb_creator.h @@ -0,0 +1,21 @@ +// Aseprite Desktop Integration Module +// Copyright (C) 2016 Gabriel Rauter +// +// Licensed under the the MIT License (https://opensource.org/licenses/MIT). + +#ifndef _ASEPRITE_THUMBCREATOR_H_ +#define _ASEPRITE_THUMBCREATOR_H_ +#pragma once + +#include +Q_DECLARE_LOGGING_CATEGORY(LOG_ASEPRITE_THUMBCREATOR) + +#include + +class AsepriteThumbCreator : public ThumbCreator { + public: + bool create(const QString& path, int width, int height, QImage& img) override; + Flags flags() const override; +}; + +#endif diff --git a/desktop/kde/asepritethumbnail.desktop b/desktop/kde/asepritethumbnail.desktop new file mode 100644 index 000000000..e7c7a0082 --- /dev/null +++ b/desktop/kde/asepritethumbnail.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Service +Name=Aseprite Pixel Art +MimeType=image/bmp;image/gif;image/jpeg;image/png;image/x-pcx;image/x-tga;image/vnd.microsoft.icon;video/x-flic;image/webp;image/x-aseprite; +X-KDE-ServiceTypes=ThumbCreator +X-KDE-Library=asepritethumbnail +CacheThumbnail=true +ThumbnailerVersion=1 diff --git a/desktop/mime/aseprite.xml b/desktop/mime/aseprite.xml new file mode 100644 index 000000000..52b2adb92 --- /dev/null +++ b/desktop/mime/aseprite.xml @@ -0,0 +1,12 @@ + + + + Aseprite Pixel Art + + + + + + + + diff --git a/src/she/CMakeLists.txt b/src/she/CMakeLists.txt index cddf5bc44..1841aa680 100644 --- a/src/she/CMakeLists.txt +++ b/src/she/CMakeLists.txt @@ -242,7 +242,8 @@ if(USE_ALLEG4_BACKEND) target_link_libraries(she ${LOADPNG_LIBRARY} ${LIBALLEGRO4_LINK_FLAGS} - ${DXGUID_LIBRARIES}) + ${DXGUID_LIBRARIES} + ${X11_LIBRARIES}) endif() if(USE_SKIA_BACKEND)