File: main.cpp

package info (click to toggle)
dde-qt5integration 5.7.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,528 kB
  • sloc: cpp: 12,089; xml: 154; sh: 13; makefile: 10
file content (52 lines) | stat: -rw-r--r-- 1,379 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (C) 2022 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "qdciiohandler.h"

#include <QImageIOHandler>
#include <QStringList>
#include <QIODevice>
#include <QByteArray>

QT_BEGIN_NAMESPACE

class QDciPlugin : public QImageIOPlugin
{
    Q_OBJECT
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "dci.json")

public:
    QStringList keys() const;
    Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
    QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const;
};

QStringList QDciPlugin::keys() const
{
    return QStringList() << QLatin1String("dci");
}

QImageIOPlugin::Capabilities QDciPlugin::capabilities(QIODevice *device, const QByteArray &format) const
{
    if (format == QByteArrayLiteral("dci") || format.startsWith(QByteArrayLiteral("dci-")))
        return Capabilities(CanRead);
    if (!format.isEmpty())
        return {};

    Capabilities cap;
    if (device->isReadable() && QDciIOHandler::canRead(device))
        cap |= CanRead;
    return cap;
}

QImageIOHandler *QDciPlugin::create(QIODevice *device, const QByteArray &format) const
{
    QDciIOHandler *hand = new QDciIOHandler();
    hand->setDevice(device);
    hand->setFormat(format);
    return hand;
}

QT_END_NAMESPACE

#include "main.moc"