init commit
This commit is contained in:
		
							
								
								
									
										17
									
								
								imageformats/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								imageformats/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,17 @@
 | 
			
		||||
set (plugin pimg_sai)
 | 
			
		||||
 | 
			
		||||
set (PLUGIN_SOURCES
 | 
			
		||||
    sai_p.h
 | 
			
		||||
    sai.cpp
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
# {{{ KCM style
 | 
			
		||||
set(CMAKE_SHARED_MODULE_PREFIX "")
 | 
			
		||||
unset(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
 | 
			
		||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
 | 
			
		||||
# }}}
 | 
			
		||||
 | 
			
		||||
add_library(${plugin} MODULE ${PLUGIN_SOURCES})
 | 
			
		||||
set_property(TARGET ${plugin} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS "sai.json")
 | 
			
		||||
set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/imageformats")
 | 
			
		||||
target_link_libraries(${plugin} Qt5::Gui sai)
 | 
			
		||||
							
								
								
									
										61
									
								
								imageformats/sai.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								imageformats/sai.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,61 @@
 | 
			
		||||
#include "sai_p.h"
 | 
			
		||||
 | 
			
		||||
#include "sai.hpp"
 | 
			
		||||
 | 
			
		||||
SAIHandler::SAIHandler()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool SAIHandler::canRead() const
 | 
			
		||||
{
 | 
			
		||||
    if (canRead(device())) {
 | 
			
		||||
        setFormat("sai");
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool SAIHandler::read(QImage *image)
 | 
			
		||||
{
 | 
			
		||||
    Q_UNUSED(image)
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool SAIHandler::write(const QImage &image)
 | 
			
		||||
{
 | 
			
		||||
    Q_UNUSED(image)
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool SAIHandler::canRead(QIODevice *device)
 | 
			
		||||
{
 | 
			
		||||
    if (!device) {
 | 
			
		||||
        qWarning("SAIHandler::canRead() called with no device");
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // FIXME: check
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QImageIOPlugin::Capabilities SAIPlugin::capabilities(QIODevice *device, const QByteArray &format) const
 | 
			
		||||
{
 | 
			
		||||
    if (!format.isEmpty()) {
 | 
			
		||||
        return {};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!device->isOpen()) {
 | 
			
		||||
        return {};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return Capabilities(CanRead);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QImageIOHandler *SAIPlugin::create(QIODevice *device, const QByteArray &format) const
 | 
			
		||||
{
 | 
			
		||||
    QImageIOHandler *handler = new SAIHandler;
 | 
			
		||||
    handler->setDevice(device);
 | 
			
		||||
    handler->setFormat(format);
 | 
			
		||||
    return handler;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										4
									
								
								imageformats/sai.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								imageformats/sai.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
			
		||||
{
 | 
			
		||||
  "Keys": [ "sai" ],
 | 
			
		||||
  "MimeTypes": []
 | 
			
		||||
} 
 | 
			
		||||
							
								
								
									
										25
									
								
								imageformats/sai_p.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								imageformats/sai_p.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <QImageIOPlugin>
 | 
			
		||||
 | 
			
		||||
class SAIHandler : public QImageIOHandler
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    SAIHandler();
 | 
			
		||||
 | 
			
		||||
    bool canRead() const override;
 | 
			
		||||
    bool read(QImage *image) override;
 | 
			
		||||
    bool write(const QImage &image) override;
 | 
			
		||||
 | 
			
		||||
    static bool canRead(QIODevice *device);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class SAIPlugin : public QImageIOPlugin
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "sai.json")
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    Capabilities capabilities(QIODevice *device, const QByteArray &format) const override;
 | 
			
		||||
    QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override;
 | 
			
		||||
};
 | 
			
		||||
		Reference in New Issue
	
	Block a user