#ifndef SETTINGDIALOG_H
#define SETTINGDIALOG_H

#include <QDialog>
#include <QLabel>
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <memory>
#include <kwidget.h>
#include <aiconfig/modelconfig.h>
#include <ukuistylehelper/ukuistylehelper.h>

#include "commandpage.h"
#include "systemchat.h"
#include "global/kaglobal.h"
#include "generalpage.h"

using namespace kdk;
using namespace std;
using namespace kyai::config::model;

class ConfirmSaveDialog : public QDialog
{
    Q_OBJECT
public:
    explicit ConfirmSaveDialog(QWidget *parent = nullptr);
    ~ConfirmSaveDialog();

signals:
    void sigSaveBtnClicked();
    void sigCancelBtnClicked();
    void sigCloseBtnClicked();

public slots:
    void onSaveBtnClicked();
    void onCancelBtnClicked();
    void onCloseBtnClicked();

private:
    void initLayout();
    void initConnect();

    QLabel *m_textLabel;
    QLabel *m_iconLabel;
    QPushButton *m_saveButton;
    QPushButton *m_cancelButton;
    QPushButton *m_closeButton;

    QWidget *m_titleWidget;
    QWidget *m_contentWidget;
    QWidget *m_buttonWidget;
};

class SettingDialog : public KWidget
{
    Q_OBJECT
    friend class ConfirmSaveDialog;
public:
    SettingDialog(QWidget *parent = nullptr);
    static SettingDialog *sharedInstance;
    ~SettingDialog();
    void resetIndex();

signals:
    void sigChangeTheme();
    void sigSetCloudModel(AiCapability capability, QString modelName);

public slots:
    void onThemeChanged();
    void onSetSelectCloudModel(AiCapability capability, QString modelName);
    void slUpdateCloseMode(bool isHideToTray);
private:
    void initLayout();
    void initConnect();
    void initSideBar();
    void initBaseBar();

private slots:
    void onCancelOperation();
    void showSaveMsgBox();
    void slotNaviClicked(const QModelIndex &index);

protected:
    void closeEvent(QCloseEvent *event) override;
    void paintEvent(QPaintEvent *event) override;

private:
    class Private;
    shared_ptr<Private> d_ptr;
};

#endif // SETTINGDIALOG_H
