/src/qtbase/src/plugins/imageformats/ico/main.cpp
Line | Count | Source |
1 | | // Copyright (C) 2016 The Qt Company Ltd. |
2 | | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | | // Qt-Security score:significant reason:default |
4 | | |
5 | | #include <qimageiohandler.h> |
6 | | #include <qdebug.h> |
7 | | |
8 | | #ifdef QT_NO_IMAGEFORMAT_ICO |
9 | | #undef QT_NO_IMAGEFORMAT_ICO |
10 | | #endif |
11 | | #include "qicohandler.h" |
12 | | |
13 | | QT_BEGIN_NAMESPACE |
14 | | |
15 | | class QICOPlugin : public QImageIOPlugin |
16 | | { |
17 | 0 | Q_OBJECT |
18 | 0 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "ico.json") |
19 | 0 | public: |
20 | 0 | Capabilities capabilities(QIODevice *device, const QByteArray &format) const override; |
21 | 0 | QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override; |
22 | 0 | }; |
23 | 0 |
|
24 | 0 | QImageIOPlugin::Capabilities QICOPlugin::capabilities(QIODevice *device, const QByteArray &format) const |
25 | 0 | { |
26 | 0 | if (format == "ico" || format == "cur") |
27 | 0 | return Capabilities(CanRead | CanWrite); |
28 | 0 | if (!format.isEmpty()) |
29 | 0 | return { }; |
30 | 0 | if (!device->isOpen()) |
31 | 0 | return { }; |
32 | | |
33 | 0 | Capabilities cap; |
34 | 0 | if (device->isReadable() && QtIcoHandler::canRead(device)) |
35 | 0 | cap |= CanRead; |
36 | 0 | if (device->isWritable()) |
37 | 0 | cap |= CanWrite; |
38 | 0 | return cap; |
39 | 0 | } |
40 | | |
41 | | QImageIOHandler *QICOPlugin::create(QIODevice *device, const QByteArray &format) const |
42 | 0 | { |
43 | 0 | QImageIOHandler *handler = new QtIcoHandler(device); |
44 | |
|
45 | 0 | handler->setFormat(format); |
46 | 0 | return handler; |
47 | 0 | } |
48 | | |
49 | | QT_END_NAMESPACE |
50 | | |
51 | | #include "main.moc" |