#ifndef WIZARDWRAPPER_H
#define WIZARDWRAPPER_H
#include "uosai_global.h"

#include <QVariant>
#include <QPropertyAnimation>

#include <DIconButton>
#include <DWidget>
#include <DMainWindow>
#include <DGuiApplicationHelper>
#include <DBlurEffectWidget>

DGUI_USE_NAMESPACE

namespace  uos_ai {

class CustomButton;
class WizardDPushButton;
class WizardWrapper : public DTK_WIDGET_NAMESPACE::DBlurEffectWidget
{
    Q_OBJECT
public:
    static WizardWrapper &instance();
    void initAnimation();
    void showWizardWrapperWithAnimation();
    void isShowHiddenAction(bool isShow);
    void setButtonHidden(bool isHidden);
    bool isMouseInside() { return m_mouseInside; }
    bool isWidgetVisible() { return m_isVisible; }
    void setWidgetVisible(bool visible) {  m_isVisible = visible; }

protected:
    void paintEvent(QPaintEvent *event)override;
    bool eventFilter(QObject *watched, QEvent *event)override;
    void mouseMoveEvent(QMouseEvent *) override;

signals:
    void signalWizardBtnClicked(int wizardtype, QPoint cursorPos);
    void signalMoreMenuTriggered(int wizardtype, QPoint cursorPos);
    void signalRequestServer();
    void signalCloseBtnClicked();
    void signalIconBtnClicked();
    void signalEscEvent();

public slots:
    void showScribeWordsAtCursorPosition(QRect screenRect, QPoint& point, bool isMouseRelease, bool isShortcut);
    void onMoreMenuTriggered(const QAction *action);
    void onButtonClicked();
    void showMenu();
    void onCloseWidget();
    void onIconBtnClicked();

private:
    WizardWrapper(QWidget *parent = nullptr);
    void onUpdateSystemTheme(const DGuiApplicationHelper::ColorType &);
    void initUI();
    void initConnect();
    void adjustShowPos(const QRect &screenRect, QPoint &pos);
    bool isFirstClose();
    Q_DISABLE_COPY(WizardWrapper)

    DTK_WIDGET_NAMESPACE::DIconButton *m_iconBtn = nullptr;
    WizardDPushButton *m_searchBtn = nullptr;
    WizardDPushButton *m_explainBtn = nullptr;
    WizardDPushButton *m_summaryBtn = nullptr;
    WizardDPushButton *m_translationBtn = nullptr;
    WizardDPushButton *m_moreBtn = nullptr;
    WizardDPushButton *m_closeBtn = nullptr;

    DTK_WIDGET_NAMESPACE::DMenu *m_moreMenu = nullptr;
    DTK_WIDGET_NAMESPACE::DWidget *m_lineSep = nullptr;
    DTK_WIDGET_NAMESPACE::DMenu *m_polishmenu = nullptr;
    QAction *m_continueAction = nullptr;
    QAction *m_expandAction = nullptr;
    QAction *m_correctAction = nullptr;
    QAction *m_hiddenAction = nullptr;
    QAction *m_polishFormal = nullptr;
    QAction *m_polishFriendly = nullptr;
    QAction *m_polishHumor = nullptr;
    QAction *m_polishPassionate = nullptr;

    QPoint m_cursorPos;
    QRect m_screenRect;
    bool m_isExtend = false;
    QPropertyAnimation *m_animation = nullptr;
    bool m_mouseInside = false;
    bool m_isVisible = false;
};
}
#endif // WIZARDWRAPPER_H
