/*
   SPDX-FileCopyrightText: 2015-2026 Laurent Montel <montel@kde.org>

   SPDX-License-Identifier: LGPL-2.0-or-later
*/

#pragma once

#include "gravatar_export.h"
#include <QWidget>
class QLabel;
class QLineEdit;
class QPushButton;
class QCheckBox;
namespace Gravatar
{
class GravatarResolvUrlJob;

/*!
 * \class Gravatar::GravatarDownloadPixmapWidget
 * \inmodule Gravatar
 * \inheaderfile Gravatar/GravatarDownloadPixmapWidget
 * \brief Avatar download widget
 * \author Laurent Montel <montel@kde.org>
 */
class GRAVATAR_EXPORT GravatarDownloadPixmapWidget : public QWidget
{
    Q_OBJECT
public:
    /*!
     * Constructs a Gravatar download pixmap widget.
     * \param parent the parent widget
     */
    explicit GravatarDownloadPixmapWidget(QWidget *parent = nullptr);
    /*!
     * Destroys the Gravatar download pixmap widget.
     */
    ~GravatarDownloadPixmapWidget() override;

    /*!
     * Returns the downloaded Gravatar pixmap.
     * \return the Gravatar pixmap
     */
    [[nodiscard]] QPixmap gravatarPixmap() const;

private:
    GRAVATAR_NO_EXPORT void slotSearchButton();

    GRAVATAR_NO_EXPORT void slotTextChanged(const QString &text);
    GRAVATAR_NO_EXPORT void slotResolvUrlFinish(Gravatar::GravatarResolvUrlJob *job);
    QPixmap mGravatarPixmap;
    QLabel *mResultLabel = nullptr;
    QLineEdit *mLineEdit = nullptr;
    QPushButton *mGetPixmapButton = nullptr;
    QCheckBox *mUseLibravatar = nullptr;
    QCheckBox *mFallbackGravatar = nullptr;
};
}
