mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-23 04:20:56 +00:00
add linux thumbnailers for Gnome & KDE/Qt
This adds thumbnailer support both for Gnome and KDE5/Qt5. The gnome thumbnailer is installed by default on linux systems, as it does not add any additional dependencies at build time and can be used by GnomeThumbnailFactory. The KDE/Qt thumbnailer need the whole Qt and Kio stack to build, as well as the distribution dependend variables set. Because of that it is not build by default. For the thumnailers to work for all of aseprites supported file formats and additonal mime type file is installed. Packagers in addition need to call update-mime-database path-to-mime-database (/usr/share/mime for example) as post install command.
This commit is contained in:
parent
5847624d0e
commit
75445d0b67
@ -38,6 +38,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)
|
||||
@ -396,6 +399,10 @@ if(APPLE)
|
||||
endif(COMPILER_GCC)
|
||||
endif(APPLE)
|
||||
|
||||
if(WITH_DESKTOP_INTEGRATION)
|
||||
add_subdirectory(desk)
|
||||
endif()
|
||||
|
||||
######################################################################
|
||||
# Main ASE targets
|
||||
|
||||
|
11
desk/CMakeLists.txt
Normal file
11
desk/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
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()
|
13
desk/aseprite-thumbnailer
Executable file
13
desk/aseprite-thumbnailer
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/sh
|
||||
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
|
4
desk/gnome/aseprite.thumbnailer
Normal file
4
desk/gnome/aseprite.thumbnailer
Normal file
@ -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;
|
18
desk/kde/CMakeLists.txt
Normal file
18
desk/kde/CMakeLists.txt
Normal file
@ -0,0 +1,18 @@
|
||||
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})
|
33
desk/kde/aseprite_thumb_creator.cpp
Normal file
33
desk/kde/aseprite_thumb_creator.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#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;
|
||||
}
|
16
desk/kde/aseprite_thumb_creator.h
Normal file
16
desk/kde/aseprite_thumb_creator.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef _ASEPRITE_THUMBCREATOR_H_
|
||||
#define _ASEPRITE_THUMBCREATOR_H_
|
||||
#pragma once
|
||||
|
||||
#include <QLoggingCategory>
|
||||
Q_DECLARE_LOGGING_CATEGORY(LOG_ASEPRITE_THUMBCREATOR)
|
||||
|
||||
#include <kio/thumbcreator.h>
|
||||
|
||||
class AsepriteThumbCreator : public ThumbCreator {
|
||||
public:
|
||||
virtual bool create(const QString& path, int width, int height, QImage& img);
|
||||
virtual Flags flags() const;
|
||||
};
|
||||
|
||||
#endif
|
8
desk/kde/asepritethumbnail.desktop
Normal file
8
desk/kde/asepritethumbnail.desktop
Normal file
@ -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
|
12
desk/mime/aseprite.xml
Normal file
12
desk/mime/aseprite.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
|
||||
<mime-type type="image/x-aseprite">
|
||||
<comment xml:lang="en">Aseprite Pixel Art</comment>
|
||||
<magic priority="50">
|
||||
<match type="little16" value="0xA5E0" offset="4"/>
|
||||
</magic>
|
||||
<glob pattern="*.ase"/>
|
||||
<glob pattern="*.aseprite"/>
|
||||
<icon name="aseprite"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
Loading…
x
Reference in New Issue
Block a user