#include "kainstructionpage.h"
#include "templatebutton.h"
#include "global/kaglobal.h"
#include "libukcc/widgets/SettingWidget/settinggroup.h"

#include <QLabel>
#include <QSharedPointer>

class KAInstructionPage::Private
{
public:
    QLabel *mInstructTitleLabel = nullptr;
    UkccFrame *mTemplateFrame = nullptr;
    QLabel *mTemplateLabel = nullptr;
    int templateNumber = 8;
};

KAInstructionPage::KAInstructionPage(QWidget *parent)
    : QWidget{parent},
      d_ptr(make_shared<Private>())
{
    initLayout();
}

KAInstructionPage::~KAInstructionPage()
{

}


void KAInstructionPage::initLayout()
{
    QVBoxLayout *base_vlayout = new QVBoxLayout(this);

    QString templateNumberStr = QString::number(d_ptr->templateNumber);
    QString titleTextStr = tr("Instruction Template") + " (" + templateNumberStr + ")";
    d_ptr->mInstructTitleLabel = new QLabel(this);
    d_ptr->mInstructTitleLabel->setText(titleTextStr);
    d_ptr->mInstructTitleLabel->setContentsMargins(20, 0, 0, 0);
    QFont font("Noto Sans CJK SC", 11, QFont::DemiBold, false);
    d_ptr->mInstructTitleLabel->setFont(font);
    base_vlayout->addWidget(d_ptr->mInstructTitleLabel);

    d_ptr->mTemplateFrame = new UkccFrame(this);
    d_ptr->mTemplateFrame->setMinimumSize(QSize(490, 96));
    d_ptr->mTemplateFrame->setMaximumSize(QSize(16777215, 96));
    d_ptr->mTemplateFrame->setFrameShape(QFrame::Box);
    d_ptr->mTemplateFrame->setObjectName(QString("templateFrame"));

    QVBoxLayout *vLayout = new QVBoxLayout(d_ptr->mTemplateFrame);
    vLayout->setContentsMargins(20, 10, 20, 10);
    QHBoxLayout *hLayout1 = new QHBoxLayout(d_ptr->mTemplateFrame);
    hLayout1->setContentsMargins(0, 0, 0, 0);
    hLayout1->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    QHBoxLayout *hLayout2 = new QHBoxLayout(d_ptr->mTemplateFrame);
    hLayout2->setContentsMargins(0, 0, 0, 0);
    hLayout2->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);

    TemplateButton *template1 = new TemplateButton(tr("文本扩写"), this);
    TemplateButton *template2 = new TemplateButton(tr("文本润色"), this);
    TemplateButton *template3 = new TemplateButton(tr("翻译"), this);
    TemplateButton *template4 = new TemplateButton(tr("内容质检"), this);
    TemplateButton *template5 = new TemplateButton(tr("总结概括"), this);
    TemplateButton *template6 = new TemplateButton(tr("邮件回复"), this);
    TemplateButton *template7 = new TemplateButton(tr("工作总结"), this);
    TemplateButton *template8 = new TemplateButton(tr("代码生成"), this);

    hLayout1->addWidget(template1);
    hLayout1->addWidget(template2);
    hLayout1->addWidget(template3);
    hLayout1->addWidget(template4);
    hLayout1->addWidget(template5);
    hLayout1->addWidget(template6);
    hLayout2->addWidget(template7);
    hLayout2->addWidget(template8);

    d_ptr->mTemplateFrame->setLayout(vLayout);
    vLayout->addLayout(hLayout1);
    vLayout->addLayout(hLayout2);
    base_vlayout->addWidget(d_ptr->mInstructTitleLabel);
    base_vlayout->setSpacing(8);
    base_vlayout->addWidget(d_ptr->mTemplateFrame);
    base_vlayout->addStretch();
}

void KAInstructionPage::initConnection()
{

}

