#ifndef COMMANDPAGE_H
#define COMMANDPAGE_H

#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QQuickWidget>
#include <QQmlContext>
#include <QSettings>
#include <QQuickItem>
#include <QScrollArea>
#include <QScrollBar>
#include <kborderlessbutton.h>

#include "libukcc/widgets/SettingWidget/settinggroup.h"
#include "commandconfigdialog.h"
#include "global/kaglobal.h"
#include "commandtemplatelist.h"
#include "lightlabel.h"
#include "titlelabel.h"

using namespace std;

class CommandPage : public QWidget
{

    Q_OBJECT

public:
    explicit CommandPage(QWidget *parent = nullptr);
    void initCommandPageWidget();
    // 获取当前是否在编辑状态
    bool isInEditingState() const;

    ~CommandPage();

signals:
    void editModeChanged(bool editing);
    void sigDeleteActiveCommand(int actorId, QString name);


public slots:
    // 添加自定义提示词弹窗
    void onAddBtnClicked();
    // 二次编辑和查看弹窗
    void onCommandClicked(int type, int actorId, QString name, QString content);
    // 创建提示词
    void onCreateCommand(QString name, QString content);
    // 编辑提示词
    void onEditCommand(int actorId, QString name, QString content);
    // 删除确认弹窗
    void showConfirmMessage(int actorId, QString name);
    // 更新QML内容区高度
    void onContentHeightChanged(int height);

private:
    void initLayout();
    void initConnection();
    // 报错弹窗
    void showErrorMessage(const QString &message, QWidget *parent);

private:
    QLabel *m_titleLabel = nullptr;
    LightLabel *m_tipLabel = nullptr;
    kdk::KBorderlessButton *m_addButton = nullptr;

    QWidget *m_titleWidget = nullptr;
    QWidget *m_tipWidget = nullptr;
    QQuickWidget *m_commandWidget = nullptr;

    QWidget *m_scrollWidget = nullptr;
    QScrollArea *m_scrollArea = nullptr;

};

#endif // COMMANDPAGE_H
