diff options
author | Alex <prevedtest@gmail.com> | 2013-12-16 22:32:39 +0400 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-17 11:22:27 +0100 |
commit | a9d13d79298ec7f7c7f69fb38f97b0f48ca45323 (patch) | |
tree | 5c53708f1d425df8ebef26f5fec5e24227c9f880 /src/plugins/imageformats/icns/main.cpp | |
parent | 2c7b8941ae4e70787f56fc277b582c8c698716d3 (diff) |
Add ICNS (Apple Icon Image) plugin.
Change-Id: I98f79d781e5986ee5602438e02d761c7f5a77217
Reviewed-by: Ivan Komissarov <ABBAPOH@me.com>
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/plugins/imageformats/icns/main.cpp')
-rw-r--r-- | src/plugins/imageformats/icns/main.cpp | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/plugins/imageformats/icns/main.cpp b/src/plugins/imageformats/icns/main.cpp new file mode 100644 index 0000000..62d1f8d --- /dev/null +++ b/src/plugins/imageformats/icns/main.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2013 Alex Char. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT_NO_IMAGEFORMATPLUGIN + +#include "qicnshandler_p.h" + +#ifndef QT_NO_DATASTREAM + +QT_BEGIN_NAMESPACE + +class QICNSPlugin : public QImageIOPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "icns.json") + +public: + Capabilities capabilities(QIODevice *device, const QByteArray &format) const; + QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const; +}; + +QImageIOPlugin::Capabilities QICNSPlugin::capabilities(QIODevice *device, const QByteArray &format) const +{ + if (format == QByteArrayLiteral("icns")) + return Capabilities(CanRead | CanWrite); + if (!format.isEmpty()) + return 0; + if (!device || !device->isOpen()) + return 0; + + Capabilities cap; + if (device->isReadable() && QICNSHandler::canRead(device)) + cap |= CanRead; + if (device->isWritable()) + cap |= CanWrite; + return cap; +} + +QImageIOHandler *QICNSPlugin::create(QIODevice *device, const QByteArray &format) const +{ + QImageIOHandler *handler = new QICNSHandler(); + handler->setDevice(device); + handler->setFormat(format); + return handler; +} + +QT_END_NAMESPACE + +#include "main.moc" + +#endif // QT_NO_DATASTREAM + +#endif // QT_NO_IMAGEFORMATPLUGIN |