#include "templatebutton.h"

#include <QLabel>
#include <QHBoxLayout>

// #include "kborderlessbutton.h"

// using namespace kdk;

class TemplateButton::Private
{
public:
    QLabel *m_textLabel = nullptr;
};

TemplateButton::TemplateButton(const QString& text, QWidget *parent)
    :  QPushButton{parent},
      d_ptr(make_shared<Private>())
{
    setText(text);
    initStyle();
    updateButton();
}

TemplateButton::~TemplateButton()
{

}

void TemplateButton::updateButton()
{
    QString buttonText = text();
    int textWidth = fontMetrics().horizontalAdvance(buttonText);
    setFixedWidth(textWidth + 20);
}
void TemplateButton::initStyle()
{
    this->setFixedHeight(28);
    setStyleSheet("QPushButton {"
                  "padding: 4px 8px 4px 8px;"
                  "border-radius: 4px 0px 0px 0px;"
                  "background: rgba(55, 144, 250, 0.1);"
                  "color: rgba(55, 144, 250, 1);"
                  "font-family: 'Noto Sans CJK SC';"
                  "font-size: 14px;"
                  "font-weight: 400;"
                  "line-height: 20px;"
                  "text-align: left;"
                  "}");
}
