Commit 19435d86 authored by azubieta's avatar azubieta
Browse files

Merge branch 'development' into 'master'

Development

See merge request !5
parents bac1ec2a a3bcd1c2
Pipeline #625 passed with stage
in 1 minute and 40 seconds
...@@ -2,11 +2,16 @@ ...@@ -2,11 +2,16 @@
set -e set -e
echo "Installing appimage-services" APPIMAGE_SERVICES_BIN_PATH=/usr/bin/appimage-services
echo "Downloading latest version from opencode.net"
APPIMAGE_SERVICES_URL="https://www.opencode.net/azubieta/AppImageService/-/jobs/artifacts/master/raw/appimage-services-x86_64.AppImage?job=build:AppImage" APPIMAGE_SERVICES_URL="https://www.opencode.net/azubieta/AppImageService/-/jobs/artifacts/master/raw/appimage-services-x86_64.AppImage?job=build:AppImage"
wget $APPIMAGE_SERVICES_URL -O /usr/bin/appimage-services if [ -f "$APPIMAGE_SERVICES_BIN_PATH" ]
then
echo "Using appimamge-services bin from $APPIMAGE_SERVICES_BIN_PATH"
else
echo "Installing appimage-services to $APPIMAGE_SERVICES_BIN_PATH"
wget "$APPIMAGE_SERVICES_URL" -O "$APPIMAGE_SERVICES_BIN_PATH"
chmod +x /usr/bin/appimage-services chmod +x "$APPIMAGE_SERVICES_BIN_PATH"
/usr/bin/appimage-services self-install "$APPIMAGE_SERVICES_BIN_PATH" self-install
fi
add_subdirectory(appimageservices-interface) add_subdirectory(appimageservices-interface)
add_subdirectory(fileitem-actions) add_subdirectory(fileitem-actions)
add_subdirectory(metadata-extractor) add_subdirectory(metadata-extractor)
add_subdirectory(thumbnailer)
add_subdirectory(bin) add_subdirectory(bin)
// libraries
#include <QString>
#include <QImage>
#include <QStandardPaths>
#include <QMimeType>
#include <QLoggingCategory>
#include <QUrl>
#include <QFile>
#include <QDir>
#include <QTemporaryFile>
#include <QStandardPaths>
#include <QCryptographicHash>
// local
#include "AppImageThumbnailCreator.h"
#include "InspectorInterface.h"
Q_LOGGING_CATEGORY(LOG_APPIMAGE_THUMBS, "AppImageThumbnailer")
extern "C"
{
Q_DECL_EXPORT ThumbCreator* new_creator() {
return new AppImageThumbnailCreator();
}
}
AppImageThumbnailCreator::AppImageThumbnailCreator(QObject* parent) : QObject(parent),
inspectorInterface(
new OrgAppimageServices1InspectorInterface(
"org.appimage.Services1.Inspector",
"/org/appimage/Services1/Inspector",
QDBusConnection::sessionBus(), this)) {
}
AppImageThumbnailCreator::~AppImageThumbnailCreator() = default;
ThumbCreator::Flags AppImageThumbnailCreator::flags() const {
return ThumbCreator::None;
}
bool AppImageThumbnailCreator::create(const QString& path, int w, int h, QImage& thumb) {
if (inspectorInterface->isValid()) {
QTemporaryFile temporaryFile;
if (temporaryFile.open()) {
auto reply = inspectorInterface->extractFile(path, ".DirIcon", temporaryFile.fileName());
reply.waitForFinished();
if (reply.isError()) {
return false;
} else {
bool res = thumb.load(temporaryFile.fileName());
thumb = thumb.scaled(w, h);
return res;
}
} else {
return false;
}
} else {
qCDebug(LOG_APPIMAGE_THUMBS) << "Unable to connect to appimage services dbus interface";
return false;
}
}
bool AppImageThumbnailCreator::isAnAcceptedMimeType(const QString& path) const {
QMimeType type = db.mimeTypeForFile(path);
return type.isValid() &&
(type.inherits("application/x-iso9660-appimage") || type.inherits("application/vnd.appimage"));
}
#pragma once
// libraries
#include <QObject>
#include <QMimeDatabase>
#include <QLoggingCategory>
#include <kio/thumbcreator.h>
Q_DECLARE_LOGGING_CATEGORY(LOG_APPIMAGE_THUMBS)
class OrgAppimageServices1InspectorInterface;
class AppImageThumbnailCreator : public QObject, public ThumbCreator {
Q_OBJECT
QMimeDatabase db;
public:
explicit AppImageThumbnailCreator(QObject* parent = 0);
~AppImageThumbnailCreator() override;
bool create(const QString& path, int w, int h, QImage& thumb) override;
Flags flags() const override;
bool isAnAcceptedMimeType(const QString& path) const;
private:
OrgAppimageServices1InspectorInterface *inspectorInterface;
};
add_library(appimage-thumbnailer MODULE AppImageThumbnailCreator.cpp)
target_link_libraries(appimage-thumbnailer PRIVATE KF5::KIOWidgets appimageservices-interfaces)
install(TARGETS appimage-thumbnailer DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES org.appimage.appimage-thumbnailer.desktop DESTINATION ${SERVICES_INSTALL_DIR})
[Desktop Entry]
Encoding=UTF-8
Type=Service
Name=AppImage
ServiceTypes=ThumbCreator
MimeType=application/x-iso9660-appimage;application/vnd.appimage;
CacheThumbnail=true
X-KDE-Library=appimage-thumbnailer
ThumbnailerVersion=6
Supports Markdown
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