// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef CLIPBOARDLOADER_H
#define CLIPBOARDLOADER_H

#include "constants.h"
#include "wlrintegration/wlrdatacontrolclipboardinterface.h"
#include "iteminfo.h"

#include <QObject>
#include <QClipboard>
#include <QDBusMetaType>
#include <QIcon>
#include <QDateTime>
#include <QList>
#include <QDebug>
#include <QDBusArgument>
#include <QDateTime>
#include <QUrl>

class ClipboardLoader : public QObject
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "org.deepin.dde.ClipboardLoader1")

public:
    explicit ClipboardLoader(QObject *parent = nullptr);

    bool cachePixmap(const QImage &srcPix, ItemInfo &info);
    void setImageData(const ItemInfo &info, QMimeData *&mimeData);

    static bool initPixPath();

public Q_SLOTS:
    void dataReborned(const QByteArray &buf);

private Q_SLOTS:
    void doWork(int protocolType);

Q_SIGNALS:
    void dataComing(const QByteArray &buf);

private:
    void extracted(const QMimeData *&mimeData, bool &dataChanged);

private:
    QClipboard *m_board;
    QByteArray m_lastTimeStamp;
    QImage m_lastImage;
    WlrDataControlClipboardInterface *m_wlrClipboard;

    static QString m_pixPath;

    QMap<QString, QByteArray> m_lastFormatMap;
    bool m_clearLastData = false;
};

#endif // CLIPBOARDLOADER_H
