#ifndef SELECTION_H
#define SELECTION_H

#include <QWidget>
#include <QPushButton>
#include <QLayout>
#include <QLabel>
#include "mypushbutton.h"

class CustomButton;

class SelectWidget : public QWidget
{
    Q_OBJECT
public:
    explicit SelectWidget(QWidget *parent = nullptr);
    QString getButtonText();
    void closeWidgetAndinstructPage(int x, int y);

public slots:
    void showScribeWordsAtCursorPosition();
    void sendButtonText();

protected:
    void paintEvent(QPaintEvent *event);
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);

signals:
    void signalSendClicpText();
    void sigbuttontext();
    void sigHomePageShow();
    void sigSettingShow();
    void sigDisableScribe();

private:
    int m_nMouseClick_X_Coordinate;
    int m_nMouseClick_Y_Coordinate;
    MyPushButton *settingButton = nullptr;
    QPushButton *m_textExpansionButton = nullptr;
    QPushButton *m_textPolishingButton = nullptr;
    QPushButton *m_translateButton = nullptr;
    CustomButton *m_totalButton = nullptr;
    QString buttonText;
    bool instructIsVisible = false;
    QDialog *instructPage = nullptr;
    QPixmap upScaledPixmap;
    QPixmap downScaledPixmap;


private:
    void insertText(const QString &text);

private slots:



};

class CustomButton : public QPushButton
{
    Q_OBJECT
public:
    CustomButton(const QString &text, const QIcon &icon, QWidget *parent = nullptr)
        : QPushButton(parent), iconLabel(new QLabel(this))
    {
        QHBoxLayout *layout = new QHBoxLayout(this);
        QLabel *label = new QLabel(text, this);
        iconLabel->setPixmap(icon.pixmap(16, 16));
        layout->setSpacing(0);
        layout->setContentsMargins(0, 0, 0, 0);
        label->setStyleSheet("QLabel {"
                                     "background-color: transparent;"
                                     "margin-left: 4px;"
                                     "margin-right: 0px;"
                                     "margin-top: 4px;"
                                     "margin-bottom: 4px;"
                                     "}"
                                     "QLabel:hover {"
                                     "background-color: transparent;"
                                     "}");
        iconLabel->setStyleSheet("QLabel {"
                                     "margin-top: 4px;"
                                     "margin-bottom: 4px;"
                                     "background-color: transparent;"
                                     "}"
                                     "QLabel:hover {"
                                     "background-color: transparent;"
                                     "}");
        layout->addWidget(label);
        layout->addWidget(iconLabel);
    }
    void setIconLabelPixmap(const QPixmap &pixmap)
    {
        iconLabel->setPixmap(pixmap);
    }

private:
    QLabel *iconLabel;

};



#endif // SELECTION_H

